Updated the NIL test suite by generating the code using the new system.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9127 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2016-03-16 14:48:13 +00:00
parent 94bbc4d19c
commit 13375b4faa
21 changed files with 4440 additions and 540 deletions

View File

@ -79,6 +79,7 @@
***************************************************************************** *****************************************************************************
*** Next *** *** Next ***
- NIL: Updated the NIL test suite by generating the code using the new system.
- RT: Removed I/O Queues and Streams interface, now those exists (much - RT: Removed I/O Queues and Streams interface, now those exists (much
improved) inside the HAL. improved) inside the HAL.
- HAL: Improvements to the I/O queues now timeouts are absolute for - HAL: Improvements to the I/O queues now timeouts are absolute for

56
test/nil/.cproject Normal file
View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.st.tools.spc5.configuration.default">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.tools.spc5.configuration.default" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="com.st.tools.spc5.configuration.default" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="com.st.tools.spc5.configuration.default." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1601604545" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1601604545.979430051" name=""/>
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1252703125" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder">
<outputEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name=""/>
</outputEntries>
</builder>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.758143064" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.466800556" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.276542087" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1590093401" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1021209563" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1880457386" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1710576459" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="source"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="NIL Tests Generator.null.1740439042" name="NIL Tests Generator"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="com.st.tools.spc5.configuration.default">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>

32
test/nil/.project Normal file
View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>NIL Tests Generator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.st.tools.spc5.spc5StudioPatchBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>com.st.tools.spc5.spc5StudioNature</nature>
</natures>
</projectDescription>

4
test/nil/.spc5project Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<SPC5StudioProject>
<Properties />
</SPC5StudioProject>

560
test/nil/configuration.xml Normal file
View File

