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); \
} \
} \
}
#define test_assert_true(test, condition,...)
Verify that condition is true.
Definition: suite.h:386
#define dbg_error(_x,...)
Definition: suite.h:219
#define NULL
Definition: src/include/lwip/def.h:47
static struct test_case * test_get_case(void)
Get pointer to current test.
Definition: suite.h:328
if(memp!=NULL)
Definition: src/core/memp.c:407

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(), _iis_set_config(), abdac_get_config_defaults(), abdac_init(), ABDACB_Handler(), ac_ch_get_config_defaults(), ac_ch_set_config(), ac_disable_interrupt(), ac_enable_interrupt(), ac_get_config_defaults(), ac_init(), ac_win_get_config_defaults(), ac_win_set_config(), ack_timout_cb(), ack_transmission_done(), adc_ch_get_config_defaults(), adc_get_config_defaults(), adc_init(), adc_pdca_get_config_defaults(), aes_get_config_defaults(), aes_init(), AESA_Handler(), beacon_loss_timer_cb(), c42364a_show_numeric_dec(), c42412a_show_numeric_dec(), cancel_any_reception(), cca_start(), continue_deferred_transmission(), cpu_irq_leave_critical(), csma_backoff_calculation(), dfll_enable_config_defaults(), dfll_enable_source(), dispatch_event(), eic_line_interrupt(), events_ch_configure(), events_ch_get_config_defaults(), events_get_config_defaults(), events_init(), fifo_init(), flashcalw_memcpy(), freqm_get_config_defaults(), freqm_init(), genclk_config_set_divider(), genclk_enable_source(), gloc_init(), gloc_lut_get_config_defaults(), gpio_common_handler(), handle_incoming_msg(), handle_received_frame_irq(), handle_tx_end_irq(), hmatrix_master_ch_get_config_defaults(), hmatrix_slave_ch_get_config_defaults(), hx8347a_get_pixel(), hx8347a_set_window(), iis_clear_status(), iis_disable_interrupt(), iis_enable_interrupt(), iis_get_config_defaults(), iis_init(), iis_read(), iis_set_callback(), iis_write(), ili9325_copy_pixels_to_screen(), ili9325_copy_raw_pixel_24bits_to_screen(), ili9325_duplicate_pixel(), ili9325_get_pixel(), ili9325_set_window(), ili9325_write_gram(), ili93xx_copy_pixels_to_screen(), ili93xx_copy_raw_pixel_24bits_to_screen(), ili93xx_duplicate_pixel(), ili93xx_get_pixel(), ili93xx_set_window(), lcdca_automated_char_set_config(), lcdca_automated_char_start(), lcdca_blink_set_config(), lcdca_clear_blink_pixel(), lcdca_set_blink_pixel(), lcdca_set_config(), 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(), main(), membag_init(), parc_clear_status(), parc_disable(), parc_disable_callback(), parc_disable_interrupts(), parc_enable(), parc_enable_callback(), parc_enable_interrupts(), parc_get_config_defaults(), parc_read(), parc_register_callback(), parc_set_config(), parc_start_capture(), parc_stop_capture(), parc_unregister_callback(), parse_mpdu(), pdca_channel_interrupt(), perform_cca_twice(), pll_config_clear_option(), pll_config_init(), pll_config_read(), pll_config_set_option(), pll_config_write(), pll_disable(), pll_enable(), pll_enable_config_defaults(), pll_enable_source(), pll_is_locked(), pll_wait_for_lock(), process_data_ind_not_transient(), sd_mmc_select_slot(), sd_mmc_start_read_blocks(), sd_mmc_start_write_blocks(), set_trx_state(), sleepmgr_get_sleep_mode(), sleepmgr_sleep(), slotted_csma_state_handling(), spi_master_setup_device(), start_ack_wait_timer(), start_beacon_loss_timer(), switch_pll_on(), sysclk_disable_peripheral_clock(), sysclk_enable_peripheral_clock(), sysclk_get_peripheral_bus_hz(), sysclk_init(), sysclk_set_prescalers(), sysclk_set_source(), tal_pib_get(), tal_pib_set(), tal_reset(), tal_rx_enable(), tal_rx_frame_cb(), tal_task(), tal_trx_sleep(), tal_trx_wakeup(), tal_tx_frame(), tc_disable_interrupt(), tc_disable_qdec_interrupt(), tc_enable_interrupt(), tc_enable_qdec_interrupt(), tc_get_feature(), tc_get_interrupt_mask(), tc_get_qdec_interrupt_mask(), tc_get_qdec_interrupt_status(), tc_get_status(), tc_get_version(), tc_init(), tc_init_2bit_gray(), tc_read_cv(), tc_read_ra(), tc_read_rb(), tc_read_rc(), tc_set_block_mode(), tc_set_writeprotect(), tc_start(), tc_stop(), tc_sync_trigger(), tc_write_ra(), tc_write_rb(), tc_write_rc(), time_tick_init(), trx_init(), trx_irq_awake_handler_cb(), trx_irq_handler_cb(), trx_reset(), twis_clear_status(), twis_disable(), twis_disable_interrupt(), twis_enable(), twis_enable_interrupt(), twis_get_config_defaults(), twis_get_interrupt_mask(), twis_get_smbus_pec(), twis_get_smbus_transfer_nb(), twis_get_status(), twis_init(), twis_read(), twis_send_data_ack(), twis_send_data_nack(), twis_set_callback(), twis_set_smbus_transfer_nb(), twis_write(), tx_done(), tx_done_handling(), udd_ctrl_in_sent(), udi_cdc_comm_disable(), udi_cdc_data_disable(), udi_phdc_wait_metadata(), uhc_enumeration_step12(), uhc_enumeration_step13(), uhc_notify_connection(), uhd_ctrl_interrupt(), uhd_ctrl_request_end(), uhd_get_speed(), uhd_interrupt(), uhd_pipe_interrupt(), uhd_pipe_trans_complet(), 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(), upload_frame(), wdt_get_config_defaults(), and wdt_init().