Microchip® Advanced Software Framework

suite.h File Reference

Test suite core declarations.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include <compiler.h>
#include <parts.h>
#include <stdio.h>

Data Structures

struct  test_case
 A test case. More...
 
struct  test_suite
 A test suite. More...
 

Macros

#define ARRAY_LEN(a)   (sizeof(a) / sizeof((a)[0]))
 Convenience macro for counting elements in arrays. More...
 
#define Assert(expr)
 Assert() macro definition for unit testing. More...
 
Wrappers for printing debug information
Note
The test suite framework feeds its output to printf. It is left up to the test application to set up the stream.
#define dbg(__fmt_)   printf(__fmt_)
 
#define dbg_info(__fmt_,...)   printf(__fmt_, __VA_ARGS__)
 
#define dbg_error(_x,...)   printf(_x, __VA_ARGS__)
 
#define dbg_putchar(c)   putc(c, stdout)
 
#define dbg_vprintf_pgm(...)   vfprintf(stdout, __VA_ARGS__)
 
Test suite definition macros
#define DEFINE_TEST_CASE(_sym, _setup, _run, _cleanup, _name)
 Create a test case struct. More...
 
#define DEFINE_TEST_ARRAY(_sym)   const struct test_case *const _sym[]
 Create an array of test case pointers. More...
 
#define DEFINE_TEST_SUITE(_sym, _test_array, _name)
 Create a test suite. More...
 

Functions

void test_case_fail (const struct test_case *test, int result, const char *file, unsigned int line, const char *fmt,...)
 Report a failure and jump out of current test case function. More...
 
Test suite interaction
int test_suite_run (const struct test_suite *suite)
 Run a test suite. More...
 

Test data access

void * test_priv_data
 Data pointer for test cases. More...
 
static void test_set_data (void *data)
 Set private data pointer for the current test. More...
 
static void * test_get_data (void)
 Get the private data pointer for the current test. More...
 

Test case pointer access

struct test_casetest_case_ptr
 Pointer to current test case. More...
 
static void test_set_case (const struct test_case *test)
 Set pointer to current test. More...
 
static struct test_casetest_get_case (void)
 Get pointer to current test. More...
 

Test result reporting

#define test_fail(test, result,...)   test_case_fail(test, result, __FILE__, __LINE__, __VA_ARGS__)
 Fail the test. More...
 
#define test_assert_true(test, condition,...)
 Verify that condition is true. More...
 
#define test_assert_false(test, condition,...)   test_assert_true(test, !(condition), __VA_ARGS__)
 Verify that condition is false. More...
 
enum  test_status {
  TEST_ERROR = -1,
  TEST_PASS = 0,
  TEST_FAIL = 1
}
 Status codes returned by test cases and fixtures. More...
 

#define Assert (   expr)
Value:
{ \
"Assertion failed: %s", #expr); \
} else { \
if (!(expr)) { \
dbg_error("Assertion '%s' failed at %s:%d\r\n", \
#expr, __FILE__, __LINE__); \
while (true); \
} \
} \
}
if((SERIAL_RX_BUF_SIZE_HOST-1)==serial_rx_buf_tail)
Definition: sio2host.c:258
#define test_assert_true(test, condition,...)
Verify that condition is true.
Definition: suite.h:386
#define dbg_error(_x,...)
Definition: suite.h:219
static struct test_case * test_get_case(void)
Get pointer to current test.
Definition: suite.h:328
#define NULL
Definition: nm_bsp.h:64

Assert() macro definition for unit testing.

The Assert() macro is set up to use test_assert_true(), as this will only halt execution of the current test, allowing the remaining tests a chance to complete.

