From c082a87062ebb9414ec223e9bf7ea8959a717488 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 13:01:54 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6694 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/nil/NIL-STM32F303-DISCOVERY/.project | 5 + demos/nil/NIL-STM32F303-DISCOVERY/Makefile | 2 +- test/lib/templates/test_sequence_XXX.c | 2 +- test/nil/test.mk | 6 +- test/nil/test_root.h | 2 + test/nil/test_sequence_000.c | 122 +++++++++++++++++---- 6 files changed, 111 insertions(+), 28 deletions(-) diff --git a/demos/nil/NIL-STM32F303-DISCOVERY/.project b/demos/nil/NIL-STM32F303-DISCOVERY/.project index 637b2d362..08a691543 100644 --- a/demos/nil/NIL-STM32F303-DISCOVERY/.project +++ b/demos/nil/NIL-STM32F303-DISCOVERY/.project @@ -86,5 +86,10 @@ 2 CHIBIOS/os + + test + 2 + CHIBIOS/test + diff --git a/demos/nil/NIL-STM32F303-DISCOVERY/Makefile b/demos/nil/NIL-STM32F303-DISCOVERY/Makefile index 0a93433bc..5a95ab821 100644 --- a/demos/nil/NIL-STM32F303-DISCOVERY/Makefile +++ b/demos/nil/NIL-STM32F303-DISCOVERY/Makefile @@ -82,7 +82,7 @@ include $(CHIBIOS)/os/hal/ports/STM32/STM32F30x/platform.mk include $(CHIBIOS)/os/hal/osal/nil/osal.mk include $(CHIBIOS)/os/nil/nil.mk include $(CHIBIOS)/os/nil/ports/ARMCMx/compilers/GCC/mk/port_stm32f30x.mk -#include $(CHIBIOS)/test/test.mk +include $(CHIBIOS)/test/nil/test.mk # Define linker script file here LDSCRIPT = $(PORTLD)/STM32F303xC.ld diff --git a/test/lib/templates/test_sequence_XXX.c b/test/lib/templates/test_sequence_XXX.c index 3fb1df8e0..2d46efac8 100644 --- a/test/lib/templates/test_sequence_XXX.c +++ b/test/lib/templates/test_sequence_XXX.c @@ -80,7 +80,7 @@ static const testcase_t test_XXX_000 = { test_XXX_000_teardown, test_XXX_000_execute }; - #endif /* TEST_XXX_000_CONDITION */ +#endif /* TEST_XXX_000_CONDITION */ /**************************************************************************** * Exported data. 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}_teardown(void) { - -} - static void test_000_000_execute(void) { + systime_t time; - /* Step description.*/ + /* 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 const testcase_t test_000_000 = { "Brief description", - test_000_000_setup, - test_000_000_teardown, + NULL, + NULL, test_000_000_execute }; - #endif /* TEST_000_000_CONDITION */ +#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_001_execute(void) { + systime_t time; + + /* 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_001 = { + "Brief description", + NULL, + NULL, + test_000_001_execute +}; +#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 };