configuration.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <SPC5-Config version="1.0.0">
  3. <application name="ChibiOS/NIL Test Suite" version="1.0.0" standalone="true" locked="false">
  4. <description>Test Specification for ChibiOS/NIL.</description>
  5. <component id="org.chibios.spc5.components.portable.generic_startup">
  6. <component id="org.chibios.spc5.components.portable.chibios_unitary_tests_engine" />
  7. </component>
  8. <instances>
  9. <instance locked="false" id="org.chibios.spc5.components.portable.generic_startup" />
  10. <instance locked="false" id="org.chibios.spc5.components.portable.chibios_unitary_tests_engine">
  11. <description>
  12. <brief>
  13. <value>ChibiOS/NIL Test Suite.</value>
  14. </brief>
  15. <copyright>
  16. <value><![CDATA[/*
  17. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  18. Licensed under the Apache License, Version 2.0 (the "License");
  19. you may not use this file except in compliance with the License.
  20. You may obtain a copy of the License at
  21. http://www.apache.org/licenses/LICENSE-2.0
  22. Unless required by applicable law or agreed to in writing, software
  23. distributed under the License is distributed on an "AS IS" BASIS,
  24. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. See the License for the specific language governing permissions and
  26. limitations under the License.
  27. */]]></value>
  28. </copyright>
  29. <introduction>
  30. <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>
  31. </introduction>
  32. </description>
  33. <global_data_and_code>
  34. <code_prefix>
  35. <value>nil_</value>
  36. </code_prefix>
  37. <global_definitions>
  38. <value><![CDATA[#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
  39. extern semaphore_t gsem1, gsem2;
  40. extern thread_reference_t gtr1;
  41. extern THD_WORKING_AREA(wa_test_support, 128);
  42. void test_print_port_info(void);
  43. THD_FUNCTION(test_support, arg);]]></value>
  44. </global_definitions>
  45. <global_code>
  46. <value><![CDATA[semaphore_t gsem1, gsem2;
  47. thread_reference_t gtr1;
  48. /*
  49. * Support thread.
  50. */
  51. THD_WORKING_AREA(wa_test_support, 128);
  52. THD_FUNCTION(test_support, arg) {
  53. #if CH_CFG_USE_EVENTS == TRUE
  54. thread_t *tp = (thread_t *)arg;
  55. #else
  56. (void)arg;
  57. #endif
  58. /* Initializing global resources.*/
  59. chSemObjectInit(&gsem1, 0);
  60. chSemObjectInit(&gsem2, 0);
  61. while (true) {
  62. chSysLock();
  63. if (chSemGetCounterI(&gsem1) < 0)
  64. chSemSignalI(&gsem1);
  65. chSemResetI(&gsem2, 0);
  66. chThdResumeI(&gtr1, MSG_OK);
  67. #if CH_CFG_USE_EVENTS == TRUE
  68. chEvtSignalI(tp, 0x55);
  69. #endif
  70. chSchRescheduleS();
  71. chSysUnlock();
  72. chThdSleepMilliseconds(250);
  73. }
  74. }]]></value>
  75. </global_code>
  76. </global_data_and_code>
  77. <sequences>
  78. <sequence>
  79. <type index="0">
  80. <value>Internal Tests</value>
  81. </type>
  82. <brief>
  83. <value>Information.</value>
  84. </brief>
  85. <description>
  86. <value>This sequence reports configuration and version information about the NIL kernel.</value>
  87. </description>
  88. <condition>
  89. <value />
  90. </condition>
  91. <shared_code>
  92. <value><![CDATA[#include "ch.h"]]></value>
  93. </shared_code>
  94. <cases>
  95. <case>
  96. <brief>
  97. <value>Port Info.</value>
  98. </brief>
  99. <description>
  100. <value>Port-related info are reported.</value>
  101. </description>
  102. <condition>
  103. <value />
  104. </condition>
  105. <various_code>
  106. <setup_code>
  107. <value />
  108. </setup_code>
  109. <teardown_code>
  110. <value />
  111. </teardown_code>
  112. <local_variables>
  113. <value />
  114. </local_variables>
  115. </various_code>
  116. <steps>
  117. <step>
  118. <description>
  119. <value>Prints the version string.</value>
  120. </description>
  121. <tags>
  122. <value />
  123. </tags>
  124. <code>
  125. <value><![CDATA[#if defined(PORT_ARCHITECTURE_NAME)
  126. test_print("--- Architecture: ");
  127. test_println(PORT_ARCHITECTURE_NAME);
  128. #endif
  129. #if defined(PORT_CORE_VARIANT_NAME)
  130. test_print("--- Core Variant: ");
  131. test_println(PORT_CORE_VARIANT_NAME);
  132. #endif
  133. #if defined(PORT_COMPILER_NAME)
  134. test_print("--- Compiler: ");
  135. test_println(PORT_COMPILER_NAME);
  136. #endif
  137. #if defined(PORT_INFO)
  138. test_print("--- Port Info: ");
  139. test_println(PORT_INFO);
  140. #endif
  141. #if defined(PORT_NATURAL_ALIGN)
  142. test_print("--- Natural alignment: ");
  143. test_printn(PORT_NATURAL_ALIGN);
  144. test_println("");
  145. #endif
  146. #if defined(PORT_STACK_ALIGN)
  147. test_print("--- Stack alignment: ");
  148. test_printn(PORT_STACK_ALIGN);
  149. test_println("");
  150. #endif
  151. #if defined(PORT_WORKING_AREA_ALIGN)
  152. test_print("--- Working area alignment: ");
  153. test_printn(PORT_WORKING_AREA_ALIGN);
  154. test_println("");
  155. #endif]]></value>
  156. </code>
  157. </step>
  158. </steps>
  159. </case>
  160. <case>
  161. <brief>
  162. <value>Kernel Info.</value>
  163. </brief>
  164. <description>
  165. <value>The version numbers are reported.</value>
  166. </description>
  167. <condition>
  168. <value />
  169. </condition>
  170. <various_code>
  171. <setup_code>
  172. <value />
  173. </setup_code>
  174. <teardown_code>
  175. <value />
  176. </teardown_code>
  177. <local_variables>
  178. <value />
  179. </local_variables>
  180. </various_code>
  181. <steps>
  182. <step>
  183. <description>
  184. <value>Prints the version string.</value>
  185. </description>
  186. <tags>
  187. <value />
  188. </tags>
  189. <code>
  190. <value><![CDATA[test_println("--- Product: ChibiOS/NIL");
  191. test_print("--- Stable Flag: ");
  192. test_printn(CH_KERNEL_STABLE);
  193. test_println("");
  194. test_print("--- Version String: ");
  195. test_println(CH_KERNEL_VERSION);
  196. test_print("--- Major Number: ");
  197. test_printn(CH_KERNEL_MAJOR);
  198. test_println("");
  199. test_print("--- Minor Number: ");
  200. test_printn(CH_KERNEL_MINOR);
  201. test_println("");
  202. test_print("--- Patch Number: ");
  203. test_printn(CH_KERNEL_PATCH);
  204. test_println("");]]></value>
  205. </code>
  206. </step>
  207. </steps>
  208. </case>
  209. <case>
  210. <brief>
  211. <value>Kernel Settings.</value>
  212. </brief>
  213. <description>
  214. <value>The static kernel settings are reported.</value>
  215. </description>
  216. <condition>
  217. <value />
  218. </condition>
  219. <various_code>
  220. <setup_code>
  221. <value />
  222. </setup_code>
  223. <teardown_code>
  224. <value />
  225. </teardown_code>
  226. <local_variables>
  227. <value />
  228. </local_variables>
  229. </various_code>
  230. <steps>
  231. <step>
  232. <description>
  233. <value>Prints the configuration options settings.</value>
  234. </description>
  235. <tags>
  236. <value />
  237. </tags>
  238. <code>
  239. <value><![CDATA[test_print("--- CH_CFG_NUM_THREADS: ");
  240. test_printn(CH_CFG_NUM_THREADS);
  241. test_println("");
  242. test_print("--- CH_CFG_ST_RESOLUTION: ");
  243. test_printn(CH_CFG_ST_RESOLUTION);
  244. test_println("");
  245. test_print("--- CH_CFG_ST_FREQUENCY: ");
  246. test_printn(CH_CFG_ST_FREQUENCY);
  247. test_println("");
  248. test_print("--- CH_CFG_ST_TIMEDELTA: ");
  249. test_printn(CH_CFG_ST_TIMEDELTA);
  250. test_println("");
  251. test_print("--- CH_CFG_USE_SEMAPHORES: ");
  252. test_printn(CH_CFG_USE_SEMAPHORES);
  253. test_println("");
  254. test_print("--- CH_CFG_USE_MUTEXES: ");
  255. test_printn(CH_CFG_USE_MUTEXES);
  256. test_println("");
  257. test_print("--- CH_CFG_USE_EVENTS: ");
  258. test_printn(CH_CFG_USE_EVENTS);
  259. test_println("");
  260. test_print("--- CH_CFG_USE_MAILBOXES: ");
  261. test_printn(CH_CFG_USE_MAILBOXES);
  262. test_println("");
  263. test_print("--- CH_CFG_USE_MEMCORE: ");
  264. test_printn(CH_CFG_USE_MEMCORE);
  265. test_println("");
  266. test_print("--- CH_CFG_USE_HEAP: ");
  267. test_printn(CH_CFG_USE_HEAP);
  268. test_println("");
  269. test_print("--- CH_CFG_USE_MEMPOOLS: ");
  270. test_printn(CH_CFG_USE_MEMPOOLS);
  271. test_println("");
  272. test_print("--- CH_CFG_USE_OBJ_FIFOS: ");
  273. test_printn(CH_CFG_USE_OBJ_FIFOS);
  274. test_println("");
  275. test_print("--- CH_CFG_MEMCORE_SIZE: ");
  276. test_printn(CH_CFG_MEMCORE_SIZE);
  277. test_println("");
  278. test_print("--- CH_CFG_USE_FACTORY: ");
  279. test_printn(CH_CFG_USE_FACTORY);
  280. test_println("");
  281. test_print("--- CH_CFG_FACTORY_MAX_NAMES_LENGTH: ");
  282. test_printn(CH_CFG_FACTORY_MAX_NAMES_LENGTH);
  283. test_println("");
  284. test_print("--- CH_CFG_FACTORY_OBJECTS_REGISTRY: ");
  285. test_printn(CH_CFG_FACTORY_OBJECTS_REGISTRY);
  286. test_println("");
  287. test_print("--- CH_CFG_FACTORY_GENERIC_BUFFERS: ");
  288. test_printn(CH_CFG_FACTORY_GENERIC_BUFFERS);
  289. test_println("");
  290. test_print("--- CH_CFG_FACTORY_SEMAPHORES: ");
  291. test_printn(CH_CFG_FACTORY_SEMAPHORES);
  292. test_println("");
  293. test_print("--- CH_CFG_FACTORY_MAILBOXES: ");
  294. test_printn(CH_CFG_FACTORY_MAILBOXES);
  295. test_println("");
  296. test_print("--- CH_CFG_FACTORY_OBJ_FIFOS: ");
  297. test_printn(CH_CFG_FACTORY_OBJ_FIFOS);
  298. test_println("");
  299. test_print("--- CH_DBG_STATISTICS: ");
  300. test_printn(CH_DBG_STATISTICS);
  301. test_println("");
  302. test_print("--- CH_DBG_SYSTEM_STATE_CHECK: ");
  303. test_printn(CH_DBG_SYSTEM_STATE_CHECK);
  304. test_println("");
  305. test_print("--- CH_DBG_ENABLE_CHECKS: ");
  306. test_printn(CH_DBG_ENABLE_CHECKS);
  307. test_println("");
  308. test_print("--- CH_DBG_ENABLE_ASSERTS: ");
  309. test_printn(CH_DBG_ENABLE_ASSERTS);
  310. test_println("");
  311. test_print("--- CH_DBG_ENABLE_STACK_CHECK: ");
  312. test_printn(CH_DBG_ENABLE_STACK_CHECK);
  313. test_println("");]]></value>
  314. </code>
  315. </step>
  316. </steps>
  317. </case>
  318. </cases>
  319. </sequence>
  320. <sequence>
  321. <type index="0">
  322. <value>Internal Tests</value>
  323. </type>
  324. <brief>
  325. <value>Threads Functionality.</value>
  326. </brief>
  327. <description>
  328. <value>This sequence tests the ChibiOS/NIL functionalities related to threading.</value>
  329. </description>
  330. <condition>
  331. <value />
  332. </condition>
  333. <shared_code>
  334. <value><![CDATA[#include "ch.h"]]></value>
  335. </shared_code>
  336. <cases>
  337. <case>
  338. <brief>
  339. <value>System Tick Counter functionality.</value>
  340. </brief>
  341. <description>
  342. <value>The functionality of the API @p chVTGetSystemTimeX() is tested.</value>
  343. </description>
  344. <condition>
  345. <value />
  346. </condition>
  347. <various_code>
  348. <setup_code>
  349. <value />
  350. </setup_code>
  351. <teardown_code>
  352. <value />
  353. </teardown_code>
  354. <local_variables>
  355. <value />
  356. </local_variables>
  357. </various_code>
  358. <steps>
  359. <step>
  360. <description>
  361. <value>A System Tick Counter increment is expected, the test simply hangs if it does not happen.</value>
  362. </description>
  363. <tags>
  364. <value />
  365. </tags>
  366. <code>
  367. <value><![CDATA[systime_t time = chVTGetSystemTimeX();
  368. while (time == chVTGetSystemTimeX()) {
  369. }]]></value>
  370. </code>
  371. </step>
  372. </steps>
  373. </case>
  374. <case>
  375. <brief>
  376. <value>Thread Sleep functionality.</value>
  377. </brief>
  378. <description>
  379. <value>The functionality of @p chThdSleep() and derivatives is tested.</value>
  380. </description>
  381. <condition>
  382. <value />
  383. </condition>
  384. <various_code>
  385. <setup_code>
  386. <value />
  387. </setup_code>
  388. <teardown_code>
  389. <value />
  390. </teardown_code>
  391. <local_variables>
  392. <value><![CDATA[systime_t time;]]></value>
  393. </local_variables>
  394. </various_code>
  395. <steps>
  396. <step>
  397. <description>
  398. <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>
  399. </description>
  400. <tags>
  401. <value />
  402. </tags>
  403. <code>
  404. <value><![CDATA[time = chVTGetSystemTimeX();
  405. chThdSleep(100);
  406. test_assert_time_window(chTimeAddX(time, 100),
  407. chTimeAddX(time, 100 + 1),
  408. "out of time window");]]></value>
  409. </code>
  410. </step>
  411. <step>
  412. <description>
  413. <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>
  414. </description>
  415. <tags>
  416. <value />
  417. </tags>
  418. <code>
  419. <value><![CDATA[time = chVTGetSystemTimeX();
  420. chThdSleepMicroseconds(100000);
  421. test_assert_time_window(chTimeAddX(time, TIME_US2I(100000)),
  422. chTimeAddX(time, TIME_US2I(100000) + 1),
  423. "out of time window");]]></value>
  424. </code>
  425. </step>
  426. <step>
  427. <description>
  428. <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>
  429. </description>
  430. <tags>
  431. <value />
  432. </tags>
  433. <code>
  434. <value><![CDATA[time = chVTGetSystemTimeX();
  435. chThdSleepMilliseconds(100);
  436. test_assert_time_window(chTimeAddX(time, TIME_MS2I(100)),
  437. chTimeAddX(time, TIME_MS2I(100) + 1),
  438. "out of time window");]]></value>
  439. </code>
  440. </step>
  441. <step>
  442. <description>
  443. <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>
  444. </description>
  445. <tags>
  446. <value />
  447. </tags>
  448. <code>
  449. <value><![CDATA[time = chVTGetSystemTimeX();
  450. chThdSleepSeconds(1);
  451. test_assert_time_window(chTimeAddX(time, TIME_S2I(1)),
  452. chTimeAddX(time, TIME_S2I(1) + 1),
  453. "out of time window");]]></value>
  454. </code>
  455. </step>
  456. <step>
  457. <description>
  458. <value>Function chThdSleepUntil() is tested with a timeline of "now" + 100 ticks.</value>
  459. </description>
  460. <tags>
  461. <value />
  462. </tags>
  463. <code>
  464. <value><![CDATA[time = chVTGetSystemTimeX();
  465. chThdSleepUntil(chTimeAddX(time, 100));
  466. test_assert_time_window(chTimeAddX(time, 100),
  467. chTimeAddX(time, 100 + 1),
  468. "out of time window");]]></value>
  469. </code>
  470. </step>
  471. </steps>
  472. </case>
  473. </cases>
  474. </sequence>
  475. <sequence>
  476. <type index="0">
  477. <value>Internal Tests</value>
  478. </type>
  479. <brief>
  480. <value>Semaphores.</value>
  481. </brief>
  482. <description>
  483. <value>This sequence tests the ChibiOS/NIL functionalities related to counter semaphores.</value>
  484. </description>
  485. <condition>
  486. <value>CH_CFG_USE_SEMAPHORES</value>
  487. </condition>
  488. <shared_code>
  489. <value><![CDATA[#include "ch.h"
  490. static semaphore_t sem1;]]></value>
  491. </shared_code>
  492. <cases>
  493. <case>
  494. <brief>
  495. <value>Semaphore primitives, no state change.</value>
  496. </brief>
  497. <description>
  498. <value>Wait, Signal and Reset primitives are tested. The testing thread does not trigger a state change.</value>
  499. </description>
  500. <condition>
  501. <value />
  502. </condition>
  503. <various_code>
  504. <setup_code>
  505. <value><![CDATA[chSemObjectInit(&sem1, 1);]]></value>
  506. </setup_code>
  507. <teardown_code>
  508. <value><![CDATA[chSemReset(&sem1, 0);]]></value>
  509. </teardown_code>
  510. <local_variables>
  511. <value />
  512. </local_variables>
  513. </various_code>
  514. <steps>
  515. <step>
  516. <description>
  517. <value>The function chSemWait() is invoked, after return the counter and the returned message are tested.</value>
  518. </description>
  519. <tags>
  520. <value />
  521. </tags>
  522. <code>
  523. <value><![CDATA[msg_t msg;
  524. msg = chSemWait(&sem1);
  525. test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
  526. test_assert(MSG_OK == msg, "wrong returned message");]]></value>
  527. </code>
  528. </step>
  529. <step>
  530. <description>
  531. <value>The function chSemSignal() is invoked, after return the counter is tested.</value>
  532. </description>
  533. <tags>
  534. <value />
  535. </tags>
  536. <code>
  537. <value><![CDATA[chSemSignal(&sem1);
  538. test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");]]></value>
  539. </code>
  540. </step>
  541. <step>
  542. <description>
  543. <value>The function chSemReset() is invoked, after return the counter is tested.</value>
  544. </description>
  545. <tags>
  546. <value />
  547. </tags>
  548. <code>
  549. <value><![CDATA[chSemReset(&sem1, 2);
  550. test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");]]></value>
  551. </code>
  552. </step>
  553. </steps>
  554. </case>
  555. <case>
  556. <brief>
  557. <value>Semaphore primitives, with state change.</value>
  558. </brief>
  559. <description>
  560. <value>Wait, Signal and Reset primitives are tested. The testing thread triggers a state change.</value>
  561. </description>
  562. <condition>
  563. <value />
  564. </condition>
  565. <various_code>
  566. <setup_code>
  567. <value><![CDATA[chSemObjectInit(&gsem1, 0);]]></value>
  568. </setup_code>
  569. <teardown_code>
  570. <value><![CDATA[chSemReset(&gsem1, 0);]]></value>
  571. </teardown_code>
  572. <local_variables>
  573. <value />
  574. </local_variables>
  575. </various_code>
  576. <steps>
  577. <step>
  578. <description>
  579. <value>The function chSemWait() is invoked, after return the counter and the returned message are tested. The semaphore is signaled by another thread.</value>
  580. </description>
  581. <tags>
  582. <value />
  583. </tags>
  584. <code>
  585. <value><![CDATA[msg_t msg;
  586. msg = chSemWait(&gsem1);
  587. test_assert_lock(chSemGetCounterI(&gsem1) == 0, "wrong counter value");
  588. test_assert(MSG_OK == msg, "wrong returned message");]]></value>
  589. </code>
  590. </step>
  591. <step>
  592. <description>
  593. <value>The function chSemWait() is invoked, after return the counter and the returned message are tested. The semaphore is reset by another thread.</value>
  594. </description>
  595. <tags>
  596. <value />
  597. </tags>
  598. <code>
  599. <value><![CDATA[msg_t msg;
  600. msg = chSemWait(&gsem2);
  601. test_assert_lock(chSemGetCounterI(&gsem2) == 0,"wrong counter value");
  602. test_assert(MSG_RESET == msg, "wrong returned message");]]></value>
  603. </code>
  604. </step>
  605. </steps>
  606. </case>
  607. <case>
  608. <brief>
  609. <value>Semaphores timeout.</value>
  610. </brief>
  611. <description>
  612. <value>Timeout on semaphores is tested.</value>
  613. </description>
  614. <condition>
  615. <value />
  616. </condition>
  617. <various_code>
  618. <setup_code>
  619. <value><![CDATA[chSemObjectInit(&sem1, 0);]]></value>
  620. </setup_code>
  621. <teardown_code>
  622. <value><![CDATA[chSemReset(&sem1, 0);]]></value>
  623. </teardown_code>
  624. <local_variables>
  625. <value><![CDATA[systime_t time;
  626. msg_t msg;]]></value>
  627. </local_variables>
  628. </various_code>
  629. <steps>
  630. <step>
  631. <description>
  632. <value>The function chSemWaitTimeout() is invoked a first time, after return the system time, the counter and the returned message are tested.</value>
  633. </description>
  634. <tags>
  635. <value />
  636. </tags>
  637. <code>
  638. <value><![CDATA[time = chVTGetSystemTimeX();
  639. msg = chSemWaitTimeout(&sem1, TIME_MS2I(1000));
  640. test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
  641. chTimeAddX(time, TIME_MS2I(1000) + 1),
  642. "out of time window");
  643. test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
  644. test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
  645. </code>
  646. </step>
  647. <step>
  648. <description>
  649. <value>The function chSemWaitTimeout() is invoked again, after return the system time, the counter and the returned message are tested.</value>
  650. </description>
  651. <tags>
  652. <value />
  653. </tags>
  654. <code>
  655. <value><![CDATA[time = chVTGetSystemTimeX();
  656. msg = chSemWaitTimeout(&sem1, TIME_MS2I(1000));
  657. test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
  658. chTimeAddX(time, TIME_MS2I(1000) + 1),
  659. "out of time window");
  660. test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
  661. test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
  662. </code>
  663. </step>
  664. </steps>
  665. </case>
  666. </cases>
  667. </sequence>
  668. <sequence>
  669. <type index="0">
  670. <value>Internal Tests</value>
  671. </type>
  672. <brief>
  673. <value>Suspend/Resume and Event Flags.</value>
  674. </brief>
  675. <description>
  676. <value>This sequence tests the ChibiOS/NIL functionalities related to threads suspend/resume and event flags.</value>
  677. </description>
  678. <condition>
  679. <value />
  680. </condition>
  681. <shared_code>
  682. <value><![CDATA[static thread_reference_t tr1;]]></value>
  683. </shared_code>
  684. <cases>
  685. <case>
  686. <brief>
  687. <value>Suspend and Resume functionality.</value>
  688. </brief>
  689. <description>
  690. <value>The functionality of chThdSuspendTimeoutS() and chThdResumeI() is tested.</value>
  691. </description>
  692. <condition>
  693. <value />
  694. </condition>
  695. <various_code>
  696. <setup_code>
  697. <value><![CDATA[tr1 = NULL;]]></value>
  698. </setup_code>
  699. <teardown_code>
  700. <value />
  701. </teardown_code>
  702. <local_variables>
  703. <value><![CDATA[systime_t time;
  704. msg_t msg;]]></value>
  705. </local_variables>
  706. </various_code>
  707. <steps>
  708. <step>
  709. <description>
  710. <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>
  711. </description>
  712. <tags>
  713. <value />
  714. </tags>
  715. <code>
  716. <value><![CDATA[chSysLock();
  717. msg = chThdSuspendTimeoutS(&gtr1, TIME_INFINITE);
  718. chSysUnlock();
  719. test_assert(NULL == gtr1, "not NULL");
  720. test_assert(MSG_OK == msg,"wrong returned message");]]></value>
  721. </code>
  722. </step>
  723. <step>
  724. <description>
  725. <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>
  726. </description>
  727. <tags>
  728. <value />
  729. </tags>
  730. <code>
  731. <value><![CDATA[chSysLock();
  732. time = chVTGetSystemTimeX();
  733. msg = chThdSuspendTimeoutS(&tr1, TIME_MS2I(1000));
  734. chSysUnlock();
  735. test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
  736. chTimeAddX(time, TIME_MS2I(1000) + 1),
  737. "out of time window");
  738. test_assert(NULL == tr1, "not NULL");
  739. test_assert(MSG_TIMEOUT == msg, "wrong returned message");]]></value>
  740. </code>
  741. </step>
  742. </steps>
  743. </case>
  744. <case>
  745. <brief>
  746. <value>Events Flags functionality.</value>
  747. </brief>
  748. <description>
  749. <value>Event flags functionality is tested.</value>
  750. </description>
  751. <condition>
  752. <value>CH_CFG_USE_EVENTS</value>
  753. </condition>
  754. <various_code>
  755. <setup_code>
  756. <value />
  757. </setup_code>
  758. <teardown_code>
  759. <value />
  760. </teardown_code>
  761. <local_variables>
  762. <value><![CDATA[systime_t time;
  763. eventmask_t events;]]></value>
  764. </local_variables>
  765. </various_code>
  766. <steps>
  767. <step>
  768. <description>
  769. <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>
  770. </description>
  771. <tags>
  772. <value />
  773. </tags>
  774. <code>
  775. <value><![CDATA[time = chVTGetSystemTimeX();
  776. chEvtSignal(chThdGetSelfX(), 0x55);
  777. events = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(1000));
  778. test_assert((eventmask_t)0 != events, "timed out");
  779. test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
  780. </code>
  781. </step>
  782. <step>
  783. <description>
  784. <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>
  785. </description>
  786. <tags>
  787. <value />
  788. </tags>
  789. <code>
  790. <value><![CDATA[time = chVTGetSystemTimeX();
  791. chThdGetSelfX()->epmask = 0;
  792. events = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(1000));
  793. test_assert((eventmask_t)0 != events, "timed out");
  794. test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
  795. </code>
  796. </step>
  797. <step>
  798. <description>
  799. <value>The function chEvtWaitAnyTimeout() is invoked, no event can wakeup the thread, the function must return because timeout.</value>
  800. </description>
  801. <tags>
  802. <value />
  803. </tags>
  804. <code>
  805. <value><![CDATA[time = chVTGetSystemTimeX();
  806. events = chEvtWaitAnyTimeout(0, TIME_MS2I(1000));
  807. test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
  808. chTimeAddX(time, TIME_MS2I(1000) + 1),
  809. "out of time window");
  810. test_assert((eventmask_t)0 == events, "wrong events mask");]]></value>
  811. </code>
  812. </step>
  813. </steps>
  814. </case>
  815. </cases>
  816. </sequence>
  817. </sequences>
  818. </instance>
  819. </instances>
  820. <exportedFeatures />
  821. </application>
  822. </SPC5-Config>