@ -0,0 +1,560 @@
<?xml version="1.0" encoding="UTF-8"?>
<SPC5-Config version="1.0.0">
<application name="Test Suite" version="1.0.0" standalone="true" locked="false">
<description>Test specification for the NASA OSAL ChibiOS extension.</description>
<component id="org.chibios.spc5.components.platform.generic">
<component id="org.chibios.spc5.components.chibios_unitary_tests_engine" />
</component>
<instances>
<instance locked="false" id="org.chibios.spc5.components.platform.generic" />
<instance locked="false" id="org.chibios.spc5.components.chibios_unitary_tests_engine">
<description>
<introduction>
<value>Test suite for ChibiOS/NIL. The purpose of this suite is to perform unit tests on the NIL modules and to converge to 100% code coverage through successive improvements.</value>
</introduction>
</description>
<global_data_and_code>
<global_definitions>
<value><![CDATA[#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
extern semaphore_t gsem1, gsem2;
extern thread_reference_t gtr1;
extern THD_WORKING_AREA(wa_test_support, 128);
THD_FUNCTION(test_support, arg);]]></value>
</global_definitions>
<global_code>
<value><![CDATA[semaphore_t gsem1, gsem2;
thread_reference_t gtr1;
/*
* Support thread.
*/
THD_WORKING_AREA(wa_test_support, 128);
THD_FUNCTION(test_support, arg) {
#if CH_CFG_USE_EVENTS == TRUE
thread_t *tp = (thread_t *)arg;
#else
(void)arg;
#endif
/* Initializing global resources.*/
chSemObjectInit(&gsem1, 0);
chSemObjectInit(&gsem2, 0);
while (true) {
chSysLock();
if (chSemGetCounterI(&gsem1) < 0)
chSemSignalI(&gsem1);
chSemResetI(&gsem2, 0);
chThdResumeI(&gtr1, MSG_OK);
#if CH_CFG_USE_EVENTS == TRUE
chEvtSignalI(tp, 0x55);
#endif
chSchRescheduleS();
chSysUnlock();
chThdSleepMilliseconds(250);
}
}]]></value>
</global_code>
</global_data_and_code>
<sequences>
<sequence>
<type index="0">
<value>Internal Tests</value>
</type>
<brief>
<value>Threads Functionality</value>
</brief>
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to threading.</value>
</description>
<shared_code>
<value><![CDATA[#include "ch.h"]]></value>
</shared_code>
<cases>
<case>
<brief>
<value>System Tick Counter functionality.</value>
</brief>
<description>
<value>The functionality of the API @p chVTGetSystemTimeX() is tested.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value />
</setup_code>
<teardown_code>
<value />
</teardown_code>
<local_variables>
<value />
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>A System Tick Counter increment is expected, the test simply hangs if it does not happen.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[systime_t time = chVTGetSystemTimeX();
while (time == chVTGetSystemTimeX()) {
}]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>Thread Sleep functionality.</value>
</brief>
<description>
<value>The functionality of @p chThdSleep() and derivatives is tested.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value />
</setup_code>
<teardown_code>
<value />
</teardown_code>
<local_variables>
<value><![CDATA[systime_t time;]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>The current system time is read then a sleep is performed for 100 system ticks and on exit the system time is verified again.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleep(100);
test_assert_time_window(time + 100,
time + 100 + 1,
"out of time window");]]></value>
</code>
</step>
<step>
<description>
<value>The current system time is read then a sleep is performed for 100000 microseconds and on exit the system time is verified again.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleepMicroseconds(100000);
test_assert_time_window(time + US2ST(100000),
time + US2ST(100000) + 1,
"out of time window");]]></value>
</code>
</step>
<step>
<description>
<value>The current system time is read then a sleep is performed for 100 milliseconds and on exit the system time is verified again.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleepMilliseconds(100);
test_assert_time_window(time + MS2ST(100),
time + MS2ST(100) + 1,
"out of time window");]]></value>
</code>
</step>
<step>
<description>
<value>The current system time is read then a sleep is performed for 1 second and on exit the system time is verified again.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleepSeconds(1);
test_assert_time_window(time + S2ST(1),
time + S2ST(1) + 1,
"out of time window");]]></value>
</code>
</step>
<step>
<description>
<value>Function chThdSleepUntil() is tested with a timeline of "now" + 100 ticks.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleepUntil(time + 100);
test_assert_time_window(time + 100,
time + 100 + 1,
"out of time window");]]></value>
</code>
</step>
</steps>
</case>
</cases>
</sequence>
<sequence>
<type index="0">
<value>Internal Tests</value>
</type>
<brief>
<value>Semaphores</value>
</brief>
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to counter semaphores.</value>
</description>
<shared_code>
<value><![CDATA[#include "ch.h"
static semaphore_t sem1;]]></value>
</shared_code>
<cases>
<case>
<brief>
<value>Semaphore primitives, no state change.</value>
</brief>
<description>
<value>Wait, Signal and Reset primitives are tested. The testing thread does not trigger a state change.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[chSemObjectInit(&sem1, 1);]]></value>
</setup_code>
<teardown_code>
<value><![CDATA[chSemReset(&sem1, 0);]]></value>
</teardown_code>
<local_variables>
<value />
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>The function chSemWait() is invoked, after return the counter and the returned message are tested.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[msg_t msg;
msg = chSemWait(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_OK == msg, "wrong returned message");]]></value>
</code>
</step>
<step>
<description>
<value>The function chSemSignal() is invoked, after return the counter is tested.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[chSemSignal(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");]]></value>
</code>
</step>
<step>
<description>
<value>The function chSemReset() is invoked, after return the counter is tested.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[chSemReset(&sem1, 2);
test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>Semaphore primitives, with state change.</value>
</brief>
<description>
<value>Wait, Signal and Reset primitives are tested. The testing thread triggers a state change.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[chSemObjectInit(&gsem1, 0);]]></value>
</setup_code>
<teardown_code>
<value><![CDATA[chSemReset(&gsem1, 0);]]></value>
</teardown_code>
<local_variables>
<value />
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>The function chSemWait() is invoked, after return the counter and the returned message are tested. The semaphore is signaled by another thread.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[msg_t msg;
msg = chSemWait(&gsem1);
test_assert_lock(chSemGetCounterI(&gsem1) == 0, "wrong counter value");
test_assert(MSG_OK == msg, "wrong returned message");]]></value>
</code>
</step>
<step>
<description>
<value>The function chSemWait() is invoked, after return the counter and the returned message are tested. The semaphore is reset by another thread.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[msg_t msg;
msg = chSemWait(&gsem2);
test_assert_lock(chSemGetCounterI(&gsem2) == 0,"wrong counter value");
test_assert(MSG_RESET == msg, "wrong returned message");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>Semaphores timeout.</value>
</brief>
<description>
<value>Timeout on semaphores is tested.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[chSemObjectInit(&sem1, 0);]]></value>
</setup_code>
<teardown_code>
<value><![CDATA[chSemReset(&sem1, 0);]]></value>
</teardown_code>
<local_variables>
<value><![CDATA[systime_t time;
msg_t msg;]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>The function chSemWaitTimeout() is invoked a first time, after return the system time, the counter and the returned message are tested.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
</code>
</step>
<step>
<description>
<value>The function chSemWaitTimeout() is invoked again, after return the system time, the counter and the returned message are tested.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
</code>
</step>
</steps>
</case>
</cases>
</sequence>
<sequence>
<type index="0">
<value>Internal Tests</value>
</type>
<brief>
<value>Suspend/Resume and Event Flags.</value>
</brief>
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to threads suspend/resume and event flags.</value>
</description>
<shared_code>
<value><![CDATA[static thread_reference_t tr1;]]></value>
</shared_code>
<cases>
<case>
<brief>
<value>Suspend and Resume functionality.</value>
</brief>
<description>
<value>The functionality of chThdSuspendTimeoutS() and chThdResumeI() is tested.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[tr1 = NULL;]]></value>
</setup_code>
<teardown_code>
<value />
</teardown_code>
<local_variables>
<value><![CDATA[systime_t time;
msg_t msg;]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>The function chThdSuspendTimeoutS() is invoked, the thread is remotely resumed with message @p MSG_OK. On return the message and the state of the reference are tested.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[chSysLock();
msg = chThdSuspendTimeoutS(&gtr1, TIME_INFINITE);
chSysUnlock();
test_assert(NULL == gtr1, "not NULL");
test_assert(MSG_OK == msg,"wrong returned message");]]></value>
</code>
</step>
<step>
<description>
<value>The function chThdSuspendTimeoutS() is invoked, the thread is not resumed so a timeout must occur. On return the message and the state of the reference are tested.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[chSysLock();
time = chVTGetSystemTimeX();
msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
chSysUnlock();
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
"out of time window");
test_assert(NULL == tr1, "not NULL");
test_assert(MSG_TIMEOUT == msg, "wrong returned message");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>Events Flags functionality.</value>
</brief>
<description>
<value>Event flags functionality is tested.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value />
</setup_code>
<teardown_code>
<value />
</teardown_code>
<local_variables>
<value><![CDATA[systime_t time;
eventmask_t events;]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>A set of event flags are set on the current thread then the function chEvtWaitAnyTimeout() is invoked, the function is supposed to return immediately because the event flags are already pending, after return the events mask is tested.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chEvtSignal(chThdGetSelfX(), 0x55);
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
</code>
</step>
<step>
<description>
<value>The pending event flags mask is cleared then the function chEvtWaitAnyTimeout() is invoked, after return the events mask is tested. The thread is signaled by another thread.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdGetSelfX()->epmask = 0;
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
</code>
</step>
<step>
<description>
<value>The function chEvtWaitAnyTimeout() is invoked, no event can wakeup the thread, the function must return because timeout.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
events = chEvtWaitAnyTimeout(0, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
"out of time window");
test_assert((eventmask_t)0 == events, "wrong events mask");]]></value>
</code>
</step>
</steps>
</case>
</cases>
</sequence>
</sequences>
</instance>
</instances>
<exportedFeatures />
</application>
</SPC5-Config>

5
test/nil/patch.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<SPC5-Patch version="1.0.0">
<!--It is your patch repository, do not break your XML File.-->
<files />
</SPC5-Patch>

View File

