NIL test suite updated.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10864 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2017-10-19 09:16:38 +00:00
parent 59d34439eb
commit 0e3a108a64
31 changed files with 334 additions and 2254 deletions

View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?>
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.665946016">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.665946016" moduleId="org.eclipse.cdt.core.settings" name="Default">

View File

@ -93,7 +93,9 @@ include $(CHIBIOS)/os/hal/osal/nil/osal.mk
include $(CHIBIOS)/os/nil/nil.mk
include $(CHIBIOS)/os/common/ports/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/nil/test.mk
include $(CHIBIOS)/test/lib/test.mk
include $(CHIBIOS)/test/nil/nil_test.mk
include $(CHIBIOS)/test/oslib/oslib_test.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/SPC560D40.ld

View File

@ -17,6 +17,7 @@
#include "ch.h"
#include "hal.h"
#include "nil_test_root.h"
#include "oslib_test_root.h"
/*
* LEDs blinker thread, times are in milliseconds.
@ -109,8 +110,10 @@ THD_FUNCTION(Thread2, arg) {
/* Waiting for button push and activation of the test suite.*/
while (true) {
if (palReadPad(PORT_E, PE_BUTTON1))
test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
if (palReadPad(PORT_E, PE_BUTTON1)) {
test_execute((BaseSequentialStream *)&SD1, &nil_test_suite);
test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
}
chThdSleepMilliseconds(500);
}
}

View File

@ -98,7 +98,9 @@ include $(CHIBIOS)/os/hal/osal/nil/osal.mk
include $(CHIBIOS)/os/nil/nil.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk
# Other files (optional).
include $(CHIBIOS)/test/nil/test.mk
include $(CHIBIOS)/test/lib/test.mk
include $(CHIBIOS)/test/nil/nil_test.mk
include $(CHIBIOS)/test/oslib/oslib_test.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F051x8.ld

View File

@ -17,6 +17,7 @@
#include "hal.h"
#include "ch.h"
#include "nil_test_root.h"
#include "oslib_test_root.h"
/*
* Thread 1.
@ -71,8 +72,10 @@ THD_FUNCTION(Thread3, arg) {
/* Waiting for button push and activation of the test suite.*/
while (true) {
if (palReadLine(LINE_BUTTON))
test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
if (palReadLine(LINE_BUTTON)) {
test_execute((BaseSequentialStream *)&SD1, &nil_test_suite);
test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
}
chThdSleepMilliseconds(500);
}
}

View File

@ -98,7 +98,9 @@ include $(CHIBIOS)/os/hal/osal/nil/osal.mk
include $(CHIBIOS)/os/nil/nil.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/nil/test.mk
include $(CHIBIOS)/test/lib/test.mk
include $(CHIBIOS)/test/nil/nil_test.mk
include $(CHIBIOS)/test/oslib/oslib_test.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F303xC.ld

View File

@ -17,6 +17,7 @@
#include "hal.h"
#include "ch.h"
#include "nil_test_root.h"
#include "oslib_test_root.h"
/*
* Blinker thread #1.
@ -95,8 +96,10 @@ THD_FUNCTION(Thread3, arg) {
/* Waiting for button push and activation of the test suite.*/
while (true) {
if (palReadLine(LINE_BUTTON))
test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
if (palReadLine(LINE_BUTTON)) {
test_execute((BaseSequentialStream *)&SD1, &nil_test_suite);
test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
}
chThdSleepMilliseconds(500);
}
}

View File

@ -98,7 +98,9 @@ include $(CHIBIOS)/os/hal/osal/nil/osal.mk
include $(CHIBIOS)/os/nil/nil.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/nil/test.mk
include $(CHIBIOS)/test/lib/test.mk
include $(CHIBIOS)/test/nil/nil_test.mk
include $(CHIBIOS)/test/oslib/oslib_test.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F746xG.ld

View File

@ -1,52 +1,52 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
<stringAttribute key="bad_container_name" value="\NIL-STM32F746G-DISCOVERY\debug"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="1"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;r0-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r1-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList/&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="NIL-STM32F746G-DISCOVERY"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="0.1984968159"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/NIL-STM32F746G-DISCOVERY"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
<stringAttribute key="bad_container_name" value="\NIL-STM32F746G-DISCOVERY\debug"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="1"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;r1-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r0-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="NIL-STM32F746G-DISCOVERY"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="0.1984968159"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/NIL-STM32F746G-DISCOVERY"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
</launchConfiguration>

View File

@ -17,6 +17,7 @@
#include "hal.h"
#include "ch.h"
#include "nil_test_root.h"
#include "oslib_test_root.h"
/*
* Blinker thread #1.
@ -58,8 +59,10 @@ THD_FUNCTION(Thread2, arg) {
/* Waiting for button push and activation of the test suite.*/
while (true) {
if (palReadLine(LINE_BUTTON_USER))
test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
if (palReadLine(LINE_BUTTON_USER)) {
test_execute((BaseSequentialStream *)&SD1, &nil_test_suite);
test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
}
chThdSleepMilliseconds(500);
}
}

View File

