From c082a87062ebb9414ec223e9bf7ea8959a717488 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 13:01:54 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6694 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nil/test.mk | 6 +-- test/nil/test_root.h | 2 + test/nil/test_sequence_000.c | 118 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 102 insertions(+), 24 deletions(-) (limited to 'test/nil') diff --git a/test/nil/test.mk b/test/nil/test.mk index 6abe29dfe..a69e80e08 100644 --- a/test/nil/test.mk +++ b/test/nil/test.mk @@ -1,8 +1,8 @@ # List of all the ChibiOS/RT test files. TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ - ${CHIBIOS}/test/rt/test_root.c \ - ${CHIBIOS}/test/rt/test_sequence_000.c + ${CHIBIOS}/test/nil/test_root.c \ + ${CHIBIOS}/test/nil/test_sequence_000.c # Required include directories TESTINC = ${CHIBIOS}/test/lib \ - ${CHIBIOS}/test/rt + ${CHIBIOS}/test/nil diff --git a/test/nil/test_root.h b/test/nil/test_root.h index fb6fea873..42463fc03 100644 --- a/test/nil/test_root.h +++ b/test/nil/test_root.h @@ -25,6 +25,8 @@ #ifndef _TEST_ROOT_H_ #define _TEST_ROOT_H_ +#include "nil.h" + #include "test_sequence_000.h" /*===========================================================================*/ diff --git a/test/nil/test_sequence_000.c b/test/nil/test_sequence_000.c index efe81b6da..7b56a3908 100644 --- a/test/nil/test_sequence_000.c +++ b/test/nil/test_sequence_000.c @@ -19,12 +19,12 @@ #include "test_root.h" /** - * @page test_sequence_000 Sequence brief description + * @page test_sequence_000 Threads Functionality * * File: @ref test_sequence_000.c * *

Description

- * Sequence detailed description. + * This sequence tests the ChibiOS/Nil functionalities related to threading. * *

Test Cases

* - @subpage test_000_000 @@ -40,47 +40,120 @@ * Test cases. ****************************************************************************/ -#if TEST_000_000_CONDITION || defined(__DOXYGEN__) +#if TRUE || defined(__DOXYGEN__) /** - * @page test_000_000 Brief description + * @page test_000_000 System Tick Counter functionality * *

Description

- * Detailed description. + * The functionality of the API @p chVTGetSystemTimeX() is tested. * *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - TEST_000_000_CONDITION - * . + * None. * *

Test Steps

- * - Step description. + * - A System Tick Counter increment is expected, the test simply hangs if + * it does not happen. * . */ -static void test_000_000_setup(void) { +static void test_000_000_execute(void) { + systime_t time; + /* A System Tick Counter increment is expected, the test simply hangs if + it does not happen.*/ + test_set_step(1); + { + time = chVTGetSystemTimeX(); + while (time == chVTGetSystemTimeX()) { + } + } } -static void test_000_000}_teardown(void) { +static const testcase_t test_000_000 = { + "Brief description", + NULL, + NULL, + test_000_000_execute +}; +#endif /* TEST_000_000_CONDITION */ -} +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_000_001 Thread Sleep functionality + * + *

Description

+ * The functionality of the API @p chThdSleep() and derivatives is tested. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - The current system time is read then a sleep is performed for 100 system + * ticks and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 100000 + * microseconds and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 100 + * milliseconds and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 1 + * second and on exit the system time is verified again. + * . + */ -static void test_000_000_execute(void) { +static void test_000_001_execute(void) { + systime_t time; - /* Step description.*/ + /* The current system time is read then a sleep is performed for 100 system + ticks and on exit the system time is verified again.*/ test_set_step(1); { + time = chVTGetSystemTimeX(); + chThdSleep(100); + test_assert_time_window(time + 100, + time + 101, + "out of time window"); + } + + /* The current system time is read then a sleep is performed for 100000 + microseconds and on exit the system time is verified again.*/ + test_set_step(2); + { + time = chVTGetSystemTimeX(); + chThdSleepMicroseconds(100); + test_assert_time_window(time + US2ST(100), + time + US2ST(100) + 1, + "out of time window"); + } + + /* The current system time is read then a sleep is performed for 100 + milliseconds and on exit the system time is verified again.*/ + test_set_step(3); + { + time = chVTGetSystemTimeX(); + chThdSleepMicroseconds(100); + test_assert_time_window(time + MS2ST(100), + time + MS2ST(100) + 1, + "out of time window"); + } + + /* The current system time is read then a sleep is performed for 1 + second and on exit the system time is verified again.*/ + test_set_step(4); + { + time = chVTGetSystemTimeX(); + chThdSleepSeconds(1); + test_assert_time_window(time + S2ST(1), + time + S2ST(1) + 1, + "out of time window"); } } -static const testcase_t test_000_000 = { +static const testcase_t test_000_001 = { "Brief description", - test_000_000_setup, - test_000_000_teardown, - test_000_000_execute + NULL, + NULL, + test_000_001_execute }; - #endif /* TEST_000_000_CONDITION */ +#endif /* TEST_000_001_CONDITION */ /**************************************************************************** * Exported data. @@ -90,8 +163,11 @@ static const testcase_t test_000_000 = { * @brief Sequence brief description. */ const testcase_t * const test_sequence_000[] = { -#if TEST_000_000_CONDITION || defined(__DOXYGEN__) +#if 1 || defined(__DOXYGEN__) &test_000_000, +#endif +#if 1 || defined(__DOXYGEN__) + &test_000_001, #endif NULL }; -- cgit v1.2.3