@ -1,5 +1,5 @@
/* /*
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -14,11 +14,24 @@
limitations under the License. limitations under the License.
*/ */
/**
* @mainpage Test Suite Specification
* Test suite for ChibiOS/NIL. The purpose of this suite is to perform
* unit tests on the NIL modules and to converge to 100% code coverage
* through successive improvements.
*
* <h2>Test Sequences</h2>
* - @subpage test_sequence_001
* - @subpage test_sequence_002
* - @subpage test_sequence_003
* .
*/
/** /**
* @file test_root.c * @file test_root.c
* @brief Test Suite root structures code. * @brief Test Suite root structures code.
* *
* @addtogroup CH_TEST_ROOT * @addtogroup SPC5_TEST_ROOT
* @{ * @{
*/ */
@ -36,6 +49,7 @@
const testcase_t * const *test_suite[] = { const testcase_t * const *test_suite[] = {
test_sequence_001, test_sequence_001,
test_sequence_002, test_sequence_002,
test_sequence_003,
NULL NULL
}; };
@ -61,7 +75,6 @@ THD_FUNCTION(test_support, arg) {
chSemObjectInit(&gsem1, 0); chSemObjectInit(&gsem1, 0);
chSemObjectInit(&gsem2, 0); chSemObjectInit(&gsem2, 0);
/* Waiting for button push and activation of the test suite.*/
while (true) { while (true) {
chSysLock(); chSysLock();
if (chSemGetCounterI(&gsem1) < 0) if (chSemGetCounterI(&gsem1) < 0)

View File

@ -18,25 +18,16 @@
* @file test_root.h * @file test_root.h
* @brief Test Suite root structures header. * @brief Test Suite root structures header.
* *
* @addtogroup CH_TEST_ROOT * @addtogroup SPC5_TEST_ROOT
* @{ * @{
*/ */
#ifndef _TEST_ROOT_H_ #ifndef _SPC5_TEST_ROOT_H_
#define _TEST_ROOT_H_ #define _SPC5_TEST_ROOT_H_
#include "ch.h"
#include "test_sequence_001.h" #include "test_sequence_001.h"
#include "test_sequence_002.h" #include "test_sequence_002.h"
#include "test_sequence_003.h"
/*===========================================================================*/
/* Default definitions. */
/*===========================================================================*/
/* Global test suite name, it is printed on top of the test
report header.*/
#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
@ -47,10 +38,6 @@ extern const testcase_t * const *test_suite[];
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern semaphore_t gsem1, gsem2;
extern thread_reference_t gtr1;
extern THD_WORKING_AREA(wa_test_support, 128);
THD_FUNCTION(test_support, arg);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -59,6 +46,14 @@ extern "C" {
/* Shared definitions. */ /* Shared definitions. */
/*===========================================================================*/ /*===========================================================================*/
#endif /* _TEST_ROOT_H_ */ #define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
extern semaphore_t gsem1, gsem2;
extern thread_reference_t gtr1;
extern THD_WORKING_AREA(wa_test_support, 128);
THD_FUNCTION(test_support, arg);
#endif /* _SPC5_TEST_ROOT_H_ */
/** @} */ /** @} */

View File

@ -24,7 +24,8 @@
* File: @ref test_sequence_001.c * File: @ref test_sequence_001.c
* *
* <h2>Description</h2> * <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to threading. * This sequence tests the ChibiOS/NIL functionalities related to
* threading.
* *
* <h2>Test Cases</h2> * <h2>Test Cases</h2>
* - @subpage test_001_001 * - @subpage test_001_001
@ -36,35 +37,31 @@
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
#include "ch.h"
/**************************************************************************** /****************************************************************************
* Test cases. * Test cases.
****************************************************************************/ ****************************************************************************/
#if TRUE || defined(__DOXYGEN__)
/** /**
* @page test_001_001 System Tick Counter functionality * @page test_001_001 System Tick Counter functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* The functionality of the API @p chVTGetSystemTimeX() is tested. * The functionality of the API @p chVTGetSystemTimeX() is tested.
* *
* <h2>Conditions</h2>
* None.
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - A System Tick Counter increment is expected, the test simply hangs if * - A System Tick Counter increment is expected, the test simply hangs
* it does not happen. * if it does not happen.
* . * .
*/ */
static void test_001_001_execute(void) { static void test_001_001_execute(void) {
systime_t time;
/* A System Tick Counter increment is expected, the test simply hangs if /* A System Tick Counter increment is expected, the test simply hangs
it does not happen.*/ if it does not happen.*/
test_set_step(1); test_set_step(1);
{ {
time = chVTGetSystemTimeX(); systime_t time = chVTGetSystemTimeX();
while (time == chVTGetSystemTimeX()) { while (time == chVTGetSystemTimeX()) {
} }
} }
@ -76,35 +73,32 @@ static const testcase_t test_001_001 = {
NULL, NULL,
test_001_001_execute test_001_001_execute
}; };
#endif /* TRUE */
#if TRUE || defined(__DOXYGEN__)
/** /**
* @page test_001_002 Thread Sleep functionality * @page test_001_002 Thread Sleep functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* The functionality of the API @p chThdSleep() and derivatives is tested. * The functionality of @p chThdSleep() and derivatives is tested.
*
* <h2>Conditions</h2>
* None.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - The current system time is read then a sleep is performed for 100 system * - The current system time is read then a sleep is performed for 100
* ticks and on exit the system time is verified again. * system ticks and on exit the system time is verified again.
* - The current system time is read then a sleep is performed for 100000 * - The current system time is read then a sleep is performed for
* microseconds and on exit the system time is verified again. * 100000 microseconds and on exit the system time is verified again.
* - The current system time is read then a sleep is performed for 100 * - The current system time is read then a sleep is performed for 100
* milliseconds and on exit the system time is verified again. * milliseconds and on exit the system time is verified again.
* - The current system time is read then a sleep is performed for 1 * - The current system time is read then a sleep is performed for 1
* second and on exit the system time is verified again. * second and on exit the system time is verified again.
* - Function chThdSleepUntil() is tested with a timeline of "now" +
* 100 ticks.
* . * .
*/ */
static void test_001_002_execute(void) { static void test_001_002_execute(void) {
systime_t time; systime_t time;
/* The current system time is read then a sleep is performed for 100 system /* The current system time is read then a sleep is performed for 100
ticks and on exit the system time is verified again.*/ system ticks and on exit the system time is verified again.*/
test_set_step(1); test_set_step(1);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
@ -114,14 +108,15 @@ static void test_001_002_execute(void) {
"out of time window"); "out of time window");
} }
/* The current system time is read then a sleep is performed for 100000 /* The current system time is read then a sleep is performed for
microseconds and on exit the system time is verified again.*/ 100000 microseconds and on exit the system time is verified
again.*/
test_set_step(2); test_set_step(2);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
chThdSleepMicroseconds(100); chThdSleepMicroseconds(100000);
test_assert_time_window(time + US2ST(100), test_assert_time_window(time + US2ST(100000),
time + US2ST(100) + 1, time + US2ST(100000) + 1,
"out of time window"); "out of time window");
} }
@ -147,6 +142,8 @@ static void test_001_002_execute(void) {
"out of time window"); "out of time window");
} }
/* Function chThdSleepUntil() is tested with a timeline of "now" +
100 ticks.*/
test_set_step(5); test_set_step(5);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
@ -163,21 +160,16 @@ static const testcase_t test_001_002 = {
NULL, NULL,
test_001_002_execute test_001_002_execute
}; };
#endif /* TRUE */
/**************************************************************************** /****************************************************************************
* Exported data. * Exported data.
****************************************************************************/ ****************************************************************************/
/** /**
* @brief Sequence brief description. * @brief Threads Functionality.
*/ */
const testcase_t * const test_sequence_001[] = { const testcase_t * const test_sequence_001[] = {
#if TRUE || defined(__DOXYGEN__)
&test_001_001, &test_001_001,
#endif
#if TRUE || defined(__DOXYGEN__)
&test_001_002, &test_001_002,
#endif
NULL NULL
}; };