Referenced by _ac_set_config(), _adc_configure_ain_pin(), _adc_get_inst_index(), _dac_set_config(), _dma_set_config(), _i2c_master_async_address_response(), _i2c_master_interrupt_handler(), _i2c_master_read(), _i2c_master_read_packet(), _i2c_master_write(), _i2c_master_write_packet(), _i2c_slave_interrupt_handler(), _i2c_slave_set_config(), _i2c_slave_wait_for_bus(), _opamp_get_config_common_defaults(), _rtc_calendar_set_config(), _rtc_count_set_config(), _sercom_default_handler(), _sercom_get_default_pad(), _sercom_get_sercom_inst_index(), _spi_check_config(), _spi_clear_tx_complete_flag(), _spi_master_vec_int_handler(), _spi_read_buffer(), _spi_set_config(), _spi_transceive_buffer(), _spi_write_buffer(), _system_pinmux_config(), _tc_get_inst_index(), _tcc_get_inst_index(), _tcc_set_compare_value(), _tcc_set_top_value(), _uhd_ctrl_request_end(), _uhd_ep0_setup(), _uhd_ep0_transfer_complete(), _uhd_pipe_trans_complete(), _usart_read_buffer(), _usart_set_config(), _usart_write_buffer(), ac_chan_clear_status(), ac_chan_disable(), ac_chan_enable(), ac_chan_get_config_defaults(), ac_chan_get_status(), ac_chan_is_ready(), ac_chan_set_config(), ac_chan_trigger_single_shot(), ac_disable(), ac_disable_callback(), ac_disable_events(), ac_enable(), ac_enable_callback(), ac_enable_events(), ac_get_config_defaults(), ac_init(), ac_is_syncing(), ac_register_callback(), ac_reset(), ac_unregister_callback(), ac_win_clear_status(), ac_win_disable(), ac_win_enable(), ac_win_get_config_defaults(), ac_win_get_status(), ac_win_is_ready(), ac_win_set_config(), adc_abort_job(), adc_clear_status(), adc_disable(), adc_disable_callback(), adc_disable_events(), adc_disable_interrupt(), adc_disable_positive_input_sequence(), adc_enable(), adc_enable_callback(), adc_enable_events(), adc_enable_interrupt(), adc_enable_positive_input_sequence(), adc_flush(), adc_get_config_defaults(), adc_get_job_status(), adc_get_sequence_status(), adc_get_status(), adc_init(), adc_read(), adc_read_buffer_job(), adc_register_callback(), adc_reset(), adc_set_master_slave_mode(), adc_set_negative_input(), adc_set_positive_input(), adc_set_window_mode(), adc_start_conversion(), adc_unregister_callback(), aes_clear_new_message(), aes_clear_status(), aes_disable(), aes_disable_callback(), aes_enable(), aes_enable_callback(), aes_gcm_clear_end_message_status(), aes_gcm_read_cipher_len(), aes_gcm_read_ghash(), aes_gcm_read_hash_key(), aes_gcm_set_end_message_status(), aes_gcm_set_gf_multiplication(), aes_gcm_write_cipher_len(), aes_gcm_write_ghash(), aes_gcm_write_hash_key(), aes_get_config_defaults(), aes_get_status(), aes_init(), aes_read_output_data(), aes_register_callback(), aes_set_config(), aes_set_new_message(), aes_start(), aes_unregister_callback(), aes_write_init_vector(), aes_write_input_data(), aes_write_key(), aes_write_random_seed(), arch_ioport_set_port_sense_mode(), beacon_loss_timer_cb(), bod12_get_config_defaults(), bod12_set_config(), bod33_get_config_defaults(), bod33_set_config(), ccl_get_config_defaults(), ccl_lut_get_config_defaults(), ccl_lut_set_config(), cpu_irq_leave_critical(), csma_backoff_calculation(), dac_chan_abort_job(), dac_chan_disable(), dac_chan_disable_callback(), dac_chan_enable(), dac_chan_enable_callback(), dac_chan_get_config_defaults(), dac_chan_get_job_status(), dac_chan_is_end_of_conversion(), dac_chan_set_config(), dac_chan_write(), dac_chan_write_buffer_job(), dac_chan_write_buffer_wait(), dac_chan_write_job(), dac_clear_status(), dac_disable(), dac_disable_events(), dac_enable(), dac_enable_events(), dac_get_config_defaults(), dac_get_status(), dac_init(), dac_is_syncing(), dac_register_callback(), dac_reset(), dac_unregister_callback(), dispatch_event(), dma_abort_job(), dma_allocate(), dma_crc_get_config_defaults(), dma_descriptor_get_config_defaults(), dma_disable_callback(), dma_enable_callback(), dma_free(), dma_get_config_defaults(), dma_get_job_status(), dma_is_busy(), dma_register_callback(), dma_reset_descriptor(), dma_resume_job(), dma_start_transfer_job(), dma_suspend_job(), dma_trigger_transfer(), dma_unregister_callback(), dma_update_descriptor(), DMAC_Handler(), events_ack_interrupt(), events_allocate(), events_attach_user(), events_detach_user(), events_disable_interrupt_source(), events_enable_interrupt_source(), events_get_config_defaults(), events_is_busy(), events_is_detected(), events_is_interrupt_set(), events_is_overrun(), events_is_users_ready(), events_release(), events_trigger(), extint_chan_disable_callback(), extint_chan_enable_callback(), extint_chan_get_config_defaults(), extint_chan_set_config(), extint_disable_events(), extint_enable_events(), extint_nmi_get_config_defaults(), extint_nmi_set_config(), extint_register_callback(), extint_unregister_callback(), gfx_mono_draw_char(), gfx_mono_draw_char_hugemem(), gfx_mono_draw_char_progmem(), gfx_mono_draw_progmem_string(), gfx_mono_draw_string(), gfx_mono_get_progmem_string_bounding_box(), gfx_mono_get_string_bounding_box(), handle_incoming_msg(), handle_received_frame_irq(), handle_tx_end_irq(), i2c_master_cancel_job(), i2c_master_disable(), i2c_master_disable_callback(), i2c_master_enable(), i2c_master_enable_callback(), i2c_master_get_config_defaults(), i2c_master_get_job_status(), i2c_master_init(), i2c_master_is_syncing(), i2c_master_read_bytes(), i2c_master_read_packet_job(), i2c_master_read_packet_job_no_nack(), i2c_master_read_packet_job_no_stop(), i2c_master_read_packet_wait(), i2c_master_read_packet_wait_no_nack(), i2c_master_read_packet_wait_no_stop(), i2c_master_register_callback(), i2c_master_reset(), i2c_master_send_nack(), i2c_master_send_stop(), i2c_master_unregister_callback(), i2c_master_write_bytes(), i2c_master_write_packet_job(), i2c_master_write_packet_job_no_stop(), i2c_master_write_packet_wait(), i2c_master_write_packet_wait_no_stop(), i2c_slave_cancel_job(), i2c_slave_clear_status(), i2c_slave_disable(), i2c_slave_disable_callback(), i2c_slave_disable_nack_on_address(), i2c_slave_enable(), i2c_slave_enable_callback(), i2c_slave_enable_nack_on_address(), i2c_slave_get_config_defaults(), i2c_slave_get_direction_wait(), i2c_slave_get_job_status(), i2c_slave_get_status(), i2c_slave_init(), i2c_slave_is_syncing(), i2c_slave_read_packet_job(), i2c_slave_read_packet_wait(), i2c_slave_register_callback(), i2c_slave_reset(), i2c_slave_unregister_callback(), i2c_slave_write_packet_job(), i2c_slave_write_packet_wait(), init_xosc32k_fail_detector(), iso7816_data_block_atr(), iso7816_init(), iso7816_xfr_block_tpdu_t0(), mac_coord_realignment_command_tx_success(), mac_idle_trans(), mac_process_tal_data_ind(), mac_process_tal_tx_status(), mac_send_gts_ind(), mac_tx_gts_data(), nvm_get_config_defaults(), nvm_get_parameters(), nvm_is_page_locked(), nvm_set_config(), opamp0_get_config_defaults(), opamp1_get_config_defaults(), opamp2_get_config_defaults(), opamp_disable(), opamp_enable(), opamp_is_ready(), parse_mpdu(), pds_compact_sector(), pds_delete(), pds_delete_all(), pds_init(), pds_item_exist(), pds_list_item(), pds_nvm_init(), pds_nvm_read(), pds_read(), pds_write(), perform_cca_twice(), platform_process_rxdata(), port_disable_input_event(), port_enable_input_event(), port_get_config_defaults(), port_group_get_input_level(), port_group_get_output_level(), port_group_set_config(), port_group_set_output_level(), port_group_toggle_output_level(), port_input_event_get_config_defaults(), port_input_event_set_config(), port_pin_set_config(), process_data_ind_not_transient(), rtc_calendar_clear_alarm_match(), rtc_calendar_clear_overflow(), rtc_calendar_clear_periodic_interval(), rtc_calendar_disable(), rtc_calendar_disable_callback(), rtc_calendar_disable_events(), rtc_calendar_enable(), rtc_calendar_enable_callback(), rtc_calendar_enable_events(), rtc_calendar_frequency_correction(), rtc_calendar_get_alarm(), rtc_calendar_get_config_defaults(), rtc_calendar_get_time(), rtc_calendar_init(), rtc_calendar_is_alarm_match(), rtc_calendar_is_overflow(), rtc_calendar_is_periodic_interval(), rtc_calendar_is_syncing(), rtc_calendar_reset(), rtc_calendar_set_alarm(), rtc_calendar_set_time(), rtc_calendar_swap_time_mode(), rtc_count_clear_compare_match(), rtc_count_clear_overflow(), rtc_count_clear_periodic_interval(), rtc_count_disable(), rtc_count_disable_callback(), rtc_count_disable_events(), rtc_count_enable(), rtc_count_enable_callback(), rtc_count_enable_events(), rtc_count_frequency_correction(), rtc_count_get_compare(), rtc_count_get_config_defaults(), rtc_count_get_count(), rtc_count_get_period(), rtc_count_init(), rtc_count_is_compare_match(), rtc_count_is_overflow(), rtc_count_is_periodic_interval(), rtc_count_is_syncing(), rtc_count_reset(), rtc_count_set_compare(), rtc_count_set_count(), rtc_count_set_period(), rtc_read_general_purpose_reg(), rtc_tamper_clear_detect_flag(), rtc_tamper_get_config_defaults(), rtc_tamper_get_detect_flag(), rtc_write_general_purpose_reg(), sd_mmc_select_slot(), sd_mmc_start_read_blocks(), sd_mmc_start_write_blocks(), ser_fifo_init(), set_trx_state(), sleepmgr_get_sleep_mode(), sleepmgr_sleep(), slotted_csma_state_handling(), spi_attach_slave(), spi_disable(), spi_disable_callback(), spi_enable(), spi_enable_callback(), spi_get_config_defaults(), spi_init(), spi_is_ready_to_read(), spi_is_ready_to_write(), spi_is_syncing(), spi_is_write_complete(), spi_master_vec_disable(), spi_master_vec_enable(), spi_master_vec_init(), spi_master_vec_reset(), spi_master_vec_transceive_buffer_job(), spi_read(), spi_read_buffer_job(), spi_read_buffer_wait(), spi_register_callback(), spi_reset(), spi_select_slave(), spi_set_baudrate(), spi_slave_inst_get_config_defaults(), spi_transceive_buffer_job(), spi_transceive_buffer_wait(), spi_transceive_wait(), spi_unregister_callback(), spi_write(), spi_write_buffer_job(), spi_write_buffer_wait(), start_beacon_loss_timer(), sw_timer_disable(), sw_timer_disable_callback(), sw_timer_enable(), sw_timer_enable_callback(), sw_timer_get_config_defaults(), sw_timer_init(), sw_timer_register_callback(), sw_timer_task(), sw_timer_unregister_callback(), switch_pll_on(), system_apb_clock_clear_mask(), system_apb_clock_set_mask(), system_backup_pin_output_clear(), system_backup_pin_output_disable_rtc_toggle(), system_backup_pin_output_enable_rtc_toggle(), system_backup_pin_output_get(), system_backup_pin_output_set(), system_battery_backup_power_switch_get_config_defaults(), system_battery_backup_power_switch_set_config(), system_clock_init(), system_clock_source_dfll_get_config_defaults(), system_clock_source_disable(), system_clock_source_enable(), system_clock_source_osc16m_get_config_defaults(), system_clock_source_osc32k_get_config_defaults(), system_clock_source_osculp32k_get_config_defaults(), system_clock_source_write_calibration(), system_clock_source_xosc32k_get_config_defaults(), system_clock_source_xosc_get_config_defaults(), system_flash_set_waitstates(), system_gclk_chan_disable(), system_gclk_chan_get_config_defaults(), system_gclk_chan_set_config(), system_gclk_gen_get_config_defaults(), system_gclk_gen_set_config(), system_interrupt_clear_pending(), system_interrupt_is_pending(), system_interrupt_set_pending(), system_interrupt_set_priority(), system_peripheral_lock(), system_peripheral_lock_always(), system_peripheral_unlock(), system_pinmux_get_config_defaults(), system_pinmux_get_group_from_gpio_pin(), system_pinmux_group_set_config(), system_pinmux_group_set_input_sample_mode(), system_standby_get_config_defaults(), system_standby_set_config(), system_voltage_reference_disable(), system_voltage_reference_enable(), system_voltage_reference_get_config_defaults(), system_voltage_reference_set_config(), system_voltage_regulator_get_config_defaults(), system_voltage_regulator_set_config(), tal_pib_set(), tal_reset(), tal_rx_frame_cb(), tal_task(), tal_trx_wakeup(), tc_clear_status(), tc_disable(), tc_disable_callback(), tc_disable_events(), tc_dma_trigger_command(), tc_enable(), tc_enable_callback(), tc_enable_events(), tc_get_capture_value(), tc_get_config_defaults(), tc_get_count_value(), tc_get_status(), tc_init(), tc_is_syncing(), tc_register_callback(), tc_reset(), tc_set_compare_value(), tc_set_count_value(), tc_set_top_value(), tc_start_counter(), tc_stop_counter(), tc_sync_read_count(), tc_unregister_callback(), tc_update_double_buffer(), tcc_clear_status(), tcc_disable(), tcc_disable_callback(), tcc_disable_circular_buffer_compare(), tcc_disable_circular_buffer_top(), tcc_disable_double_buffering(), tcc_disable_events(), tcc_dma_trigger_command(), tcc_enable(), tcc_enable_callback(), tcc_enable_circular_buffer_compare(), tcc_enable_circular_buffer_top(), tcc_enable_double_buffering(), tcc_enable_events(), tcc_force_double_buffer_update(), tcc_get_capture_value(), tcc_get_count_value(), tcc_get_status(), tcc_init(), tcc_is_running(), tcc_is_syncing(), tcc_lock_double_buffer_update(), tcc_register_callback(), tcc_reset(), tcc_restart_counter(), tcc_set_compare_value(), tcc_set_count_direction(), tcc_set_count_value(), tcc_set_double_buffer_compare_values(), tcc_set_double_buffer_top_values(), tcc_set_pattern(), tcc_set_ramp_index(), tcc_set_top_value(), tcc_stop_counter(), tcc_toggle_count_direction(), tcc_unlock_double_buffer_update(), tcc_unregister_callback(), time_tick_init(), trng_abort_job(), trng_disable(), trng_disable_callback(), trng_disable_events(), trng_enable(), trng_enable_callback(), trng_enable_events(), trng_get_config_defaults(), trng_get_job_status(), trng_init(), trng_read(), trng_read_buffer_job(), trng_register_callback(), trng_unregister_callback(), trx_init(), trx_irq_awake_handler_cb(), trx_irq_handler_cb(), trx_reset(), tx_done(), tx_done_handling(), udi_cdc_comm_disable(), udi_cdc_data_disable(), udi_phdc_wait_metadata(), uhc_enumeration_step12(), uhc_enumeration_step13(), uhc_notify_connection(), uhc_request_bos_desc(), uhd_get_speed(), uhd_setup_request(), uhi_aoa_install(), uhi_cdc_install(), uhi_hid_mouse_install(), uhi_hid_mouse_uninstall(), uhi_msc_cbw_sent(), uhi_msc_enable(), uhi_msc_enable_step2(), uhi_vendor_install(), usart_abort_job(), usart_disable(), usart_disable_callback(), usart_disable_transceiver(), usart_enable(), usart_enable_callback(), usart_enable_transceiver(), usart_get_config_defaults(), usart_get_job_status(), usart_init(), usart_is_syncing(), usart_read_buffer_job(), usart_read_buffer_wait(), usart_read_job(), usart_read_wait(), usart_register_callback(), usart_reset(), usart_unregister_callback(), usart_write_buffer_job(), usart_write_buffer_wait(), usart_write_job(), usart_write_wait(), usb_device_disable_callback(), usb_device_enable_callback(), usb_device_endpoint_disable_callback(), usb_device_endpoint_enable_callback(), usb_device_endpoint_get_config_defaults(), usb_device_endpoint_read_buffer_job(), usb_device_endpoint_register_callback(), usb_device_endpoint_set_config(), usb_device_endpoint_setup_buffer_job(), usb_device_endpoint_unregister_callback(), usb_device_endpoint_write_buffer_job(), usb_device_register_callback(), usb_device_unregister_callback(), usb_disable(), usb_enable(), usb_get_config_defaults(), usb_get_state_machine_status(), usb_host_disable_callback(), usb_host_disable_sof(), usb_host_enable(), usb_host_enable_callback(), usb_host_enable_sof(), usb_host_get_frame_number(), usb_host_get_speed(), usb_host_is_sof_enabled(), usb_host_pipe_abort_job(), usb_host_pipe_clear_toggle(), usb_host_pipe_disable_callback(), usb_host_pipe_enable_callback(), usb_host_pipe_freeze(), usb_host_pipe_get_config(), usb_host_pipe_get_config_defaults(), usb_host_pipe_is_frozen(), usb_host_pipe_lpm_job(), usb_host_pipe_read_job(), usb_host_pipe_register_callback(), usb_host_pipe_set_auto_zlp(), usb_host_pipe_set_config(), usb_host_pipe_set_toggle(), usb_host_pipe_setup_job(), usb_host_pipe_unfreeze(), usb_host_pipe_unregister_callback(), usb_host_pipe_write_job(), usb_host_register_callback(), usb_host_send_l1_resume(), usb_host_send_reset(), usb_host_send_resume(), usb_host_unregister_callback(), usb_init(), wdt_disable_callback(), wdt_enable_callback(), wdt_get_config_defaults(), wdt_register_callback(), wdt_set_config(), and wdt_unregister_callback().