Atmel Software Framework

suite.h File Reference

Test suite core declarations.

Copyright (c) 2011-2014 Atmel Corporation. All rights reserved.

#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 NULL
Definition: lwip-1.4.0/src/include/lwip/def.h:47
#define test_assert_true(test, condition,...)
Verify that condition is true.
Definition: suite.h:393
#define dbg_error(_x,...)
Definition: suite.h:226
while(put_bits >=8)
Definition: jchuff.c:321
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
static struct test_case * test_get_case(void)
Get pointer to current test.
Definition: suite.h:335

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 adc_check_eoc(), adc_check_ovr(), adc_configure(), adc_disable(), adc_enable(), adc_get_latest_value(), adc_get_status(), adc_get_value(), adc_start(), calendar_add_second_to_date(), dip204_read_byte(), dip204_unselect(), dip204_write_byte(), et024006_CopyPixelsFromScreen(), et024006_CopyPixelsToScreen(), et024006_DrawFilledRect(), et024006_DrawLine(), et024006_DrawPixel(), et024006_DrawQuickPixel(), et024006_DuplicatePixel(), et024006_GetPixel(), et024006_GetPixmap(), et024006_PutBitmap(), et024006_PutPixmap(), et024006_Scroll(), fifo_init(), flashc_memcpy(), genclk_config_set_divider(), genclk_config_set_source(), genclk_enable_source(), gfx_draw_char(), gfx_draw_char_hugemem(), gfx_draw_char_progmem(), gfx_draw_progmem_string_aligned(), gfx_draw_string_aligned(), gfx_generic_draw_bitmap_tiled(), gfx_generic_get_pixmap(), gfx_generic_put_bitmap(), gfx_generic_put_pixmap(), gfx_get_progmem_string_bounding_box(), gfx_get_string_bounding_box(), ili9341_copy_pixels_from_screen(), ili9341_copy_pixels_to_screen(), ili9341_duplicate_pixel(), ili9341_write_gram(), main(), membag_init(), 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(), rtouch_adc_int_handler(), rtouch_detect_int_handler(), rtouch_resample(), sd_mmc_select_slot(), sd_mmc_start_read_blocks(), sd_mmc_start_write_blocks(), sleepmgr_get_sleep_mode(), sleepmgr_lock_mode(), sleepmgr_sleep(), sleepmgr_unlock_mode(), spi_set_bits_per_transfer(), spi_set_chipselect_delay_bct(), spi_set_chipselect_delay_bs(), sysclk_disable_peripheral_clock(), sysclk_enable_peripheral_clock(), sysclk_get_peripheral_bus_hz(), sysclk_init(), sysclk_set_prescalers(), sysclk_set_source(), timer_init(), timer_sched_timeout(), timer_sched_timeout_cb(), udd_ctrl_in_sent(), udi_cdc_comm_disable(), udi_cdc_data_disable(), udi_dfu_atmel_erase_chip(), udi_dfu_atmel_mem_getaddr(), udi_dfu_atmel_mem_read(), udi_dfu_atmel_mem_write(), udi_dfu_atmel_select_memory(), udi_dfu_atmel_setup(), udi_dfu_atmel_start(), udi_phdc_wait_metadata(), uhc_enumeration_step12(), uhc_enumeration_step13(), uhc_notify_connection(), uhd_ctrl_interrupt(), uhd_ctrl_phase_setup(), uhd_ep_alloc(), uhd_get_speed(), uhd_interrupt(), uhd_pipe_interrupt(), 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(), win_create(), win_destroy(), win_get_area(), win_get_attributes(), win_hide(), win_inflate_area(), win_lower(), win_process_command_event(), win_process_events(), win_raise(), win_reparent(), win_set_area(), win_set_attributes(), win_show(), win_translate_win_to_root(), wtk_basic_frame_as_child(), wtk_basic_frame_create(), wtk_basic_frame_get_custom_data(), wtk_button_as_child(), wtk_button_create(), wtk_button_get_command(), wtk_button_handler(), wtk_button_size_hint(), wtk_check_box_as_child(), wtk_check_box_create(), wtk_check_box_get_command(), wtk_check_box_handler(), wtk_check_box_is_selected(), wtk_check_box_set(), wtk_check_box_size_hint(), wtk_check_box_toggle(), wtk_copy_string(), wtk_frame_as_child(), wtk_frame_as_parent(), wtk_frame_create(), wtk_frame_get_custom_data(), wtk_icon_button_as_child(), wtk_icon_button_create(), wtk_icon_button_get_command(), wtk_icon_button_handler(), wtk_icon_button_is_selected(), wtk_icon_button_select(), wtk_icon_button_size_hint(), wtk_icon_group_get_selected(), wtk_label_as_child(), wtk_label_change(), wtk_label_create(), wtk_label_handler(), wtk_label_size_hint(), wtk_plot_add_value(), wtk_plot_as_child(), wtk_plot_create(), wtk_plot_handler(), wtk_plot_set_colors(), wtk_plot_set_grid(), wtk_progress_bar_as_child(), wtk_progress_bar_create(), wtk_progress_bar_get_value(), wtk_progress_bar_handler(), wtk_progress_bar_set_colors(), wtk_progress_bar_set_value(), wtk_radio_button_as_child(), wtk_radio_button_create(), wtk_radio_button_get_command(), wtk_radio_button_handler(), wtk_radio_button_is_selected(), wtk_radio_button_select(), wtk_radio_button_size_hint(), wtk_radio_group_get_selected(), wtk_rescale_value(), wtk_slider_as_child(), wtk_slider_create(), wtk_slider_get_command(), wtk_slider_get_value(), wtk_slider_handler(), wtk_slider_is_moving(), and wtk_slider_set_value().