View File

@ -14,9 +14,4 @@
limitations under the License. limitations under the License.
*/ */
#ifndef _TEST_SEQUENCE_001_H_
#define _TEST_SEQUENCE_001_H_
extern const testcase_t * const test_sequence_001[]; extern const testcase_t * const test_sequence_001[];
#endif /* _TEST_SEQUENCE_001_H_ */

View File

@ -0,0 +1,244 @@
/*
ChibiOS - Copyright (C) 2006..2015 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"
/**
* @page test_sequence_002 Semaphores
*
* File: @ref test_sequence_002.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* counter semaphores.
*
* <h2>Test Cases</h2>
* - @subpage test_002_001
* - @subpage test_002_002
* - @subpage test_002_003
* .
*/
/****************************************************************************
* Shared code.
****************************************************************************/
#include "ch.h"
static semaphore_t sem1;
/****************************************************************************
* Test cases.
****************************************************************************/
/**
* @page test_002_001 Semaphore primitives, no state change
*
* <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread
* does not trigger a state change.
*
* <h2>Test Steps</h2>
* - The function chSemWait() is invoked, after return the counter and
* the returned message are tested.
* - The function chSemSignal() is invoked, after return the counter is
* tested.
* - The function chSemReset() is invoked, after return the counter is
* tested.
* .
*/
static void test_002_001_setup(void) {
chSemObjectInit(&sem1, 1);
}
static void test_002_001_teardown(void) {
chSemReset(&sem1, 0);
}
static void test_002_001_execute(void) {
/* The function chSemWait() is invoked, after return the counter and
the returned message are tested.*/
test_set_step(1);
{
msg_t msg;
msg = chSemWait(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_OK == msg, "wrong returned message");
}
/* The function chSemSignal() is invoked, after return the counter is
tested.*/
test_set_step(2);
{
chSemSignal(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");
}
/* The function chSemReset() is invoked, after return the counter is
tested.*/
test_set_step(3);
{
chSemReset(&sem1, 2);
test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");
}
}
static const testcase_t test_002_001 = {
"Semaphore primitives, no state change",
test_002_001_setup,
test_002_001_teardown,
test_002_001_execute
};
/**
* @page test_002_002 Semaphore primitives, with state change
*
* <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread
* triggers a state change.
*
* <h2>Test Steps</h2>
* - The function chSemWait() is invoked, after return the counter and
* the returned message are tested. The semaphore is signaled by
* another thread.
* - The function chSemWait() is invoked, after return the counter and
* the returned message are tested. The semaphore is reset by another
* thread.
* .
*/
static void test_002_002_setup(void) {
chSemObjectInit(&gsem1, 0);
}
static void test_002_002_teardown(void) {
chSemReset(&gsem1, 0);
}
static void test_002_002_execute(void) {
/* The function chSemWait() is invoked, after return the counter and
the returned message are tested. The semaphore is signaled by
another thread.*/
test_set_step(1);
{
msg_t msg;
msg = chSemWait(&gsem1);
test_assert_lock(chSemGetCounterI(&gsem1) == 0, "wrong counter value");
test_assert(MSG_OK == msg, "wrong returned message");
}
/* The function chSemWait() is invoked, after return the counter and
the returned message are tested. The semaphore is reset by another
thread.*/
test_set_step(2);
{
msg_t msg;
msg = chSemWait(&gsem2);
test_assert_lock(chSemGetCounterI(&gsem2) == 0,"wrong counter value");
test_assert(MSG_RESET == msg, "wrong returned message");
}
}
static const testcase_t test_002_002 = {
"Semaphore primitives, with state change",
test_002_002_setup,
test_002_002_teardown,
test_002_002_execute
};
/**
* @page test_002_003 Semaphores timeout
*
* <h2>Description</h2>
* Timeout on semaphores is tested.
*
* <h2>Test Steps</h2>
* - The function chSemWaitTimeout() is invoked a first time, after
* return the system time, the counter and the returned message are
* tested.
* - The function chSemWaitTimeout() is invoked again, after return the
* system time, the counter and the returned message are tested.
* .
*/
static void test_002_003_setup(void) {
chSemObjectInit(&sem1, 0);
}
static void test_002_003_teardown(void) {
chSemReset(&sem1, 0);
}
static void test_002_003_execute(void) {
systime_t time;
msg_t msg;
/* The function chSemWaitTimeout() is invoked a first time, after
return the system time, the counter and the returned message are
tested.*/
test_set_step(1);
{
time = chVTGetSystemTimeX();
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
}
/* The function chSemWaitTimeout() is invoked again, after return the
system time, the counter and the returned message are tested.*/
test_set_step(2);
{
time = chVTGetSystemTimeX();
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(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_002_003 = {
"Semaphores timeout",
test_002_003_setup,
test_002_003_teardown,
test_002_003_execute
};
/****************************************************************************
* Exported data.
****************************************************************************/
/**
* @brief Semaphores.
*/
const testcase_t * const test_sequence_002[] = {
&test_002_001,
&test_002_002,
&test_002_003,
NULL
};

View File

@ -14,9 +14,4 @@
limitations under the License. limitations under the License.
*/ */
#ifndef _TEST_SEQUENCE_002_H_
#define _TEST_SEQUENCE_002_H_
extern const testcase_t * const test_sequence_002[]; extern const testcase_t * const test_sequence_002[];
#endif /* _TEST_SEQUENCE_002_H_ */

View File

@ -0,0 +1,186 @@
/*
ChibiOS - Copyright (C) 2006..2015 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"
/**
* @page test_sequence_003 Suspend/Resume and Event Flags
*
* File: @ref test_sequence_003.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_003_001
* - @subpage test_003_002
* .
*/
/****************************************************************************
* Shared code.
****************************************************************************/
static thread_reference_t tr1;
/****************************************************************************
* Test cases.
****************************************************************************/
/**
* @page test_003_001 Suspend and Resume functionality
*
* <h2>Description</h2>
* The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
* tested.
*
* <h2>Test Steps</h2>
* - The function chThdSuspendTimeoutS() is invoked, the thread is
* remotely resumed with message @p MSG_OK. On return the message and
* the state of the reference are tested.
* - The function chThdSuspendTimeoutS() is invoked, the thread is not
* resumed so a timeout must occur. On return the message and the
* state of the reference are tested.
* .
*/
static void test_003_001_setup(void) {
tr1 = NULL;
}
static void test_003_001_execute(void) {
systime_t time;
msg_t msg;
/* The function chThdSuspendTimeoutS() is invoked, the thread is
remotely resumed with message @p MSG_OK. On return the message and
the state of the reference are tested.*/
test_set_step(1);
{
chSysLock();
msg = chThdSuspendTimeoutS(&gtr1, TIME_INFINITE);
chSysUnlock();
test_assert(NULL == gtr1, "not NULL");
test_assert(MSG_OK == msg,"wrong returned message");
}
/* The function chThdSuspendTimeoutS() is invoked, the thread is not
resumed so a timeout must occur. On return the message and the
state of the reference are tested.*/
test_set_step(2);
{
chSysLock();
time = chVTGetSystemTimeX();
msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
chSysUnlock();
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(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_003_001 = {
"Suspend and Resume functionality",
test_003_001_setup,
NULL,
test_003_001_execute
};
/**
* @page test_003_002 Events Flags functionality
*
* <h2>Description</h2>
* Event flags functionality is tested.
*
* <h2>Test Steps</h2>
* - A set of event flags are set on the current thread then the
* function chEvtWaitAnyTimeout() is invoked, the function is
* supposed to return immediately because the event flags are already
* pending, after return the events mask is tested.
* - The pending event flags mask is cleared then the function
* chEvtWaitAnyTimeout() is invoked, after return the events mask is
* tested. The thread is signaled by another thread.
* - The function chEvtWaitAnyTimeout() is invoked, no event can wakeup
* the thread, the function must return because timeout.
* .
*/
static void test_003_002_execute(void) {
systime_t time;
eventmask_t events;
/* A set of event flags are set on the current thread then the
function chEvtWaitAnyTimeout() is invoked, the function is
supposed to return immediately because the event flags are already
pending, after return the events mask is tested.*/
test_set_step(1);
{
time = chVTGetSystemTimeX();
chEvtSignal(chThdGetSelfX(), 0x55);
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");
}
/* The pending event flags mask is cleared then the function
chEvtWaitAnyTimeout() is invoked, after return the events mask is
tested. The thread is signaled by another thread.*/
test_set_step(2);
{
time = chVTGetSystemTimeX();
chThdGetSelfX()->epmask = 0;
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");
}
/* The function chEvtWaitAnyTimeout() is invoked, no event can wakeup
the thread, the function must return because timeout.*/
test_set_step(3);
{
time = chVTGetSystemTimeX();
events = chEvtWaitAnyTimeout(0, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
"out of time window");
test_assert((eventmask_t)0 == events, "wrong events mask");
}
}
static const testcase_t test_003_002 = {
"Events Flags functionality",
NULL,
NULL,
test_003_002_execute
};
/****************************************************************************
* Exported data.
****************************************************************************/
/**
* @brief Suspend/Resume and Event Flags.
*/
const testcase_t * const test_sequence_003[] = {
&test_003_001,
&test_003_002,
NULL
};

View File

@ -0,0 +1,17 @@
/*
ChibiOS - Copyright (C) 2006..2015 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.
*/
extern const testcase_t * const test_sequence_003[];

2411
test/nil/specgen/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
del html\*.* /Q
Doxygen Doxyfile
del html\*.md5
del html\*.map
pause

View File

@ -0,0 +1,800 @@
/* The standard CSS for doxygen */
body, table, div, p, dl {
font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif;
font-size: 12px;
}
/* @group Heading Levels */
h1 {
font-size: 150%;
}
h2 {
font-size: 120%;
}
h3 {
font-size: 100%;
}
dt {
font-weight: bold;
}
div.multicol {
-moz-column-gap: 1em;
-webkit-column-gap: 1em;
-moz-column-count: 3;
-webkit-column-count: 3;
}
p.startli, p.startdd, p.starttd {
margin-top: 2px;
}
p.endli {
margin-bottom: 0px;
}
p.enddd {
margin-bottom: 4px;
}
p.endtd {
margin-bottom: 2px;
}
/* @end */
caption {
font-weight: bold;
}
span.legend {
font-size: 70%;
text-align: center;
}
h3.version {
font-size: 90%;
text-align: center;
}
div.qindex, div.navtab{
background-color: #EBEFF6;
border: 1px solid #A3B4D7;
text-align: center;
margin: 2px;
padding: 2px;
}
div.qindex, div.navpath {
width: 100%;
line-height: 140%;
}
div.navtab {
margin-right: 15px;
}
/* @group Link Styling */
a {
color: #3D578C;
font-weight: normal;
text-decoration: none;
}
.contents a:visited {
color: #4665A2;
}
a:hover {
text-decoration: underline;
}
a.qindex {
font-weight: bold;
}
a.qindexHL {
font-weight: bold;
background-color: #9CAFD4;
color: #ffffff;
border: 1px double #869DCA;
}
.contents a.qindexHL:visited {
color: #ffffff;
}
a.el {
font-weight: bold;
}
a.elRef {
}
a.code {
color: #4665A2;
}
a.codeRef {
color: #4665A2;
}
/* @end */
dl.el {
margin-left: -1cm;
}
.fragment {
font-family: monospace, fixed;
font-size: 105%;
}
pre.fragment {
border: 1px solid #C4CFE5;
background-color: #FBFCFD;
padding: 4px 6px;
margin: 4px 8px 4px 2px;
overflow: auto;
word-wrap: break-word;
font-size: 9pt;
line-height: 125%;
}
div.ah {
background-color: black;
font-weight: bold;
color: #ffffff;
margin-bottom: 3px;
margin-top: 3px;
padding: 0.2em;
border: solid thin #333;
border-radius: 0.5em;
-webkit-border-radius: .5em;
-moz-border-radius: .5em;
box-shadow: 2px 2px 3px #999;
-webkit-box-shadow: 2px 2px 3px #999;
-moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px;
background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444));
background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000);
}
div.groupHeader {
margin-left: 16px;
margin-top: 12px;
font-weight: bold;
}
div.groupText {
margin-left: 16px;
font-style: italic;
}
body {
background: white;
color: black;
margin: 0;
}
div.contents {
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
}
td.indexkey {
background-color: #EBEFF6;
font-weight: bold;
border: 1px solid #C4CFE5;
margin: 2px 0px 2px 0;
padding: 2px 10px;
}
td.indexvalue {
background-color: #EBEFF6;
border: 1px solid #C4CFE5;
padding: 2px 10px;
margin: 2px 0px;
}
tr.memlist {
background-color: #EEF1F7;
}
p.formulaDsp {
text-align: center;
}
img.formulaDsp {
}
img.formulaInl {
vertical-align: middle;
}
div.center {
text-align: center;
margin-top: 0px;
margin-bottom: 0px;
padding: 0px;
}
div.center img {
border: 0px;
}
address.footer {
text-align: right;
padding-right: 12px;
}
img.footer {
border: 0px;
vertical-align: middle;
}
/* @group Code Colorization */
span.keyword {
color: #008000
}
span.keywordtype {
color: #604020
}
span.keywordflow {
color: #e08000
}
span.comment {
color: #800000
}
span.preprocessor {
color: #806020
}
span.stringliteral {
color: #002080
}
span.charliteral {
color: #008080
}
span.vhdldigit {
color: #ff00ff
}
span.vhdlchar {
color: #000000
}
span.vhdlkeyword {
color: #700070
}
span.vhdllogic {
color: #ff0000
}
/* @end */
/*
.search {
color: #003399;
font-weight: bold;
}
form.search {
margin-bottom: 0px;
margin-top: 0px;
}
input.search {
font-size: 75%;
color: #000080;
font-weight: normal;
background-color: #e8eef2;
}
*/
td.tiny {
font-size: 75%;
}
.dirtab {
padding: 4px;
border-collapse: collapse;
border: 1px solid #A3B4D7;
}
th.dirtab {
background: #EBEFF6;
font-weight: bold;
}
hr {
height: 0px;
border: none;
border-top: 1px solid #4A6AAA;
}
hr.footer {
height: 1px;
}
/* @group Member Descriptions */
table.memberdecls {
border-spacing: 0px;
padding: 0px;
}
.mdescLeft, .mdescRight,
.memItemLeft, .memItemRight,
.memTemplItemLeft, .memTemplItemRight, .memTemplParams {
background-color: #F9FAFC;
border: none;
margin: 4px;
padding: 1px 0 0 8px;
}
.mdescLeft, .mdescRight {
padding: 0px 8px 4px 8px;
color: #555;
}
.memItemLeft, .memItemRight, .memTemplParams {
border-top: 1px solid #C4CFE5;
}
.memItemLeft, .memTemplItemLeft {
white-space: nowrap;
}
.memTemplParams {
color: #4665A2;
white-space: nowrap;
}
/* @end */
/* @group Member Details */
/* Styles for detailed member documentation */
.memtemplate {
font-size: 80%;
color: #4665A2;
font-weight: normal;
margin-left: 9px;
}
.memnav {
background-color: #EBEFF6;
border: 1px solid #A3B4D7;
text-align: center;
margin: 2px;
margin-right: 15px;
padding: 2px;
}
.memitem {
padding: 0;
margin-bottom: 10px;
}
.memname {
white-space: nowrap;
font-weight: bold;
margin-left: 6px;
}
.memproto {
border-top: 1px solid #A8B8D9;
border-left: 1px solid #A8B8D9;
border-right: 1px solid #A8B8D9;
padding: 6px 0px 6px 0px;
color: #253555;
font-weight: bold;
text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9);
/* opera specific markup */
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
border-top-right-radius: 8px;
border-top-left-radius: 8px;
/* firefox specific markup */
-moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px;
-moz-border-radius-topright: 8px;
-moz-border-radius-topleft: 8px;
/* webkit specific markup */
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
-webkit-border-top-right-radius: 8px;
-webkit-border-top-left-radius: 8px;
background-image:url('nav_f.png');
background-repeat:repeat-x;
background-color: #E2E8F2;
}
.memdoc {
border-bottom: 1px solid #A8B8D9;
border-left: 1px solid #A8B8D9;
border-right: 1px solid #A8B8D9;
padding: 2px 5px;
background-color: #FBFCFD;
border-top-width: 0;
/* opera specific markup */
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
/* firefox specific markup */
-moz-border-radius-bottomleft: 8px;
-moz-border-radius-bottomright: 8px;
-moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px;
background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7F8FB 95%, #EEF1F7);
/* webkit specific markup */
-webkit-border-bottom-left-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7F8FB), to(#EEF1F7));
}
.paramkey {
text-align: right;
}
.paramtype {
white-space: nowrap;
}
.paramname {
color: #602020;
white-space: nowrap;
}
.paramname em {
font-style: normal;
}
.params, .retval, .exception, .tparams {
border-spacing: 6px 2px;
}
.params .paramname, .retval .paramname {
font-weight: bold;
vertical-align: top;
}
.params .paramtype {
font-style: italic;
vertical-align: top;
}
.params .paramdir {
font-family: "courier new",courier,monospace;
vertical-align: top;
}
/* @end */
/* @group Directory (tree) */
/* for the tree view */
.ftvtree {
font-family: sans-serif;
margin: 0px;
}
/* these are for tree view when used as main index */
.directory {
font-size: 9pt;
font-weight: bold;
margin: 5px;
}
.directory h3 {
margin: 0px;
margin-top: 1em;
font-size: 11pt;
}
/*
The following two styles can be used to replace the root node title
with an image of your choice. Simply uncomment the next two styles,
specify the name of your image and be sure to set 'height' to the
proper pixel height of your image.
*/
/*
.directory h3.swap {
height: 61px;
background-repeat: no-repeat;
background-image: url("yourimage.gif");
}
.directory h3.swap span {
display: none;
}
*/
.directory > h3 {
margin-top: 0;
}
.directory p {
margin: 0px;
white-space: nowrap;
}
.directory div {
display: none;
margin: 0px;
}
.directory img {
vertical-align: -30%;
}
/* these are for tree view when not used as main index */
.directory-alt {
font-size: 100%;
font-weight: bold;
}
.directory-alt h3 {
margin: 0px;
margin-top: 1em;
font-size: 11pt;
}
.directory-alt > h3 {
margin-top: 0;
}
.directory-alt p {
margin: 0px;
white-space: nowrap;
}
.directory-alt div {
display: none;
margin: 0px;
}
.directory-alt img {
vertical-align: -30%;
}
/* @end */
div.dynheader {
margin-top: 8px;
}
address {
font-style: normal;
color: #2A3D61;
}
table.doxtable {
border-collapse:collapse;
}
table.doxtable td, table.doxtable th {
border: 1px solid #2D4068;
padding: 3px 7px 2px;
}
table.doxtable th {
background-color: #374F7F;
color: #FFFFFF;
font-size: 110%;
padding-bottom: 4px;
padding-top: 5px;
text-align:left;
}
.tabsearch {
top: 0px;
left: 10px;
height: 36px;
background-image: url('tab_b.png');
z-index: 101;
overflow: hidden;
font-size: 13px;
}
.navpath ul
{
font-size: 11px;
background-image:url('tab_b.png');
background-repeat:repeat-x;
height:30px;
line-height:30px;
color:#8AA0CC;
border:solid 1px #C2CDE4;
overflow:hidden;
margin:0px;
padding:0px;
}
.navpath li
{
list-style-type:none;
float:left;
padding-left:10px;
padding-right:15px;
background-image:url('bc_s.png');
background-repeat:no-repeat;
background-position:right;
color:#364D7C;
}
.navpath li.navelem a
{
height:32px;
display:block;
text-decoration: none;
outline: none;
}
.navpath li.navelem a:hover
{
color:#6884BD;
}
.navpath li.footer
{
list-style-type:none;
float:right;
padding-left:10px;
padding-right:15px;
background-image:none;
background-repeat:no-repeat;
background-position:right;
color:#364D7C;
font-size: 8pt;
}
div.summary
{
float: right;
font-size: 8pt;
padding-right: 5px;
width: 50%;
text-align: right;
}
div.summary a
{
white-space: nowrap;
}
div.ingroups
{
font-size: 8pt;
padding-left: 5px;
width: 50%;
text-align: left;
}
div.ingroups a
{
white-space: nowrap;
}
div.header
{
background-image:url('nav_h.png');
background-repeat:repeat-x;
background-color: #F9FAFC;
margin: 0px;
border-bottom: 1px solid #C4CFE5;
}
div.headertitle
{
padding: 5px 5px 5px 10px;
}
dl
{
padding: 0 0 0 10px;
}
dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug
{
border-left:4px solid;
padding: 0 0 0 6px;
}
dl.note
{
border-color: #D0D000;
}
dl.warning, dl.attention
{
border-color: #FF0000;
}
dl.pre, dl.post, dl.invariant
{
border-color: #00D000;
}
dl.deprecated
{
border-color: #505050;
}
dl.todo
{
border-color: #00C0E0;
}
dl.test
{
border-color: #3030E0;
}
dl.bug
{
border-color: #C08050;
}
#projectlogo
{
text-align: center;
vertical-align: bottom;
border-collapse: separate;
}
#projectlogo img
{
border: 0px none;
}
#projectname
{
font: 300% arial,sans-serif;
margin: 0px;
padding: 0px;
}
#projectbrief
{
font: 120% arial,sans-serif;
margin: 0px;
padding: 0px;
}
#projectnumber
{
font: 50% arial,sans-serif;
margin: 0px;
padding: 0px;
}
#titlearea
{
padding: 0px;
margin: 0px;
width: 100%;
border-bottom: 1px solid #5373B4;
}

View File

@ -0,0 +1,4 @@
<hr class="footer"/><address class="footer"><small>
Generated on $datetime for $projectname by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="$relpath$doxygen.png" alt="doxygen"/></a> $doxygenversion</small></address>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>$title</title>
<link href="$relpath$tabs.css" rel="stylesheet" type="text/css"/>
<link href="$relpath$doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">ChibiOS/NIL&#160;<span id="projectnumber">$projectnumber</span></div>
</td>
</tr>
</tbody>
</table>
</div>

View File

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

View File

@ -1,437 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2015 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"
/**
* @page test_sequence_002 Synchronization primitives
*
* File: @ref test_sequence_002.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* threads synchronization.
*
* <h2>Test Cases</h2>
* - @subpage test_002_001
* - @subpage test_002_002
* .
*/
/****************************************************************************
* Shared code.
****************************************************************************/
static semaphore_t sem1;
static thread_reference_t tr1;
/****************************************************************************
* Test cases.
****************************************************************************/
#if TRUE || defined(__DOXYGEN__)
/**
* @page test_002_001 Semaphore primitives, no state change
*
* <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread does not
* trigger a state change.
*
* <h2>Conditions</h2>
* None.
*
* <h2>Test Steps</h2>
* - The function chSemWait() is invoked, after return the counter and
* the returned message are tested.
* - The function chSemSignal() is invoked, after return the counter
* is tested.
* - The function chSemReset() is invoked, after return the counter
* is tested.
* .
*/
static void test_002_001_setup(void) {
chSemObjectInit(&sem1, 1);
}
static void test_002_001_teardown(void) {
chSemReset(&sem1, 0);
}
static void test_002_001_execute(void) {
/* The function chSemWait() is invoked, after return the counter and
the returned message are tested.*/
test_set_step(1);
{
msg_t msg;
msg = chSemWait(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 0,
"wrong counter value");
test_assert(MSG_OK == msg,
"wrong returned message");
}
/* The function chSemSignal() is invoked, after return the counter
is tested.*/
test_set_step(2);
{
chSemSignal(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 1,
"wrong counter value");
}
/* The function chSemReset() is invoked, after return the counter
is tested.*/
test_set_step(3);
{
chSemReset(&sem1, 2);
test_assert_lock(chSemGetCounterI(&sem1) == 2,
"wrong counter value");
}
}
static const testcase_t test_002_001 = {
"semaphore primitives, no state change",
test_002_001_setup,
test_002_001_teardown,
test_002_001_execute
};
#endif /* TRUE */
#if TRUE || defined(__DOXYGEN__)
/**
* @page test_002_002 Semaphore primitives, with state change
*
* <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread
* triggers a state change.
*
* <h2>Conditions</h2>
* None.
*
* <h2>Test Steps</h2>
* - The function chSemWait() is invoked, after return the counter and
* the returned message are tested. The semaphore is signaled by another
* thread.
* - The function chSemWait() is invoked, after return the counter and
* the returned message are tested. The semaphore is reset by another
* thread.
* .
*/
static void test_002_002_setup(void) {
chSemObjectInit(&sem1, 0);
}
static void test_002_002_teardown(void) {
chSemReset(&sem1, 0);
}
static void test_002_002_execute(void) {
/* The function chSemWait() is invoked, after return the counter and
the returned message are tested. The semaphore is signaled by another
thread.*/
test_set_step(1);
{
msg_t msg;
msg = chSemWait(&gsem1);
test_assert_lock(chSemGetCounterI(&gsem1) == 0,
"wrong counter value");
test_assert(MSG_OK == msg,
"wrong returned message");
}
/* The function chSemWait() is invoked, after return the counter and
the returned message are tested. The semaphore is reset by another
thread.*/
test_set_step(2);
{
msg_t msg;
msg = chSemWait(&gsem2);
test_assert_lock(chSemGetCounterI(&gsem2) == 0,
"wrong counter value");
test_assert(MSG_RESET == msg,
"wrong returned message");
}
}
static const testcase_t test_002_002 = {
"semaphore primitives, with state change",
test_002_002_setup,
test_002_002_teardown,
test_002_002_execute
};
#endif /* TRUE */
#if TRUE || defined(__DOXYGEN__)
/**
* @page test_002_003 Semaphores timeout
*
* <h2>Description</h2>
* Timeout on semaphores is tested.
*
* <h2>Conditions</h2>
* None.
*
* <h2>Test Steps</h2>
* - The function chSemWaitTimeout() is invoked, after return the system
* time, the counter and the returned message are tested.
* .
*/
static void test_002_003_setup(void) {
chSemObjectInit(&sem1, 0);
}
static void test_002_003_teardown(void) {
chSemReset(&sem1, 0);
}
static void test_002_003_execute(void) {
systime_t time;
msg_t msg;
/* The function chSemWaitTimeout() is invoked, after return the system
time, the counter and the returned message are tested.*/
test_set_step(1);
{
time = chVTGetSystemTimeX();
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0,
"wrong counter value");
test_assert(MSG_TIMEOUT == msg,
"wrong timeout message");
}
/* The function chSemWaitTimeout() is invoked, after return the system
time, the counter and the returned message are tested.*/
test_set_step(2);
{
time = chVTGetSystemTimeX();
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(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_002_003 = {
"semaphores timeout",
test_002_003_setup,
test_002_003_teardown,
test_002_003_execute
};
#endif /* TRUE */
#if TRUE || defined(__DOXYGEN__)
/**
* @page test_002_004 Suspend and Resume functionality
*
* <h2>Description</h2>
* The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
* tested.
*
* <h2>Conditions</h2>
* None.
*
* <h2>Test Steps</h2>
* - The function chThdSuspendTimeoutS() is invoked, the thread is
* remotely resumed with message @p MSG_OK. On return the message
* and the state of the reference are tested.
* - The function chThdSuspendTimeoutS() is invoked, the thread is
* not resumed so a timeout must occur. On return the message
* and the state of the reference are tested.
* .
*/
static void test_002_004_setup(void) {
tr1 = NULL;
}
static void test_002_004_execute(void) {
systime_t time;
msg_t msg;
/* The function chThdSuspendTimeoutS() is invoked, the thread is
remotely resumed with message @p MSG_OK. On return the message
and the state of the reference are tested.*/
test_set_step(1);
{
chSysLock();
msg = chThdSuspendTimeoutS(&gtr1, TIME_INFINITE);
chSysUnlock();
test_assert(NULL == gtr1,
"not NULL");
test_assert(MSG_OK == msg,
"wrong returned message");
}
/* The function chThdSuspendTimeoutS() is invoked, the thread is
not resumed so a timeout must occur. On return the message
and the state of the reference are tested.*/
test_set_step(2);
{
chSysLock();
time = chVTGetSystemTimeX();
msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
chSysUnlock();
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(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_002_004 = {
"suspend and resume functionality",
test_002_004_setup,
NULL,
test_002_004_execute
};
#endif /* TRUE */
#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
/**
* @page test_002_005 Events functionality
*
* <h2>Description</h2>
* Event flags functionality is tested.
*
* <h2>Conditions</h2>
* None.
*
* <h2>Test Steps</h2>
* - A set of event flags are set on the current thread then the
* function chVTGetSystemTimeX() is invoked, the function is supposed to
* return immediately because the event flags are already pending,
* after return the events mask is tested.
* - The pending event flags mask is cleared then the function
* chVTGetSystemTimeX() is invoked, after return the events
* mask is tested. The thread is signaled by another thread.
* -
* . The function chVTGetSystemTimeX() is invoked, no event can
* wakeup the thread, the function must return because timeout.
*/
static void test_002_005_setup(void) {
chSemObjectInit(&sem1, 0);
}
static void test_002_005_execute(void) {
systime_t time;
eventmask_t events;
/* A set of event flags are set on the current thread then the
function chVTGetSystemTimeX() is invoked, the function is supposed to
return immediately because the event flags are already pending,
after return the events mask is tested.*/
test_set_step(1);
{
time = chVTGetSystemTimeX();
chEvtSignal(chThdGetSelfX(), 0x55);
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
test_assert((eventmask_t)0 != events,
"timed out");
test_assert((eventmask_t)0x55 == events,
"wrong events mask");
}
/* The pending event flags mask is cleared then the function
chVTGetSystemTimeX() is invoked, after return the events
mask is tested. The thread is signaled by another thread.*/
test_set_step(2);
{
time = chVTGetSystemTimeX();
chThdGetSelfX()->epmask = 0;
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
test_assert((eventmask_t)0 != events,
"timed out");
test_assert((eventmask_t)0x55 == events,
"wrong events mask");
}
/* The function chVTGetSystemTimeX() is invoked, no event can
wakeup the thread, the function must return because timeout.*/
test_set_step(3);
{
time = chVTGetSystemTimeX();
events = chEvtWaitAnyTimeout(0, MS2ST(1000));
test_assert_time_window(time + MS2ST(1000),
time + MS2ST(1000) + 1,
"out of time window");
test_assert((eventmask_t)0 == events,
"wrong events mask");
}
}
static const testcase_t test_002_005 = {
"events functionality",
test_002_005_setup,
NULL,
test_002_005_execute
};
#endif /* CH_CFG_USE_EVENTS == TRUE */
/****************************************************************************
* Exported data.
****************************************************************************/
/**
* @brief Sequence brief description.
*/
const testcase_t * const test_sequence_002[] = {
#if TRUE || defined(__DOXYGEN__)
&test_002_001,
#endif
#if TRUE || defined(__DOXYGEN__)
&test_002_002,
#endif
#if TRUE || defined(__DOXYGEN__)
&test_002_003,
#endif
#if TRUE || defined(__DOXYGEN__)
&test_002_004,
#endif
#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
&test_002_005,
#endif
NULL
};