@ -391,7 +391,7 @@
*
* @note The default is @p FALSE.
*/
#define CH_DBG_STATISTICS FALSE
#define CH_DBG_STATISTICS TRUE
/**
* @brief Debug option, system state check.
@ -400,7 +400,7 @@
*
* @note The default is @p FALSE.
*/
#define CH_DBG_SYSTEM_STATE_CHECK FALSE
#define CH_DBG_SYSTEM_STATE_CHECK TRUE
/**
* @brief Debug option, parameters checks.
@ -409,7 +409,7 @@
*
* @note The default is @p FALSE.
*/
#define CH_DBG_ENABLE_CHECKS FALSE
#define CH_DBG_ENABLE_CHECKS TRUE
/**
* @brief Debug option, consistency checks.
@ -419,7 +419,7 @@
*
* @note The default is @p FALSE.
*/
#define CH_DBG_ENABLE_ASSERTS FALSE
#define CH_DBG_ENABLE_ASSERTS TRUE
/**
* @brief Debug option, trace buffer.
@ -427,7 +427,7 @@
*
* @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
*/
#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_ALL
/**
* @brief Trace buffer entries.
@ -446,7 +446,7 @@
* @note The default failure mode is to halt the system with the global
* @p panic_msg variable set to @p NULL.
*/
#define CH_DBG_ENABLE_STACK_CHECK FALSE
#define CH_DBG_ENABLE_STACK_CHECK TRUE
/**
* @brief Debug option, stacks initialization.
@ -456,7 +456,7 @@
*
* @note The default is @p FALSE.
*/
#define CH_DBG_FILL_THREADS FALSE
#define CH_DBG_FILL_THREADS TRUE
/**
* @brief Debug option, threads profiling.

5
test/lib/test.mk Normal file
View File

@ -0,0 +1,5 @@
# List of all the test runtime files.
TESTSRC += ${CHIBIOS}/test/lib/ch_test.c
# Required include directories
TESTINC += ${CHIBIOS}/test/lib

File diff suppressed because it is too large Load Diff

9
test/nil/nil_test.mk Normal file
View File

@ -0,0 +1,9 @@
# List of all the ChibiOS/NIL test files.
TESTSRC += ${CHIBIOS}/test/nil/source/test/nil_test_root.c \
${CHIBIOS}/test/nil/source/test/nil_test_sequence_001.c \
${CHIBIOS}/test/nil/source/test/nil_test_sequence_002.c \
${CHIBIOS}/test/nil/source/test/nil_test_sequence_003.c \
${CHIBIOS}/test/nil/source/test/nil_test_sequence_004.c
# Required include directories
TESTINC += ${CHIBIOS}/test/nil/source/test

View File

@ -21,24 +21,20 @@
* through successive improvements.
*
* <h2>Test Sequences</h2>
* - @subpage test_sequence_001
* - @subpage test_sequence_002
* - @subpage test_sequence_003
* - @subpage test_sequence_004
* - @subpage test_sequence_005
* - @subpage test_sequence_006
* - @subpage test_sequence_007
* - @subpage nil_test_sequence_001
* - @subpage nil_test_sequence_002
* - @subpage nil_test_sequence_003
* - @subpage nil_test_sequence_004
* .
*/
/**
* @file test_root.c
* @file nil_test_root.c
* @brief Test Suite root structures code.
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
#include "nil_test_root.h"
#if !defined(__DOXYGEN__)
@ -47,27 +43,26 @@
/*===========================================================================*/
/**
* @brief Array of all the test sequences.
* @brief Array of test sequences.
*/
const testcase_t * const *test_suite[] = {
test_sequence_001,
test_sequence_002,
const testsequence_t * const nil_test_suite_array[] = {
&nil_test_sequence_001,
&nil_test_sequence_002,
#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
test_sequence_003,
#endif
test_sequence_004,
#if (CH_CFG_USE_MAILBOXES) || defined(__DOXYGEN__)
test_sequence_005,
#endif
#if (CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
test_sequence_006,
#endif
#if (CH_CFG_USE_HEAP) || defined(__DOXYGEN__)
test_sequence_007,
&nil_test_sequence_003,
#endif
&nil_test_sequence_004,
NULL
};
/**
* @brief Test suite root structure.
*/
const testsuite_t nil_test_suite = {
"Test Specification for ChibiOS/NIL.",
nil_test_suite_array
};
/*===========================================================================*/
/* Shared code. */
/*===========================================================================*/

View File

@ -15,20 +15,19 @@
*/
/**
* @file test_root.h
* @file nil_test_root.h
* @brief Test Suite root structures header.
*/
#ifndef TEST_ROOT_H
#define TEST_ROOT_H
#ifndef NIL_TEST_ROOT_H
#define NIL_TEST_ROOT_H
#include "test_sequence_001.h"
#include "test_sequence_002.h"
#include "test_sequence_003.h"
#include "test_sequence_004.h"
#include "test_sequence_005.h"
#include "test_sequence_006.h"
#include "test_sequence_007.h"
#include "ch_test.h"
#include "nil_test_sequence_001.h"
#include "nil_test_sequence_002.h"
#include "nil_test_sequence_003.h"
#include "nil_test_sequence_004.h"
#if !defined(__DOXYGEN__)
@ -36,7 +35,7 @@
/* External declarations. */
/*===========================================================================*/
extern const testcase_t * const *test_suite[];
extern const testsuite_t nil_test_suite;
#ifdef __cplusplus
extern "C" {
@ -62,4 +61,4 @@ THD_FUNCTION(test_support, arg);
#endif /* !defined(__DOXYGEN__) */
#endif /* TEST_ROOT_H */
#endif /* NIL_TEST_ROOT_H */

View File

@ -15,24 +15,23 @@
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
#include "nil_test_root.h"
/**
* @file test_sequence_001.c
* @file nil_test_sequence_001.c
* @brief Test Sequence 001 code.
*
* @page test_sequence_001 [1] Information
* @page nil_test_sequence_001 [1] Information
*
* File: @ref test_sequence_001.c
* File: @ref nil_test_sequence_001.c
*
* <h2>Description</h2>
* This sequence reports configuration and version information about
* the NIL kernel.
*
* <h2>Test Cases</h2>
* - @subpage test_001_001
* - @subpage test_001_002
* - @subpage nil_test_001_001
* - @subpage nil_test_001_002
* .
*/
@ -47,7 +46,7 @@
****************************************************************************/
/**
* @page test_001_001 [1.1] Kernel Info
* @page nil_test_001_001 [1.1] Kernel Info
*
* <h2>Description</h2>
* The version numbers are reported.
@ -57,7 +56,7 @@
* .
*/
static void test_001_001_execute(void) {
static void nil_test_001_001_execute(void) {
/* [1.1.1] Prints the version string.*/
test_set_step(1);
@ -80,15 +79,15 @@ static void test_001_001_execute(void) {
}
}
static const testcase_t test_001_001 = {
static const testcase_t nil_test_001_001 = {
"Kernel Info",
NULL,
NULL,
test_001_001_execute
nil_test_001_001_execute
};
/**
* @page test_001_002 [1.2] Kernel Settings
* @page nil_test_001_002 [1.2] Kernel Settings
*
* <h2>Description</h2>
* The static kernel settings are reported.
@ -98,7 +97,7 @@ static const testcase_t test_001_001 = {
* .
*/
static void test_001_002_execute(void) {
static void nil_test_001_002_execute(void) {
/* [1.2.1] Prints the configuration options settings.*/
test_set_step(1);
@ -154,11 +153,11 @@ static void test_001_002_execute(void) {
}
}
static const testcase_t test_001_002 = {
static const testcase_t nil_test_001_002 = {
"Kernel Settings",
NULL,
NULL,
test_001_002_execute
nil_test_001_002_execute
};
/****************************************************************************
@ -166,10 +165,18 @@ static const testcase_t test_001_002 = {
****************************************************************************/
/**
* @brief Information.
* @brief Array of test cases.
*/
const testcase_t * const test_sequence_001[] = {
&test_001_001,
&test_001_002,
const testcase_t * const nil_test_sequence_001_array[] = {
&nil_test_001_001,
&nil_test_001_002,
NULL
};
/**
* @brief Information.
*/
const testsequence_t nil_test_sequence_001 = {
NULL,
nil_test_sequence_001_array
};

View File

@ -15,13 +15,13 @@
*/
/**
* @file test_sequence_001.h
* @file nil_test_sequence_001.h
* @brief Test Sequence 001 header.
*/
#ifndef TEST_SEQUENCE_001_H
#define TEST_SEQUENCE_001_H
#ifndef NIL_TEST_SEQUENCE_001_H
#define NIL_TEST_SEQUENCE_001_H
extern const testcase_t * const test_sequence_001[];
extern const testsequence_t nil_test_sequence_001;
#endif /* TEST_SEQUENCE_001_H */
#endif /* NIL_TEST_SEQUENCE_001_H */

View File

@ -15,24 +15,23 @@
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
#include "nil_test_root.h"
/**
* @file test_sequence_002.c
* @file nil_test_sequence_002.c
* @brief Test Sequence 002 code.
*
* @page test_sequence_002 [2] Threads Functionality
* @page nil_test_sequence_002 [2] Threads Functionality
*
* File: @ref test_sequence_002.c
* File: @ref nil_test_sequence_002.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* threading.
*
* <h2>Test Cases</h2>
* - @subpage test_002_001
* - @subpage test_002_002
* - @subpage nil_test_002_001
* - @subpage nil_test_002_002
* .
*/
@ -47,7 +46,7 @@
****************************************************************************/
/**
* @page test_002_001 [2.1] System Tick Counter functionality
* @page nil_test_002_001 [2.1] System Tick Counter functionality
*
* <h2>Description</h2>
* The functionality of the API @p chVTGetSystemTimeX() is tested.
@ -58,7 +57,7 @@
* .
*/
static void test_002_001_execute(void) {
static void nil_test_002_001_execute(void) {
/* [2.1.1] A System Tick Counter increment is expected, the test
simply hangs if it does not happen.*/
@ -70,15 +69,15 @@ static void test_002_001_execute(void) {
}
}
static const testcase_t test_002_001 = {
static const testcase_t nil_test_002_001 = {
"System Tick Counter functionality",
NULL,
NULL,
test_002_001_execute
nil_test_002_001_execute
};
/**
* @page test_002_002 [2.2] Thread Sleep functionality
* @page nil_test_002_002 [2.2] Thread Sleep functionality
*
* <h2>Description</h2>
* The functionality of @p chThdSleep() and derivatives is tested.
@ -100,7 +99,7 @@ static const testcase_t test_002_001 = {
* .
*/
static void test_002_002_execute(void) {
static void nil_test_002_002_execute(void) {
systime_t time;
/* [2.2.1] The current system time is read then a sleep is performed
@ -110,8 +109,8 @@ static void test_002_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdSleep(100);
test_assert_time_window(time + 100,
time + 100 + 1,
test_assert_time_window(chTimeAddX(time, 100),
chTimeAddX(time, 100 + 1),
"out of time window");
}
@ -122,8 +121,8 @@ static void test_002_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdSleepMicroseconds(100000);
test_assert_time_window(time + US2ST(100000),
time + US2ST(100000) + 1,
test_assert_time_window(chTimeAddX(time, TIME_US2I(100000)),
chTimeAddX(time, TIME_US2I(100000) + 1),
"out of time window");
}
@ -134,8 +133,8 @@ static void test_002_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdSleepMilliseconds(100);
test_assert_time_window(time + MS2ST(100),
time + MS2ST(100) + 1,
test_assert_time_window(chTimeAddX(time, TIME_MS2I(100)),
chTimeAddX(time, TIME_MS2I(100) + 1),
"out of time window");
}
@ -145,8 +144,8 @@ static void test_002_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdSleepSeconds(1);
test_assert_time_window(time + S2ST(1),
time + S2ST(1) + 1,
test_assert_time_window(chTimeAddX(time, TIME_S2I(1)),
chTimeAddX(time, TIME_S2I(1) + 1),
"out of time window");
}
@ -155,18 +154,18 @@ static void test_002_002_execute(void) {
test_set_step(5);
{
time = chVTGetSystemTimeX();
chThdSleepUntil(time + 100);
test_assert_time_window(time + 100,
time + 100 + 1,
chThdSleepUntil(chTimeAddX(time, 100));
test_assert_time_window(chTimeAddX(time, 100),
chTimeAddX(time, 100 + 1),
"out of time window");
}
}
static const testcase_t test_002_002 = {
static const testcase_t nil_test_002_002 = {
"Thread Sleep functionality",
NULL,
NULL,
test_002_002_execute
nil_test_002_002_execute
};
/****************************************************************************
@ -174,10 +173,18 @@ static const testcase_t test_002_002 = {
****************************************************************************/
/**
* @brief Threads Functionality.
* @brief Array of test cases.
*/
const testcase_t * const test_sequence_002[] = {
&test_002_001,
&test_002_002,
const testcase_t * const nil_test_sequence_002_array[] = {
&nil_test_002_001,
&nil_test_002_002,
NULL
};
/**
* @brief Threads Functionality.
*/
const testsequence_t nil_test_sequence_002 = {
NULL,
nil_test_sequence_002_array
};

View File

@ -15,13 +15,13 @@
*/
/**
* @file test_sequence_002.h
* @file nil_test_sequence_002.h
* @brief Test Sequence 002 header.
*/
#ifndef TEST_SEQUENCE_002_H
#define TEST_SEQUENCE_002_H
#ifndef NIL_TEST_SEQUENCE_002_H
#define NIL_TEST_SEQUENCE_002_H
extern const testcase_t * const test_sequence_002[];
extern const testsequence_t nil_test_sequence_002;
#endif /* TEST_SEQUENCE_002_H */
#endif /* NIL_TEST_SEQUENCE_002_H */

View File

@ -15,16 +15,15 @@
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
#include "nil_test_root.h"
/**
* @file test_sequence_003.c
* @file nil_test_sequence_003.c
* @brief Test Sequence 003 code.
*
* @page test_sequence_003 [3] Semaphores
* @page nil_test_sequence_003 [3] Semaphores
*
* File: @ref test_sequence_003.c
* File: @ref nil_test_sequence_003.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
@ -37,9 +36,9 @@
* .
*
* <h2>Test Cases</h2>
* - @subpage test_003_001
* - @subpage test_003_002
* - @subpage test_003_003
* - @subpage nil_test_003_001
* - @subpage nil_test_003_002
* - @subpage nil_test_003_003
* .
*/
@ -58,7 +57,7 @@ static semaphore_t sem1;
****************************************************************************/
/**
* @page test_003_001 [3.1] Semaphore primitives, no state change
* @page nil_test_003_001 [3.1] Semaphore primitives, no state change
*
* <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread
@ -74,15 +73,15 @@ static semaphore_t sem1;
* .
*/
static void test_003_001_setup(void) {
static void nil_test_003_001_setup(void) {
chSemObjectInit(&sem1, 1);
}
static void test_003_001_teardown(void) {
static void nil_test_003_001_teardown(void) {
chSemReset(&sem1, 0);
}
static void test_003_001_execute(void) {
static void nil_test_003_001_execute(void) {
/* [3.1.1] The function chSemWait() is invoked, after return the
counter and the returned message are tested.*/
@ -112,15 +111,15 @@ static void test_003_001_execute(void) {
}
}
static const testcase_t test_003_001 = {
static const testcase_t nil_test_003_001 = {
"Semaphore primitives, no state change",
test_003_001_setup,
test_003_001_teardown,
test_003_001_execute
nil_test_003_001_setup,
nil_test_003_001_teardown,
nil_test_003_001_execute
};
/**
* @page test_003_002 [3.2] Semaphore primitives, with state change
* @page nil_test_003_002 [3.2] Semaphore primitives, with state change
*
* <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread
@ -136,15 +135,15 @@ static const testcase_t test_003_001 = {
* .
*/
static void test_003_002_setup(void) {
static void nil_test_003_002_setup(void) {
chSemObjectInit(&gsem1, 0);
}
static void test_003_002_teardown(void) {
static void nil_test_003_002_teardown(void) {
chSemReset(&gsem1, 0);
}
static void test_003_002_execute(void) {
static void nil_test_003_002_execute(void) {
/* [3.2.1] The function chSemWait() is invoked, after return the
counter and the returned message are tested. The semaphore is
@ -171,15 +170,15 @@ static void test_003_002_execute(void) {
}
}
static const testcase_t test_003_002 = {
static const testcase_t nil_test_003_002 = {
"Semaphore primitives, with state change",
test_003_002_setup,
test_003_002_teardown,
test_003_002_execute
nil_test_003_002_setup,
nil_test_003_002_teardown,
nil_test_003_002_execute
};
/**
* @page test_003_003 [3.3] Semaphores timeout
* @page nil_test_003_003 [3.3] Semaphores timeout
*
* <h2>Description</h2>
* Timeout on semaphores is tested.
@ -194,15 +193,15 @@ static const testcase_t test_003_002 = {
* .
*/
static void test_003_003_setup(void) {
static void nil_test_003_003_setup(void) {
chSemObjectInit(&sem1, 0);
}
static void test_003_003_teardown(void) {
static void nil_test_003_003_teardown(void) {
chSemReset(&sem1, 0);
}
static void test_003_003_execute(void) {
static void nil_test_003_003_execute(void) {
systime_t time;
msg_t msg;
@ -212,9 +211,9 @@ static void test_003_003_execute(void) {
test_set_step(1);
{
time = chVTGetSystemTimeX();
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
msg = chSemWaitTimeout(&sem1, TIME_MS2I(1000));
test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
@ -226,20 +225,20 @@ static void test_003_003_execute(void) {
test_set_step(2);
{
time = chVTGetSystemTimeX();
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
msg = chSemWaitTimeout(&sem1, TIME_MS2I(1000));
test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
}
}
static const testcase_t test_003_003 = {
static const testcase_t nil_test_003_003 = {
"Semaphores timeout",
test_003_003_setup,
test_003_003_teardown,
test_003_003_execute
nil_test_003_003_setup,
nil_test_003_003_teardown,
nil_test_003_003_execute
};
/****************************************************************************
@ -247,13 +246,21 @@ static const testcase_t test_003_003 = {
****************************************************************************/
/**
* @brief Semaphores.
* @brief Array of test cases.
*/
const testcase_t * const test_sequence_003[] = {
&test_003_001,
&test_003_002,
&test_003_003,
const testcase_t * const nil_test_sequence_003_array[] = {
&nil_test_003_001,
&nil_test_003_002,
&nil_test_003_003,
NULL
};
/**
* @brief Semaphores.
*/
const testsequence_t nil_test_sequence_003 = {
NULL,
nil_test_sequence_003_array
};
#endif /* CH_CFG_USE_SEMAPHORES */

View File

@ -15,13 +15,13 @@
*/
/**
* @file test_sequence_003.h
* @file nil_test_sequence_003.h
* @brief Test Sequence 003 header.
*/
#ifndef TEST_SEQUENCE_003_H
#define TEST_SEQUENCE_003_H
#ifndef NIL_TEST_SEQUENCE_003_H
#define NIL_TEST_SEQUENCE_003_H
extern const testcase_t * const test_sequence_003[];
extern const testsequence_t nil_test_sequence_003;
#endif /* TEST_SEQUENCE_003_H */
#endif /* NIL_TEST_SEQUENCE_003_H */

View File

@ -15,24 +15,23 @@
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
#include "nil_test_root.h"
/**
* @file test_sequence_004.c
* @file nil_test_sequence_004.c
* @brief Test Sequence 004 code.
*
* @page test_sequence_004 [4] Suspend/Resume and Event Flags
* @page nil_test_sequence_004 [4] Suspend/Resume and Event Flags
*
* File: @ref test_sequence_004.c
* File: @ref nil_test_sequence_004.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* threads suspend/resume and event flags.
*
* <h2>Test Cases</h2>
* - @subpage test_004_001
* - @subpage test_004_002
* - @subpage nil_test_004_001
* - @subpage nil_test_004_002
* .
*/
@ -47,7 +46,7 @@ static thread_reference_t tr1;
****************************************************************************/
/**
* @page test_004_001 [4.1] Suspend and Resume functionality
* @page nil_test_004_001 [4.1] Suspend and Resume functionality
*
* <h2>Description</h2>
* The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
@ -63,11 +62,11 @@ static thread_reference_t tr1;
* .
*/
static void test_004_001_setup(void) {
static void nil_test_004_001_setup(void) {
tr1 = NULL;
}
static void test_004_001_execute(void) {
static void nil_test_004_001_execute(void) {
systime_t time;
msg_t msg;
@ -90,26 +89,26 @@ static void test_004_001_execute(void) {
{
chSysLock();
time = chVTGetSystemTimeX();
msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
msg = chThdSuspendTimeoutS(&tr1, TIME_MS2I(1000));
chSysUnlock();
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert(NULL == tr1, "not NULL");
test_assert(MSG_TIMEOUT == msg, "wrong returned message");
}
}
static const testcase_t test_004_001 = {
static const testcase_t nil_test_004_001 = {
"Suspend and Resume functionality",
test_004_001_setup,
nil_test_004_001_setup,
NULL,
test_004_001_execute
nil_test_004_001_execute
};
#if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
/**
* @page test_004_002 [4.2] Events Flags functionality
* @page nil_test_004_002 [4.2] Events Flags functionality
*
* <h2>Description</h2>
* Event flags functionality is tested.
@ -133,7 +132,7 @@ static const testcase_t test_004_001 = {
* .
*/
static void test_004_002_execute(void) {
static void nil_test_004_002_execute(void) {
systime_t time;
eventmask_t events;
@ -145,7 +144,7 @@ static void test_004_002_execute(void) {
{
time = chVTGetSystemTimeX();
chEvtSignal(chThdGetSelfX(), 0x55);
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
events = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");
}
@ -157,7 +156,7 @@ static void test_004_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdGetSelfX()->epmask = 0;
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
events = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");
}
@ -167,19 +166,19 @@ static void test_004_002_execute(void) {
test_set_step(3);
{
time = chVTGetSystemTimeX();
events = chEvtWaitAnyTimeout(0, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
events = chEvtWaitAnyTimeout(0, TIME_MS2I(1000));
test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert((eventmask_t)0 == events, "wrong events mask");
}
}
static const testcase_t test_004_002 = {
static const testcase_t nil_test_004_002 = {
"Events Flags functionality",
NULL,
NULL,
test_004_002_execute
nil_test_004_002_execute
};
#endif /* CH_CFG_USE_EVENTS */
@ -188,12 +187,20 @@ static const testcase_t test_004_002 = {
****************************************************************************/
/**
* @brief Suspend/Resume and Event Flags.
* @brief Array of test cases.
*/
const testcase_t * const test_sequence_004[] = {
&test_004_001,
const testcase_t * const nil_test_sequence_004_array[] = {
&nil_test_004_001,
#if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
&test_004_002,
&nil_test_004_002,
#endif
NULL
};
/**
* @brief Suspend/Resume and Event Flags.
*/
const testsequence_t nil_test_sequence_004 = {
NULL,
nil_test_sequence_004_array
};

View File

@ -15,13 +15,13 @@
*/
/**
* @file test_sequence_004.h
* @file nil_test_sequence_004.h
* @brief Test Sequence 004 header.
*/
#ifndef TEST_SEQUENCE_004_H
#define TEST_SEQUENCE_004_H
#ifndef NIL_TEST_SEQUENCE_004_H
#define NIL_TEST_SEQUENCE_004_H
extern const testcase_t * const test_sequence_004[];
extern const testsequence_t nil_test_sequence_004;
#endif /* TEST_SEQUENCE_004_H */
#endif /* NIL_TEST_SEQUENCE_004_H */

View File

@ -1,408 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
/**
* @file test_sequence_005.c
* @brief Test Sequence 005 code.
*
* @page test_sequence_005 [5] Mailboxes
*
* File: @ref test_sequence_005.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* mailboxes.
*
* <h2>Conditions</h2>
* This sequence is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_MAILBOXES
* .
*
* <h2>Test Cases</h2>
* - @subpage test_005_001
* - @subpage test_005_002
* - @subpage test_005_003
* .
*/
#if (CH_CFG_USE_MAILBOXES) || defined(__DOXYGEN__)
/****************************************************************************
* Shared code.
****************************************************************************/
#define ALLOWED_DELAY MS2ST(5)
#define MB_SIZE 4
static msg_t mb_buffer[MB_SIZE];
static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);
/****************************************************************************
* Test cases.
****************************************************************************/
/**
* @page test_005_001 [5.1] Mailbox normal API, non-blocking tests
*
* <h2>Description</h2>
* The mailbox normal API is tested without triggering blocking
* conditions.
*
* <h2>Test Steps</h2>
* - [5.1.1] Testing the mailbox size.
* - [5.1.2] Resetting the mailbox, conditions are checked, no errors
* expected.
* - [5.1.3] Testing the behavior of API when the mailbox is in reset
* state then return in active state.
* - [5.1.4] Filling the mailbox using chMBPostTimeout() and
* chMBPostAheadTimeout() once, no errors expected.
* - [5.1.5] Testing intermediate conditions. Data pointers must be
* aligned, semaphore counters are checked.
* - [5.1.6] Emptying the mailbox using chMBFetchTimeout(), no errors
* expected.
* - [5.1.7] Posting and then fetching one more message, no errors
* expected.
* - [5.1.8] Testing final conditions. Data pointers must be aligned to
* buffer start, semaphore counters are checked.
* .
*/
static void test_005_001_setup(void) {
chMBObjectInit(&mb1, mb_buffer, MB_SIZE);
}
static void test_005_001_teardown(void) {
chMBReset(&mb1);
}
static void test_005_001_execute(void) {
msg_t msg1, msg2;
unsigned i;
/* [5.1.1] Testing the mailbox size.*/
test_set_step(1);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
}
/* [5.1.2] Resetting the mailbox, conditions are checked, no errors
expected.*/
test_set_step(2);
{
chMBReset(&mb1);
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
test_assert_lock(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
}
/* [5.1.3] Testing the behavior of API when the mailbox is in reset
state then return in active state.*/
test_set_step(3);
{
msg1 = chMBPostTimeout(&mb1, (msg_t)0, TIME_INFINITE);
test_assert(msg1 == MSG_RESET, "not in reset state");
msg1 = chMBPostAheadTimeout(&mb1, (msg_t)0, TIME_INFINITE);
test_assert(msg1 == MSG_RESET, "not in reset state");
msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
test_assert(msg1 == MSG_RESET, "not in reset state");
chMBResumeX(&mb1);
}
/* [5.1.4] Filling the mailbox using chMBPostTimeout() and
chMBPostAheadTimeout() once, no errors expected.*/
test_set_step(4);
{
for (i = 0; i < MB_SIZE - 1; i++) {
msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
msg1 = chMBPostAheadTimeout(&mb1, 'A', TIME_INFINITE);
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
/* [5.1.5] Testing intermediate conditions. Data pointers must be
aligned, semaphore counters are checked.*/
test_set_step(5);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
test_assert_lock(chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");
}
/* [5.1.6] Emptying the mailbox using chMBFetchTimeout(), no errors
expected.*/
test_set_step(6);
{
for (i = 0; i < MB_SIZE; i++) {
msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
test_assert(msg1 == MSG_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence("ABCD", "wrong get sequence");
}
/* [5.1.7] Posting and then fetching one more message, no errors
expected.*/
test_set_step(7);
{
msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
test_assert(msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
/* [5.1.8] Testing final conditions. Data pointers must be aligned to
buffer start, semaphore counters are checked.*/
test_set_step(8);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
test_assert(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
}
}
static const testcase_t test_005_001 = {
"Mailbox normal API, non-blocking tests",
test_005_001_setup,
test_005_001_teardown,
test_005_001_execute
};
/**
* @page test_005_002 [5.2] Mailbox I-Class API, non-blocking tests
*
* <h2>Description</h2>
* The mailbox I-Class API is tested without triggering blocking
* conditions.
*
* <h2>Test Steps</h2>
* - [5.2.1] Testing the mailbox size.
* - [5.2.2] Resetting the mailbox, conditions are checked, no errors
* expected.
* - [5.2.3] Filling the mailbox using chMBPostI() and chMBPostAheadI()
* once, no errors expected.
* - [5.2.4] Testing intermediate conditions. Data pointers must be
* aligned, semaphore counters are checked.
* - [5.2.5] Emptying the mailbox using chMBFetchI(), no errors
* expected.
* - [5.2.6] Posting and then fetching one more message, no errors
* expected.
* - [5.2.7] Testing final conditions. Data pointers must be aligned to
* buffer start, semaphore counters are checked.
* .
*/
static void test_005_002_setup(void) {
chMBObjectInit(&mb1, mb_buffer, MB_SIZE);
}
static void test_005_002_teardown(void) {
chMBReset(&mb1);
}
static void test_005_002_execute(void) {
msg_t msg1, msg2;
unsigned i;
/* [5.2.1] Testing the mailbox size.*/
test_set_step(1);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
}
/* [5.2.2] Resetting the mailbox, conditions are checked, no errors
expected.*/
test_set_step(2);
{
chSysLock();
chMBResetI(&mb1);
chSysUnlock();
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
test_assert_lock(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
chMBResumeX(&mb1);
}
/* [5.2.3] Filling the mailbox using chMBPostI() and chMBPostAheadI()
once, no errors expected.*/
test_set_step(3);
{
for (i = 0; i < MB_SIZE - 1; i++) {
chSysLock();
msg1 = chMBPostI(&mb1, 'B' + i);
chSysUnlock();
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
chSysLock();
msg1 = chMBPostAheadI(&mb1, 'A');
chSysUnlock();
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
/* [5.2.4] Testing intermediate conditions. Data pointers must be
aligned, semaphore counters are checked.*/
test_set_step(4);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
test_assert_lock(chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");
}
/* [5.2.5] Emptying the mailbox using chMBFetchI(), no errors
expected.*/
test_set_step(5);
{
for (i = 0; i < MB_SIZE; i++) {
chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
chSysUnlock();
test_assert(msg1 == MSG_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence("ABCD", "wrong get sequence");
}
/* [5.2.6] Posting and then fetching one more message, no errors
expected.*/
test_set_step(6);
{
msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
test_assert(msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
/* [5.2.7] Testing final conditions. Data pointers must be aligned to
buffer start, semaphore counters are checked.*/
test_set_step(7);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
test_assert(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
}
}
static const testcase_t test_005_002 = {
"Mailbox I-Class API, non-blocking tests",
test_005_002_setup,
test_005_002_teardown,
test_005_002_execute
};
/**
* @page test_005_003 [5.3] Mailbox timeouts
*
* <h2>Description</h2>
* The mailbox API is tested for timeouts.
*
* <h2>Test Steps</h2>
* - [5.3.1] Filling the mailbox.
* - [5.3.2] Testing chMBPostTimeout(), chMBPostI(),
* chMBPostAheadTimeout() and chMBPostAheadI() timeout.
* - [5.3.3] Resetting the mailbox.
* - [5.3.4] Testing chMBFetchTimeout() and chMBFetchI() timeout.
* .
*/
static void test_005_003_setup(void) {
chMBObjectInit(&mb1, mb_buffer, MB_SIZE);
}
static void test_005_003_teardown(void) {
chMBReset(&mb1);
}
static void test_005_003_execute(void) {
msg_t msg1, msg2;
unsigned i;
/* [5.3.1] Filling the mailbox.*/
test_set_step(1);
{
for (i = 0; i < MB_SIZE; i++) {
msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
}
/* [5.3.2] Testing chMBPostTimeout(), chMBPostI(),
chMBPostAheadTimeout() and chMBPostAheadI() timeout.*/
test_set_step(2);
{
msg1 = chMBPostTimeout(&mb1, 'X', 1);
test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBPostI(&mb1, 'X');
chSysUnlock();
test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
msg1 = chMBPostAheadTimeout(&mb1, 'X', 1);
test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBPostAheadI(&mb1, 'X');
chSysUnlock();
test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
}
/* [5.3.3] Resetting the mailbox.*/
test_set_step(3);
{
chMBReset(&mb1);;
chMBResumeX(&mb1);
}
/* [5.3.4] Testing chMBFetchTimeout() and chMBFetchI() timeout.*/
test_set_step(4);
{
msg1 = chMBFetchTimeout(&mb1, &msg2, 1);
test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
chSysUnlock();
test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
}
}
static const testcase_t test_005_003 = {
"Mailbox timeouts",
test_005_003_setup,
test_005_003_teardown,
test_005_003_execute
};
/****************************************************************************
* Exported data.
****************************************************************************/
/**
* @brief Mailboxes.
*/
const testcase_t * const test_sequence_005[] = {
&test_005_001,
&test_005_002,
&test_005_003,
NULL
};
#endif /* CH_CFG_USE_MAILBOXES */

View File

@ -1,27 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file test_sequence_005.h
* @brief Test Sequence 005 header.
*/
#ifndef TEST_SEQUENCE_005_H
#define TEST_SEQUENCE_005_H
extern const testcase_t * const test_sequence_005[];
#endif /* TEST_SEQUENCE_005_H */

View File

@ -1,296 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
/**
* @file test_sequence_006.c
* @brief Test Sequence 006 code.
*
* @page test_sequence_006 [6] Memory Pools
*
* File: @ref test_sequence_006.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* memory pools.
*
* <h2>Conditions</h2>
* This sequence is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_MEMPOOLS
* .
*
* <h2>Test Cases</h2>
* - @subpage test_006_001
* - @subpage test_006_002
* - @subpage test_006_003
* .
*/
#if (CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
/****************************************************************************
* Shared code.
****************************************************************************/
#define MEMORY_POOL_SIZE 4
static uint32_t objects[MEMORY_POOL_SIZE];
static MEMORYPOOL_DECL(mp1, sizeof (uint32_t), PORT_NATURAL_ALIGN, NULL);
#if CH_CFG_USE_SEMAPHORES
static GUARDEDMEMORYPOOL_DECL(gmp1, sizeof (uint32_t), PORT_NATURAL_ALIGN);
#endif
static void *null_provider(size_t size, unsigned align) {
(void)size;
(void)align;
return NULL;
}
/****************************************************************************
* Test cases.
****************************************************************************/
/**
* @page test_006_001 [6.1] Loading and emptying a memory pool
*
* <h2>Description</h2>
* The memory pool functionality is tested by loading and emptying it,
* all conditions are tested.
*
* <h2>Test Steps</h2>
* - [6.1.1] Adding the objects to the pool using chPoolLoadArray().
* - [6.1.2] Emptying the pool using chPoolAlloc().
* - [6.1.3] Now must be empty.
* - [6.1.4] Adding the objects to the pool using chPoolFree().
* - [6.1.5] Emptying the pool using chPoolAlloc() again.
* - [6.1.6] Now must be empty again.
* - [6.1.7] Covering the case where a provider is unable to return
* more memory.
* .
*/
static void test_006_001_setup(void) {
chPoolObjectInit(&mp1, sizeof (uint32_t), NULL);
}
static void test_006_001_execute(void) {
unsigned i;
/* [6.1.1] Adding the objects to the pool using chPoolLoadArray().*/
test_set_step(1);
{
chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE);
}
/* [6.1.2] Emptying the pool using chPoolAlloc().*/
test_set_step(2);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chPoolAlloc(&mp1) != NULL, "list empty");
}
/* [6.1.3] Now must be empty.*/
test_set_step(3);
{
test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
}
/* [6.1.4] Adding the objects to the pool using chPoolFree().*/
test_set_step(4);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
chPoolFree(&mp1, &objects[i]);
}
/* [6.1.5] Emptying the pool using chPoolAlloc() again.*/
test_set_step(5);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chPoolAlloc(&mp1) != NULL, "list empty");
}
/* [6.1.6] Now must be empty again.*/
test_set_step(6);
{
test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
}
/* [6.1.7] Covering the case where a provider is unable to return
more memory.*/
test_set_step(7);
{
chPoolObjectInit(&mp1, sizeof (uint32_t), null_provider);
test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");
}
}
static const testcase_t test_006_001 = {
"Loading and emptying a memory pool",
test_006_001_setup,
NULL,
test_006_001_execute
};
#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
/**
* @page test_006_002 [6.2] Loading and emptying a guarded memory pool without waiting
*
* <h2>Description</h2>
* The memory pool functionality is tested by loading and emptying it,
* all conditions are tested.
*
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_SEMAPHORES
* .
*
* <h2>Test Steps</h2>
* - [6.2.1] Adding the objects to the pool using
* chGuardedPoolLoadArray().
* - [6.2.2] Emptying the pool using chGuardedPoolAllocTimeout().
* - [6.2.3] Now must be empty.
* - [6.2.4] Adding the objects to the pool using chGuardedPoolFree().
* - [6.2.5] Emptying the pool using chGuardedPoolAllocTimeout() again.
* - [6.2.6] Now must be empty again.
* .
*/
static void test_006_002_setup(void) {
chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));
}
static void test_006_002_execute(void) {
unsigned i;
/* [6.2.1] Adding the objects to the pool using
chGuardedPoolLoadArray().*/
test_set_step(1);
{
chGuardedPoolLoadArray(&gmp1, objects, MEMORY_POOL_SIZE);
}
/* [6.2.2] Emptying the pool using chGuardedPoolAllocTimeout().*/
test_set_step(2);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");
}
/* [6.2.3] Now must be empty.*/
test_set_step(3);
{
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");
}
/* [6.2.4] Adding the objects to the pool using
chGuardedPoolFree().*/
test_set_step(4);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
chGuardedPoolFree(&gmp1, &objects[i]);
}
/* [6.2.5] Emptying the pool using chGuardedPoolAllocTimeout()
again.*/
test_set_step(5);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");
}
/* [6.2.6] Now must be empty again.*/
test_set_step(6);
{
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");
}
}
static const testcase_t test_006_002 = {
"Loading and emptying a guarded memory pool without waiting",
test_006_002_setup,
NULL,
test_006_002_execute
};
#endif /* CH_CFG_USE_SEMAPHORES */
#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
/**
* @page test_006_003 [6.3] Guarded Memory Pools timeout
*
* <h2>Description</h2>
* The timeout features for the Guarded Memory Pools is tested.
*
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_SEMAPHORES
* .
*
* <h2>Test Steps</h2>
* - [6.3.1] Trying to allocate with 100mS timeout, must fail because
* the pool is empty.
* .
*/
static void test_006_003_setup(void) {
chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));
}
static void test_006_003_execute(void) {
/* [6.3.1] Trying to allocate with 100mS timeout, must fail because
the pool is empty.*/
test_set_step(1);
{
test_assert(chGuardedPoolAllocTimeout(&gmp1, MS2ST(100)) == NULL, "list not empty");
}
}
static const testcase_t test_006_003 = {
"Guarded Memory Pools timeout",
test_006_003_setup,
NULL,
test_006_003_execute
};
#endif /* CH_CFG_USE_SEMAPHORES */
/****************************************************************************
* Exported data.
****************************************************************************/
/**
* @brief Memory Pools.
*/
const testcase_t * const test_sequence_006[] = {
&test_006_001,
#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
&test_006_002,
#endif
#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
&test_006_003,
#endif
NULL
};
#endif /* CH_CFG_USE_MEMPOOLS */

View File

@ -1,27 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file test_sequence_006.h
* @brief Test Sequence 006 header.
*/
#ifndef TEST_SEQUENCE_006_H
#define TEST_SEQUENCE_006_H
extern const testcase_t * const test_sequence_006[];
#endif /* TEST_SEQUENCE_006_H */

View File

@ -1,273 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
/**
* @file test_sequence_007.c
* @brief Test Sequence 007 code.
*
* @page test_sequence_007 [7] Memory Heaps
*
* File: @ref test_sequence_007.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* memory heaps.
*
* <h2>Conditions</h2>
* This sequence is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_HEAP
* .
*
* <h2>Test Cases</h2>
* - @subpage test_007_001
* - @subpage test_007_002
* .
*/
#if (CH_CFG_USE_HEAP) || defined(__DOXYGEN__)
/****************************************************************************
* Shared code.
****************************************************************************/
#define ALLOC_SIZE 16
#define HEAP_SIZE (ALLOC_SIZE * 8)
static memory_heap_t test_heap;
static CH_HEAP_AREA(myheap, HEAP_SIZE);
/****************************************************************************
* Test cases.
****************************************************************************/
/**
* @page test_007_001 [7.1] Allocation and fragmentation
*
* <h2>Description</h2>
* Series of allocations/deallocations are performed in carefully
* designed sequences in order to stimulate all the possible code paths
* inside the allocator. The test expects to find the heap back to the
* initial status after each sequence.
*
* <h2>Test Steps</h2>
* - [7.1.1] Testing initial conditions, the heap must not be
* fragmented and one free block present.
* - [7.1.2] Trying to allocate an block bigger than available space,
* an error is expected.
* - [7.1.3] Single block allocation using chHeapAlloc() then the block
* is freed using chHeapFree(), must not fail.
* - [7.1.4] Using chHeapStatus() to assess the heap state. There must
* be at least one free block of sufficient size.
* - [7.1.5] Allocating then freeing in the same order.
* - [7.1.6] Allocating then freeing in reverse order.
* - [7.1.7] Small fragments handling. Checking the behavior when
* allocating blocks with size not multiple of alignment unit.
* - [7.1.8] Skipping a fragment, the first fragment in the list is too
* small so the allocator must pick the second one.
* - [7.1.9] Allocating the whole available space.
* - [7.1.10] Testing final conditions. The heap geometry must be the
* same than the one registered at beginning.
* .
*/
static void test_007_001_setup(void) {
chHeapObjectInit(&test_heap, myheap, sizeof(myheap));
}
static void test_007_001_execute(void) {
void *p1, *p2, *p3;
size_t n, sz;
/* [7.1.1] Testing initial conditions, the heap must not be
fragmented and one free block present.*/
test_set_step(1);
{
test_assert(chHeapStatus(&test_heap, &sz, NULL) == 1, "heap fragmented");
}
/* [7.1.2] Trying to allocate an block bigger than available space,
an error is expected.*/
test_set_step(2);
{
p1 = chHeapAlloc(&test_heap, HEAP_SIZE * 2);
test_assert(p1 == NULL, "allocation not failed");
}
/* [7.1.3] Single block allocation using chHeapAlloc() then the block
is freed using chHeapFree(), must not fail.*/
test_set_step(3);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
test_assert(p1 != NULL, "allocation failed");
chHeapFree(p1);
}
/* [7.1.4] Using chHeapStatus() to assess the heap state. There must
be at least one free block of sufficient size.*/
test_set_step(4);
{
size_t total_size, largest_size;
n = chHeapStatus(&test_heap, &total_size, &largest_size);
test_assert(n == 1, "missing free block");
test_assert(total_size >= ALLOC_SIZE, "unexpected heap state");
test_assert(total_size == largest_size, "unexpected heap state");
}
/* [7.1.5] Allocating then freeing in the same order.*/
test_set_step(5);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
p3 = chHeapAlloc(&test_heap, ALLOC_SIZE);
chHeapFree(p1); /* Does not merge.*/
chHeapFree(p2); /* Merges backward.*/
chHeapFree(p3); /* Merges both sides.*/
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
}
/* [7.1.6] Allocating then freeing in reverse order.*/
test_set_step(6);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
p3 = chHeapAlloc(&test_heap, ALLOC_SIZE);
chHeapFree(p3); /* Merges forward.*/
chHeapFree(p2); /* Merges forward.*/
chHeapFree(p1); /* Merges forward.*/
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
}
/* [7.1.7] Small fragments handling. Checking the behavior when
allocating blocks with size not multiple of alignment unit.*/
test_set_step(7);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE + 1);
p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
chHeapFree(p1);
test_assert(chHeapStatus(&test_heap, &n, NULL) == 2, "invalid state");
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
/* Note, the first situation happens when the alignment size is smaller
than the header size, the second in the other cases.*/
test_assert((chHeapStatus(&test_heap, &n, NULL) == 1) ||
(chHeapStatus(&test_heap, &n, NULL) == 2), "heap fragmented");
chHeapFree(p2);
chHeapFree(p1);
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
}
/* [7.1.8] Skipping a fragment, the first fragment in the list is too
small so the allocator must pick the second one.*/
test_set_step(8);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
chHeapFree(p1);
test_assert( chHeapStatus(&test_heap, &n, NULL) == 2, "invalid state");
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE * 2); /* Skips first fragment.*/
chHeapFree(p1);
chHeapFree(p2);
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
}
/* [7.1.9] Allocating the whole available space.*/
test_set_step(9);
{
(void)chHeapStatus(&test_heap, &n, NULL);
p1 = chHeapAlloc(&test_heap, n);
test_assert(p1 != NULL, "allocation failed");
test_assert(chHeapStatus(&test_heap, NULL, NULL) == 0, "not empty");
chHeapFree(p1);
}
/* [7.1.10] Testing final conditions. The heap geometry must be the
same than the one registered at beginning.*/
test_set_step(10);
{
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
test_assert(n == sz, "size changed");
}
}
static const testcase_t test_007_001 = {
"Allocation and fragmentation",
test_007_001_setup,
NULL,
test_007_001_execute
};
/**
* @page test_007_002 [7.2] Default Heap
*
* <h2>Description</h2>
* The default heap is pre-allocated in the system. We test base
* functionality.
*
* <h2>Test Steps</h2>
* - [7.2.1] Single block allocation using chHeapAlloc() then the block
* is freed using chHeapFree(), must not fail.
* - [7.2.2] Testing allocation failure.
* .
*/
static void test_007_002_execute(void) {
void *p1;
size_t total_size, largest_size;
/* [7.2.1] Single block allocation using chHeapAlloc() then the block
is freed using chHeapFree(), must not fail.*/
test_set_step(1);
{
(void)chHeapStatus(NULL, &total_size, &largest_size);
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
test_assert(p1 != NULL, "allocation failed");
chHeapFree(p1);
}
/* [7.2.2] Testing allocation failure.*/
test_set_step(2);
{
p1 = chHeapAlloc(NULL, (size_t)-256);
test_assert(p1 == NULL, "allocation not failed");
}
}
static const testcase_t test_007_002 = {
"Default Heap",
NULL,
NULL,
test_007_002_execute
};
/****************************************************************************
* Exported data.
****************************************************************************/
/**
* @brief Memory Heaps.
*/
const testcase_t * const test_sequence_007[] = {
&test_007_001,
&test_007_002,
NULL
};
#endif /* CH_CFG_USE_HEAP */

View File

@ -1,27 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file test_sequence_007.h
* @brief Test Sequence 007 header.
*/
#ifndef TEST_SEQUENCE_007_H
#define TEST_SEQUENCE_007_H
extern const testcase_t * const test_sequence_007[];
#endif /* TEST_SEQUENCE_007_H */

View File

@ -1,14 +0,0 @@
# List of all the ChibiOS/NIL test files.
TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \
${CHIBIOS}/test/nil/source/test/test_root.c \
${CHIBIOS}/test/nil/source/test/test_sequence_001.c \
${CHIBIOS}/test/nil/source/test/test_sequence_002.c \
${CHIBIOS}/test/nil/source/test/test_sequence_003.c \
${CHIBIOS}/test/nil/source/test/test_sequence_004.c \
${CHIBIOS}/test/nil/source/test/test_sequence_005.c \
${CHIBIOS}/test/nil/source/test/test_sequence_006.c\
${CHIBIOS}/test/nil/source/test/test_sequence_007.c
# Required include directories
TESTINC = ${CHIBIOS}/test/lib \
${CHIBIOS}/test/nil/source/test