123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061 |
- <?xml version="1.0" encoding="UTF-8"?>
- <SPC5-Config version="1.0.0">
- <application name="ChibiOS OS Library Test Suite" version="1.0.0" standalone="true" locked="false">
- <description>Test Specification for ChibiOS OS Library.</description>
- <component id="org.chibios.spc5.components.portable.generic_startup">
- <component id="org.chibios.spc5.components.portable.chibios_unitary_tests_engine" />
- </component>
- <instances>
- <instance locked="false" id="org.chibios.spc5.components.portable.generic_startup" />
- <instance locked="false" id="org.chibios.spc5.components.portable.chibios_unitary_tests_engine">
- <description>
- <brief>
- <value>ChibiOS OS Library Test Suite.</value>
- </brief>
- <copyright>
- <value><![CDATA[/*
- ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */]]></value>
- </copyright>
- <introduction>
- <value>Test suite for ChibiOS OS Library. The purpose of this suite is to perform unit tests on the library modules and to converge to 100% code coverage through successive improvements.</value>
- </introduction>
- </description>
- <global_data_and_code>
- <code_prefix>
- <value>oslib_</value>
- </code_prefix>
- <global_definitions>
- <value />
- </global_definitions>
- <global_code>
- <value />
- </global_code>
- </global_data_and_code>
- <sequences>
- <sequence>
- <type index="0">
- <value>Internal Tests</value>
- </type>
- <brief>
- <value>Mailboxes.</value>
- </brief>
- <description>
- <value>This sequence tests the ChibiOS library functionalities related to mailboxes.</value>
- </description>
- <condition>
- <value>CH_CFG_USE_MAILBOXES</value>
- </condition>
- <shared_code>
- <value><![CDATA[#define MB_SIZE 4
- static msg_t mb_buffer[MB_SIZE];
- static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);]]></value>
- </shared_code>
- <cases>
- <case>
- <brief>
- <value>Mailbox normal API, non-blocking tests.</value>
- </brief>
- <description>
- <value>The mailbox normal API is tested without triggering blocking conditions.</value>
- </description>
- <condition>
- <value />
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chMBObjectInit(&mb1, mb_buffer, MB_SIZE);]]></value>
- </setup_code>
- <teardown_code>
- <value><![CDATA[chMBReset(&mb1);]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[msg_t msg1, msg2;
- unsigned i;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Testing the mailbox size.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Resetting the mailbox, conditions are checked, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chMBReset(&mb1);
- test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert_lock(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
- test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing the behavior of API when the mailbox is in reset state then return in active state.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBPostTimeout(&mb1, (msg_t)0, TIME_INFINITE);
- test_assert(msg1 == MSG_RESET, "not in reset state");
- msg1 = chMBPostAheadTimeout(&mb1, (msg_t)0, TIME_INFINITE);
- test_assert(msg1 == MSG_RESET, "not in reset state");
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_RESET, "not in reset state");
- chMBResumeX(&mb1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Filling the mailbox using chMBPostTimeout() and chMBPostAheadTimeout() once, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE - 1; i++) {
- msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
- msg1 = chMBPostAheadTimeout(&mb1, 'A', TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing intermediate conditions. Data pointers must be aligned, semaphore counters are checked.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
- test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the mailbox using chMBFetchTimeout(), no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE; i++) {
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- test_emit_token(msg2);
- }
- test_assert_sequence("ABCD", "wrong get sequence");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Posting and then fetching one more message, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing final conditions. Data pointers must be aligned to buffer start, semaphore counters are checked.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
- test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Mailbox I-Class API, non-blocking tests.</value>
- </brief>
- <description>
- <value>The mailbox I-Class API is tested without triggering blocking conditions.</value>
- </description>
- <condition>
- <value />
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chMBObjectInit(&mb1, mb_buffer, MB_SIZE);]]></value>
- </setup_code>
- <teardown_code>
- <value><![CDATA[chMBReset(&mb1);]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[msg_t msg1, msg2;
- unsigned i;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Testing the mailbox size.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Resetting the mailbox, conditions are checked, no errors expected. The mailbox is then returned in active state.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chSysLock();
- chMBResetI(&mb1);
- chSysUnlock();
- test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert_lock(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
- test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
- chMBResumeX(&mb1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Filling the mailbox using chMBPostI() and chMBPostAheadI() once, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE - 1; i++) {
- chSysLock();
- msg1 = chMBPostI(&mb1, 'B' + i);
- chSysUnlock();
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
- chSysLock();
- msg1 = chMBPostAheadI(&mb1, 'A');
- chSysUnlock();
- test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing intermediate conditions. Data pointers must be aligned, semaphore counters are checked.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
- test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the mailbox using chMBFetchI(), no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE; i++) {
- chSysLock();
- msg1 = chMBFetchI(&mb1, &msg2);
- chSysUnlock();
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- test_emit_token(msg2);
- }
- test_assert_sequence("ABCD", "wrong get sequence");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Posting and then fetching one more message, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing final conditions. Data pointers must be aligned to buffer start, semaphore counters are checked.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
- test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Mailbox timeouts.</value>
- </brief>
- <description>
- <value>The mailbox API is tested for timeouts.</value>
- </description>
- <condition>
- <value />
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chMBObjectInit(&mb1, mb_buffer, MB_SIZE);]]></value>
- </setup_code>
- <teardown_code>
- <value><![CDATA[chMBReset(&mb1);]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[msg_t msg1, msg2;
- unsigned i;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Filling the mailbox.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE; i++) {
- msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing chMBPostTimeout(), chMBPostI(), chMBPostAheadTimeout() and chMBPostAheadI() timeout.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBPostTimeout(&mb1, 'X', 1);
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- chSysLock();
- msg1 = chMBPostI(&mb1, 'X');
- chSysUnlock();
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- msg1 = chMBPostAheadTimeout(&mb1, 'X', 1);
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- chSysLock();
- msg1 = chMBPostAheadI(&mb1, 'X');
- chSysUnlock();
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Resetting the mailbox. The mailbox is then returned in active state.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chMBReset(&mb1);
- chMBResumeX(&mb1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing chMBFetchTimeout() and chMBFetchI() timeout.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBFetchTimeout(&mb1, &msg2, 1);
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- chSysLock();
- msg1 = chMBFetchI(&mb1, &msg2);
- chSysUnlock();
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");]]></value>
- </code>
- </step>
- </steps>
- </case>
- </cases>
- </sequence>
- <sequence>
- <type index="0">
- <value>Internal Tests</value>
- </type>
- <brief>
- <value>Pipes</value>
- </brief>
- <description>
- <value>This sequence tests the ChibiOS library functionalities related to pipes.</value>
- </description>
- <condition>
- <value>CH_CFG_USE_PIPES</value>
- </condition>
- <shared_code>
- <value><![CDATA[#include <string.h>
- #define PIPE_SIZE 16
- static uint8_t buffer[PIPE_SIZE];
- static PIPE_DECL(pipe1, buffer, PIPE_SIZE);
- static const uint8_t pipe_pattern[] = "0123456789ABCDEF";]]></value>
- </shared_code>
- <cases>
- <case>
- <brief>
- <value>Pipes normal API, non-blocking tests.</value>
- </brief>
- <description>
- <value>The pipe functionality is tested by loading and emptying it, all conditions are tested.</value>
- </description>
- <condition>
- <value>
- </value>
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chPipeObjectInit(&pipe1, buffer, PIPE_SIZE);]]></value>
- </setup_code>
- <teardown_code>
- <value/>
- </teardown_code>
- <local_variables>
- <value></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Resetting pipe.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[chPipeReset(&pipe1);
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Writing data, must fail.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- n = chPipeWriteTimeout(&pipe1, pipe_pattern, PIPE_SIZE, TIME_IMMEDIATE);
- test_assert(n == 0, "not reset");
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Reading data, must fail.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- uint8_t buf[PIPE_SIZE];
- n = chPipeReadTimeout(&pipe1, buf, PIPE_SIZE, TIME_IMMEDIATE);
- test_assert(n == 0, "not reset");
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Reactivating pipe.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[chPipeResume(&pipe1);
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Filling whole pipe.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- n = chPipeWriteTimeout(&pipe1, pipe_pattern, PIPE_SIZE, TIME_IMMEDIATE);
- test_assert(n == PIPE_SIZE, "wrong size");
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == PIPE_SIZE),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying pipe.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- uint8_t buf[PIPE_SIZE];
- n = chPipeReadTimeout(&pipe1, buf, PIPE_SIZE, TIME_IMMEDIATE);
- test_assert(n == PIPE_SIZE, "wrong size");
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");
- test_assert(memcmp(pipe_pattern, buf, PIPE_SIZE) == 0, "content mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Small write.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- n = chPipeWriteTimeout(&pipe1, pipe_pattern, 4, TIME_IMMEDIATE);
- test_assert(n == 4, "wrong size");
- test_assert((pipe1.rdptr != pipe1.wrptr) &&
- (pipe1.rdptr == pipe1.buffer) &&
- (pipe1.cnt == 4),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Filling remaining space.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- n = chPipeWriteTimeout(&pipe1, pipe_pattern, PIPE_SIZE - 4, TIME_IMMEDIATE);
- test_assert(n == PIPE_SIZE - 4, "wrong size");
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == PIPE_SIZE),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Small Read.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- uint8_t buf[PIPE_SIZE];
- n = chPipeReadTimeout(&pipe1, buf, 4, TIME_IMMEDIATE);
- test_assert(n == 4, "wrong size");
- test_assert((pipe1.rdptr != pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == PIPE_SIZE - 4),
- "invalid pipe state");
- test_assert(memcmp(pipe_pattern, buf, 4) == 0, "content mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Reading remaining data.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- uint8_t buf[PIPE_SIZE];
- n = chPipeReadTimeout(&pipe1, buf, PIPE_SIZE - 4, TIME_IMMEDIATE);
- test_assert(n == PIPE_SIZE - 4, "wrong size");
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");
- test_assert(memcmp(pipe_pattern, buf, PIPE_SIZE - 4) == 0, "content mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Small Write.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- n = chPipeWriteTimeout(&pipe1, pipe_pattern, 5, TIME_IMMEDIATE);
- test_assert(n == 5, "wrong size");
- test_assert((pipe1.rdptr != pipe1.wrptr) &&
- (pipe1.rdptr == pipe1.buffer) &&
- (pipe1.cnt == 5),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Small Read.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- uint8_t buf[PIPE_SIZE];
- n = chPipeReadTimeout(&pipe1, buf, 5, TIME_IMMEDIATE);
- test_assert(n == 5, "wrong size");
- test_assert((pipe1.rdptr == pipe1.wrptr) &&
- (pipe1.wrptr != pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");
- test_assert(memcmp(pipe_pattern, buf, 5) == 0, "content mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Write wrapping buffer boundary.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- n = chPipeWriteTimeout(&pipe1, pipe_pattern, PIPE_SIZE, TIME_IMMEDIATE);
- test_assert(n == PIPE_SIZE, "wrong size");
- test_assert((pipe1.rdptr == pipe1.wrptr) &&
- (pipe1.wrptr != pipe1.buffer) &&
- (pipe1.cnt == PIPE_SIZE),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Read wrapping buffer boundary.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- uint8_t buf[PIPE_SIZE];
- n = chPipeReadTimeout(&pipe1, buf, PIPE_SIZE, TIME_IMMEDIATE);
- test_assert(n == PIPE_SIZE, "wrong size");
- test_assert((pipe1.rdptr == pipe1.wrptr) &&
- (pipe1.wrptr != pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");
- test_assert(memcmp(pipe_pattern, buf, PIPE_SIZE) == 0, "content mismatch");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Pipe timeouts.</value>
- </brief>
- <description>
- <value>The pipe API is tested for timeouts.</value>
- </description>
- <condition>
- <value>
- </value>
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chPipeObjectInit(&pipe1, buffer, PIPE_SIZE / 2);]]></value>
- </setup_code>
- <teardown_code>
- <value/>
- </teardown_code>
- <local_variables>
- <value></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Reading while pipe is empty.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- uint8_t buf[PIPE_SIZE];
- n = chPipeReadTimeout(&pipe1, buf, PIPE_SIZE, TIME_IMMEDIATE);
- test_assert(n == 0, "wrong size");
- test_assert((pipe1.rdptr == pipe1.buffer) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == 0),
- "invalid pipe state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Writing a string larger than pipe buffer.</value>
- </description>
- <tags>
- <value></value>
- </tags>
- <code>
- <value><![CDATA[size_t n;
- n = chPipeWriteTimeout(&pipe1, pipe_pattern, PIPE_SIZE, TIME_IMMEDIATE);
- test_assert(n == PIPE_SIZE / 2, "wrong size");
- test_assert((pipe1.rdptr == pipe1.wrptr) &&
- (pipe1.wrptr == pipe1.buffer) &&
- (pipe1.cnt == PIPE_SIZE / 2),
- "invalid pipe state");]]></value>
- </code>
- </step>
- </steps>
- </case>
- </cases>
- </sequence>
- <sequence>
- <type index="0">
- <value>Internal Tests</value>
- </type>
- <brief>
- <value>Memory Pools.</value>
- </brief>
- <description>
- <value>This sequence tests the ChibiOS library functionalities related to memory pools.</value>
- </description>
- <condition>
- <value>CH_CFG_USE_MEMPOOLS</value>
- </condition>
- <shared_code>
- <value><![CDATA[#define MEMORY_POOL_SIZE 4
- static uint32_t objects[MEMORY_POOL_SIZE];
- static MEMORYPOOL_DECL(mp1, sizeof (uint32_t), PORT_NATURAL_ALIGN, NULL);
- #if CH_CFG_USE_SEMAPHORES
- static GUARDEDMEMORYPOOL_DECL(gmp1, sizeof (uint32_t), PORT_NATURAL_ALIGN);
- #endif
- static void *null_provider(size_t size, unsigned align) {
- (void)size;
- (void)align;
- return NULL;
- }]]></value>
- </shared_code>
- <cases>
- <case>
- <brief>
- <value>Loading and emptying a memory pool.</value>
- </brief>
- <description>
- <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
- </description>
- <condition>
- <value />
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chPoolObjectInit(&mp1, sizeof (uint32_t), NULL);]]></value>
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value><![CDATA[unsigned i;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Adding the objects to the pool using chPoolLoadArray().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the pool using chPoolAlloc().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- test_assert(chPoolAlloc(&mp1) != NULL, "list empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Now must be empty.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Adding the objects to the pool using chPoolFree().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- chPoolFree(&mp1, &objects[i]);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the pool using chPoolAlloc() again.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- test_assert(chPoolAlloc(&mp1) != NULL, "list empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Now must be empty again.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Covering the case where a provider is unable to return more memory.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chPoolObjectInit(&mp1, sizeof (uint32_t), null_provider);
- test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Loading and emptying a guarded memory pool without waiting.</value>
- </brief>
- <description>
- <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
- </description>
- <condition>
- <value>CH_CFG_USE_SEMAPHORES</value>
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));]]></value>
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value><![CDATA[unsigned i;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Adding the objects to the pool using chGuardedPoolLoadArray().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chGuardedPoolLoadArray(&gmp1, objects, MEMORY_POOL_SIZE);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the pool using chGuardedPoolAllocTimeout().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Now must be empty.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Adding the objects to the pool using chGuardedPoolFree().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- chGuardedPoolFree(&gmp1, &objects[i]);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the pool using chGuardedPoolAllocTimeout() again.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Now must be empty again.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Guarded Memory Pools timeout.</value>
- </brief>
- <description>
- <value>The timeout features for the Guarded Memory Pools is tested.</value>
- </description>
- <condition>
- <value>CH_CFG_USE_SEMAPHORES</value>
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));]]></value>
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value />
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Trying to allocate with 100mS timeout, must fail because the pool is empty.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_MS2I(100)) == NULL, "list not empty");]]></value>
- </code>
- </step>
- </steps>
- </case>
- </cases>
- </sequence>
- <sequence>
- <type index="0">
- <value>Internal Tests</value>
- </type>
- <brief>
- <value>Memory Heaps.</value>
- </brief>
- <description>
- <value>This sequence tests the ChibiOS library functionalities related to memory heaps.</value>
- </description>
- <condition>
- <value>CH_CFG_USE_HEAP</value>
- </condition>
- <shared_code>
- <value><![CDATA[#define ALLOC_SIZE 16
- #define HEAP_SIZE (ALLOC_SIZE * 8)
- static memory_heap_t test_heap;
- static uint8_t test_heap_buffer[HEAP_SIZE];]]></value>
- </shared_code>
- <cases>
- <case>
- <brief>
- <value>Allocation and fragmentation.</value>
- </brief>
- <description>
- <value>Series of allocations/deallocations are performed in carefully designed sequences in order to stimulate all the possible code paths inside the allocator. The test expects to find the heap back to the initial status after each sequence.</value>
- </description>
- <condition>
- <value />
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chHeapObjectInit(&test_heap, test_heap_buffer, sizeof(test_heap_buffer));]]></value>
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value><![CDATA[void *p1, *p2, *p3;
- size_t n, sz;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Testing initial conditions, the heap must not be fragmented and one free block present.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chHeapStatus(&test_heap, &sz, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Trying to allocate an block bigger than available space, an error is expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, sizeof test_heap_buffer * 2);
- test_assert(p1 == NULL, "allocation not failed");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Single block allocation using chHeapAlloc() then the block is freed using chHeapFree(), must not fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- test_assert(p1 != NULL, "allocation failed");
- chHeapFree(p1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Using chHeapStatus() to assess the heap state. There must be at least one free block of sufficient size.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[size_t total_size, largest_size;
- n = chHeapStatus(&test_heap, &total_size, &largest_size);
- test_assert(n == 1, "missing free block");
- test_assert(total_size >= ALLOC_SIZE, "unexpected heap state");
- test_assert(total_size == largest_size, "unexpected heap state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Allocating then freeing in the same order.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p3 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- chHeapFree(p1); /* Does not merge.*/
- chHeapFree(p2); /* Merges backward.*/
- chHeapFree(p3); /* Merges both sides.*/
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Allocating then freeing in reverse order.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p3 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- chHeapFree(p3); /* Merges forward.*/
- chHeapFree(p2); /* Merges forward.*/
- chHeapFree(p1); /* Merges forward.*/
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Small fragments handling. Checking the behavior when allocating blocks with size not multiple of alignment unit.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE + 1);
- p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- chHeapFree(p1);
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 2, "invalid state");
- p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- /* Note, the first situation happens when the alignment size is smaller
- than the header size, the second in the other cases.*/
- test_assert((chHeapStatus(&test_heap, &n, NULL) == 1) ||
- (chHeapStatus(&test_heap, &n, NULL) == 2), "heap fragmented");
- chHeapFree(p2);
- chHeapFree(p1);
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Skipping a fragment, the first fragment in the list is too small so the allocator must pick the second one.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- chHeapFree(p1);
- test_assert( chHeapStatus(&test_heap, &n, NULL) == 2, "invalid state");
- p1 = chHeapAlloc(&test_heap, ALLOC_SIZE * 2); /* Skips first fragment.*/
- chHeapFree(p1);
- chHeapFree(p2);
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Allocating the whole available space.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[(void)chHeapStatus(&test_heap, &n, NULL);
- p1 = chHeapAlloc(&test_heap, n);
- test_assert(p1 != NULL, "allocation failed");
- test_assert(chHeapStatus(&test_heap, NULL, NULL) == 0, "not empty");
- chHeapFree(p1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing final conditions. The heap geometry must be the same than the one registered at beginning.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
- test_assert(n == sz, "size changed");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Default Heap.</value>
- </brief>
- <description>
- <value>The default heap is pre-allocated in the system. We test base functionality.</value>
- </description>
- <condition>
- <value />
- </condition>
- <various_code>
- <setup_code>
- <value />
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value><![CDATA[void *p1;
- size_t total_size, largest_size;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Single block allocation using chHeapAlloc() then the block is freed using chHeapFree(), must not fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[(void)chHeapStatus(NULL, &total_size, &largest_size);
- p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- test_assert(p1 != NULL, "allocation failed");
- chHeapFree(p1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing allocation failure.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(NULL, (size_t)-256);
- test_assert(p1 == NULL, "allocation not failed");]]></value>
- </code>
- </step>
- </steps>
- </case>
- </cases>
- </sequence>
- <sequence>
- <type index="0">
- <value>Internal Tests</value>
- </type>
- <brief>
- <value>Objects Factory.</value>
- </brief>
- <description>
- <value>This sequence tests the ChibiOS library functionalities related to the object factory.</value>
- </description>
- <condition>
- <value>(CH_CFG_USE_FACTORY == TRUE) && (CH_CFG_USE_MEMPOOLS == TRUE) && (CH_CFG_USE_HEAP == TRUE)</value>
- </condition>
- <shared_code>
- <value />
- </shared_code>
- <cases>
- <case>
- <brief>
- <value>Objects Registry.</value>
- </brief>
- <description>
- <value>This test case verifies the static objects registry.</value>
- </description>
- <condition>
- <value>CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE</value>
- </condition>
- <various_code>
- <setup_code>
- <value />
- </setup_code>
- <teardown_code>
- <value><![CDATA[registered_object_t *rop;
- rop = chFactoryFindObject("myobj");
- if (rop != NULL) {
- while (rop->element.refs > 0U) {
- chFactoryReleaseObject(rop);
- }
- }]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[registered_object_t *rop;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Retrieving a registered object by name, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[rop = chFactoryFindObject("myobj");
- test_assert(rop == NULL, "found");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Registering an object, it must not exists, must succeed.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[static uint32_t myobj = 0x55aa;
- rop = chFactoryRegisterObject("myobj", (void *)&myobj);
- test_assert(rop != NULL, "cannot register");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Registering an object with the same name, must fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[registered_object_t *rop1;
- static uint32_t myobj = 0x55aa;
- rop1 = chFactoryRegisterObject("myobj", (void *)&myobj);
- test_assert(rop1 == NULL, "can register");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the registered object by name, must exist, then increasing the reference counter, finally releasing both references.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[registered_object_t *rop1, *rop2;
- rop1 = chFactoryFindObject("myobj");
- test_assert(rop1 != NULL, "not found");
- test_assert(*(uint32_t *)(rop1->objp) == 0x55aa, "object mismatch");
- test_assert(rop == rop1, "object reference mismatch");
- test_assert(rop1->element.refs == 2, "object reference mismatch");
- rop2 = (registered_object_t *)chFactoryDuplicateReference(&rop1->element);
- test_assert(rop1 == rop2, "object reference mismatch");
- test_assert(*(uint32_t *)(rop2->objp) == 0x55aa, "object mismatch");
- test_assert(rop2->element.refs == 3, "object reference mismatch");
- chFactoryReleaseObject(rop2);
- test_assert(rop1->element.refs == 2, "references mismatch");
- chFactoryReleaseObject(rop1);
- test_assert(rop->element.refs == 1, "references mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Releasing the first reference to the object, must not trigger an assertion.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chFactoryReleaseObject(rop);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the registered object by name again, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[rop = chFactoryFindObject("myobj");
- test_assert(rop == NULL, "found");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Dynamic Buffers Factory.</value>
- </brief>
- <description>
- <value>This test case verifies the dynamic buffers factory.</value>
- </description>
- <condition>
- <value>CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE</value>
- </condition>
- <various_code>
- <setup_code>
- <value />
- </setup_code>
- <teardown_code>
- <value><![CDATA[dyn_buffer_t *dbp;
- dbp = chFactoryFindBuffer("mybuf");
- if (dbp != NULL) {
- while (dbp->element.refs > 0U) {
- chFactoryReleaseBuffer(dbp);
- }
- }]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[dyn_buffer_t *dbp;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Retrieving a dynamic buffer by name, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dbp = chFactoryFindBuffer("mybuf");
- test_assert(dbp == NULL, "found");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic buffer it must not exists, must succeed.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dbp = chFactoryCreateBuffer("mybuf", 128U);
- test_assert(dbp != NULL, "cannot create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic buffer with the same name, must fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_buffer_t *dbp1;
- dbp1 = chFactoryCreateBuffer("mybuf", 128U);
- test_assert(dbp1 == NULL, "can create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic buffer by name, must exist, then increasing the reference counter, finally releasing both references.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_buffer_t *dbp1, *dbp2;
- dbp1 = chFactoryFindBuffer("mybuf");
- test_assert(dbp1 != NULL, "not found");
- test_assert(dbp == dbp1, "object reference mismatch");
- test_assert(dbp1->element.refs == 2, "object reference mismatch");
- dbp2 = (dyn_buffer_t *)chFactoryDuplicateReference(&dbp1->element);
- test_assert(dbp1 == dbp2, "object reference mismatch");
- test_assert(dbp2->element.refs == 3, "object reference mismatch");
- chFactoryReleaseBuffer(dbp2);
- test_assert(dbp1->element.refs == 2, "references mismatch");
- chFactoryReleaseBuffer(dbp1);
- test_assert(dbp->element.refs == 1, "references mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Releasing the first reference to the dynamic buffer, must not trigger an assertion.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chFactoryReleaseBuffer(dbp);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic buffer by name again, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dbp = chFactoryFindBuffer("mybuf");
- test_assert(dbp == NULL, "found");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Dynamic Semaphores Factory.</value>
- </brief>
- <description>
- <value>This test case verifies the dynamic semaphores factory.</value>
- </description>
- <condition>
- <value>CH_CFG_FACTORY_SEMAPHORES == TRUE</value>
- </condition>
- <various_code>
- <setup_code>
- <value />
- </setup_code>
- <teardown_code>
- <value><![CDATA[dyn_semaphore_t *dsp;
- dsp = chFactoryFindSemaphore("mysem");
- if (dsp != NULL) {
- while (dsp->element.refs > 0U) {
- chFactoryReleaseSemaphore(dsp);
- }
- }]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[dyn_semaphore_t *dsp;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Retrieving a dynamic semaphore by name, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dsp = chFactoryFindSemaphore("mysem");
- test_assert(dsp == NULL, "found");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic semaphore it must not exists, must succeed.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dsp = chFactoryCreateSemaphore("mysem", 0);
- test_assert(dsp != NULL, "cannot create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic semaphore with the same name, must fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_semaphore_t *dsp1;
- dsp1 = chFactoryCreateSemaphore("mysem", 0);
- test_assert(dsp1 == NULL, "can create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic semaphore by name, must exist, then increasing the reference counter, finally releasing both references.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_semaphore_t *dsp1, *dsp2;
- dsp1 = chFactoryFindSemaphore("mysem");
- test_assert(dsp1 != NULL, "not found");
- test_assert(dsp == dsp1, "object reference mismatch");
- test_assert(dsp1->element.refs == 2, "object reference mismatch");
- dsp2 = (dyn_semaphore_t *)chFactoryDuplicateReference(&dsp1->element);
- test_assert(dsp1 == dsp2, "object reference mismatch");
- test_assert(dsp2->element.refs == 3, "object reference mismatch");
- chFactoryReleaseSemaphore(dsp2);
- test_assert(dsp1->element.refs == 2, "references mismatch");
- chFactoryReleaseSemaphore(dsp1);
- test_assert(dsp->element.refs == 1, "references mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Releasing the first reference to the dynamic semaphore must not trigger an assertion.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chFactoryReleaseSemaphore(dsp);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic semaphore by name again, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dsp = chFactoryFindSemaphore("mysem");
- test_assert(dsp == NULL, "found");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Dynamic Mailboxes Factory.</value>
- </brief>
- <description>
- <value>This test case verifies the dynamic mailboxes factory.</value>
- </description>
- <condition>
- <value>CH_CFG_FACTORY_MAILBOXES == TRUE</value>
- </condition>
- <various_code>
- <setup_code>
- <value />
- </setup_code>
- <teardown_code>
- <value><![CDATA[dyn_mailbox_t *dmp;
- dmp = chFactoryFindMailbox("mymbx");
- if (dmp != NULL) {
- while (dmp->element.refs > 0U) {
- chFactoryReleaseMailbox(dmp);
- }
- }]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[dyn_mailbox_t *dmp;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Retrieving a dynamic mailbox by name, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dmp = chFactoryFindMailbox("mymbx");
- test_assert(dmp == NULL, "found");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic mailbox it must not exists, must succeed.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dmp = chFactoryCreateMailbox("mymbx", 16U);
- test_assert(dmp != NULL, "cannot create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic mailbox with the same name, must fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_mailbox_t *dmp1;
- dmp1 = chFactoryCreateMailbox("mymbx", 16U);
- test_assert(dmp1 == NULL, "can create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic mailbox by name, must exist, then increasing the reference counter, finally releasing both references.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_mailbox_t *dmp1, *dmp2;
- dmp1 = chFactoryFindMailbox("mymbx");
- test_assert(dmp1 != NULL, "not found");
- test_assert(dmp == dmp1, "object reference mismatch");
- test_assert(dmp1->element.refs == 2, "object reference mismatch");
- dmp2 = (dyn_mailbox_t *)chFactoryDuplicateReference(&dmp1->element);
- test_assert(dmp1 == dmp2, "object reference mismatch");
- test_assert(dmp2->element.refs == 3, "object reference mismatch");
- chFactoryReleaseMailbox(dmp2);
- test_assert(dmp1->element.refs == 2, "references mismatch");
- chFactoryReleaseMailbox(dmp1);
- test_assert(dmp->element.refs == 1, "references mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Releasing the first reference to the dynamic mailbox must not trigger an assertion.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chFactoryReleaseMailbox(dmp);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic mailbox by name again, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dmp = chFactoryFindMailbox("mymbx");
- test_assert(dmp == NULL, "found");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Dynamic Objects FIFOs Factory.</value>
- </brief>
- <description>
- <value>This test case verifies the dynamic objects FIFOs factory.</value>
- </description>
- <condition>
- <value>CH_CFG_FACTORY_OBJ_FIFOS == TRUE</value>
- </condition>
- <various_code>
- <setup_code>
- <value />
- </setup_code>
- <teardown_code>
- <value><![CDATA[dyn_objects_fifo_t *dofp;
- dofp = chFactoryFindObjectsFIFO("myfifo");
- if (dofp != NULL) {
- while (dofp->element.refs > 0U) {
- chFactoryReleaseObjectsFIFO(dofp);
- }
- }]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[dyn_objects_fifo_t *dofp;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Retrieving a dynamic objects FIFO by name, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dofp = chFactoryFindObjectsFIFO("myfifo");
- test_assert(dofp == NULL, "found");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic objects FIFO it must not exists, must succeed.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dofp = chFactoryCreateObjectsFIFO("myfifo", 16U, 16U, PORT_NATURAL_ALIGN);
- test_assert(dofp != NULL, "cannot create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic objects FIFO with the same name, must fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_objects_fifo_t *dofp1;
- dofp1 = chFactoryCreateObjectsFIFO("myfifo", 16U, 16U, PORT_NATURAL_ALIGN);
- test_assert(dofp1 == NULL, "can create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic objects FIFO by name, must exist, then increasing the reference counter, finally releasing both references.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_objects_fifo_t *dofp1, *dofp2;
- dofp1 = chFactoryFindObjectsFIFO("myfifo");
- test_assert(dofp1 != NULL, "not found");
- test_assert(dofp == dofp1, "object reference mismatch");
- test_assert(dofp1->element.refs == 2, "object reference mismatch");
- dofp2 = (dyn_objects_fifo_t *)chFactoryDuplicateReference(&dofp1->element);
- test_assert(dofp1 == dofp2, "object reference mismatch");
- test_assert(dofp2->element.refs == 3, "object reference mismatch");
- chFactoryReleaseObjectsFIFO(dofp2);
- test_assert(dofp1->element.refs == 2, "references mismatch");
- chFactoryReleaseObjectsFIFO(dofp1);
- test_assert(dofp->element.refs == 1, "references mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Releasing the first reference to the dynamic objects FIFO must not trigger an assertion.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chFactoryReleaseObjectsFIFO(dofp);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic objects FIFO by name again, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dofp = chFactoryFindObjectsFIFO("myfifo");
- test_assert(dofp == NULL, "found");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Dynamic Pipes Factory.</value>
- </brief>
- <description>
- <value>This test case verifies the dynamic pipes factory.</value>
- </description>
- <condition>
- <value>CH_CFG_FACTORY_PIPES == TRUE</value>
- </condition>
- <various_code>
- <setup_code>
- <value />
- </setup_code>
- <teardown_code>
- <value><![CDATA[dyn_pipe_t *dpp;
- dpp = chFactoryFindPipe("mypipe");
- if (dpp != NULL) {
- while (dpp->element.refs > 0U) {
- chFactoryReleasePipe(dpp);
- }
- }]]></value>
- </teardown_code>
- <local_variables>
- <value><![CDATA[dyn_pipe_t *dpp;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Retrieving a dynamic pipe by name, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dpp = chFactoryFindPipe("mypipe");
- test_assert(dpp == NULL, "found");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic pipe it must not exists, must succeed.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dpp = chFactoryCreatePipe("mypipe", 16U);
- test_assert(dpp != NULL, "cannot create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Creating a dynamic pipe with the same name, must fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_pipe_t *dpp1;
- dpp1 = chFactoryCreatePipe("mypipe", 16U);
- test_assert(dpp1 == NULL, "can create");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic pipe by name, must exist, then increasing the reference counter, finally releasing both references.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dyn_pipe_t *dpp1, *dpp2;
- dpp1 = chFactoryFindPipe("mypipe");
- test_assert(dpp1 != NULL, "not found");
- test_assert(dpp == dpp1, "object reference mismatch");
- test_assert(dpp1->element.refs == 2, "object reference mismatch");
- dpp2 = (dyn_pipe_t *)chFactoryDuplicateReference(&dpp1->element);
- test_assert(dpp1 == dpp2, "object reference mismatch");
- test_assert(dpp2->element.refs == 3, "object reference mismatch");
- chFactoryReleasePipe(dpp2);
- test_assert(dpp1->element.refs == 2, "references mismatch");
- chFactoryReleasePipe(dpp1);
- test_assert(dpp->element.refs == 1, "references mismatch");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Releasing the first reference to the dynamic pipe must not trigger an assertion.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chFactoryReleasePipe(dpp);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Retrieving the dynamic pipe by name again, must not exist.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[dpp = chFactoryFindPipe("mypipe");
- test_assert(dpp == NULL, "found");]]></value>
- </code>
- </step>
- </steps>
- </case>
- </cases>
- </sequence>
-
- </sequences>
- </instance>
- </instances>
- <exportedFeatures />
- </application>
- </SPC5-Config>
|