<ahref="test_8c.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">/*</span>
<aname="l00035"></a>00035 <spanclass="preprocessor">#include "<aclass="code"href="ch_8h.html"title="ChibiOS/RT main include file.">ch.h</a>"</span>
<aname="l00038"></a>00038 <spanclass="preprocessor">#include "<aclass="code"href="test_8h.html"title="Tests support header.">test.h</a>"</span>
<aname="l00039"></a>00039 <spanclass="preprocessor">#include "<aclass="code"href="testthd_8h.html"title="Threads and Scheduler test header file.">testthd.h</a>"</span>
<aname="l00040"></a>00040 <spanclass="preprocessor">#include "<aclass="code"href="testsem_8h.html"title="Semaphores test header file.">testsem.h</a>"</span>
<aname="l00041"></a>00041 <spanclass="preprocessor">#include "<aclass="code"href="testmtx_8h.html"title="Mutexes and CondVars test header file.">testmtx.h</a>"</span>
<aname="l00054"></a>00054 <spanclass="keyword">static</span><spanclass="keyword">const</span><spanclass="keyword">struct </span><aclass="code"href="structtestcase.html"title="Structure representing a test case.">testcase</a> **patterns[] = {
<aname="l00055"></a>00055 <aclass="code"href="testthd_8c.html#a0e03ba3eab1184efc52f1ecb594042ca"title="Test sequence for threads.">patternthd</a>,
<aname="l00056"></a>00056 <aclass="code"href="testsem_8c.html#a775d46d7f42a35bff0a0e9ff4ea52235"title="Test sequence for semaphores.">patternsem</a>,
<aname="l00057"></a>00057 <aclass="code"href="testmtx_8c.html#a642f97ab257fac66c224357081f84c9a"title="Test sequence for mutexes.">patternmtx</a>,
<aname="l00058"></a>00058 <aclass="code"href="testmsg_8c.html#ac111c8b66901d381cd6073425d269b1c"title="Test sequence for messages.">patternmsg</a>,
<aname="l00059"></a>00059 <aclass="code"href="testmbox_8c.html#a92dec0157564833faf1169169648dee9"title="Test sequence for mailboxes.">patternmbox</a>,
<aname="l00060"></a>00060 <aclass="code"href="testevt_8c.html#ac18f9a59a9f086d1752448b81d6af6e1"title="Test sequence for events.">patternevt</a>,
<aname="l00061"></a>00061 <aclass="code"href="testheap_8c.html#a5573379e505168afe49bf5d440911438"title="Test sequence for heap.">patternheap</a>,
<aname="l00062"></a>00062 patternpools,
<aname="l00063"></a>00063 <aclass="code"href="testdyn_8c.html#a52d5578e94aaa419c9687076097472e3"title="Test sequence for dynamic APIs.">patterndyn</a>,
<aname="l00064"></a>00064 <aclass="code"href="testqueues_8c.html#aabddff37abe7d59b774db69e4e9203c2"title="Test sequence for queues.">patternqueues</a>,
<aname="l00065"></a>00065 <aclass="code"href="testbmk_8c.html#a0872e725814c81578940e743e9a1cd61"title="Test sequence for benchmarks.">patternbmk</a>,
<aname="l00066"></a>00066 NULL
<aname="l00067"></a>00067 };
<aname="l00068"></a>00068
<aname="l00069"></a>00069 <spanclass="keyword">static</span><aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a> local_fail, global_fail;
<aname="l00120"></a>00120 <spanclass="keywordtype">void</span><aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="keywordtype">char</span> *msgp) {
<aname="l00131"></a>00131 <spanclass="keywordtype">void</span><aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="keywordtype">char</span> *msgp) {
<aname="l00132"></a>00132
<aname="l00133"></a>00133 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(msgp);
<aname="l00158"></a>00158 <spanclass="keywordtype">void</span><aclass="code"href="group__test.html#gab3d9527d7616b3f9f8cba60cda0211a8"title="Emits a token into the tokens buffer.">test_emit_token</a>(<spanclass="keywordtype">char</span> token) {
<aname="l00159"></a>00159
<aname="l00160"></a>00160 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00161"></a>00161 *tokp++ = token;
<aname="l00162"></a>00162 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00176"></a>00176 <aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a> _test_assert(<spanclass="keywordtype">unsigned</span> point, <aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a> condition) {
<aname="l00195"></a>00195 <aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a> _test_assert_time_window(<spanclass="keywordtype">unsigned</span> point, <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> start, <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> end) {
<aname="l00196"></a>00196
<aname="l00197"></a>00197 <spanclass="keywordflow">return</span> _test_assert(point, <aclass="code"href="group__time.html#ga47933e7381151ab9cc0888e53ced3847"title="Checks if the current system time is within the specified time window.">chTimeIsWithin</a>(start, end));
<aname="l00207"></a>00207 <spanclass="keywordtype">void</span><aclass="code"href="group__test.html#ga9415896a22ab615391028ec0852bc678"title="Pends a termination request in all the test-spawned threads.">test_terminate_threads</a>(<spanclass="keywordtype">void</span>) {
<aname="l00212"></a>00212 <aclass="code"href="group__threads.html#ga7ea7371fa41598ebd523622587ce3f22"title="Requests a thread termination.">chThdTerminate</a>(threads[i]);
<aname="l00218"></a>00218 <spanclass="keywordtype">void</span><aclass="code"href="group__test.html#ga361d9d2685d79754206ae8af370a303c"title="Waits for the completion of all the test-spawned threads.">test_wait_threads</a>(<spanclass="keywordtype">void</span>) {
<aname="l00223"></a>00223 <aclass="code"href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409"title="Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...">chThdWait</a>(threads[i]);
<aname="l00236"></a>00236 <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> start, end, now;
<aname="l00237"></a>00237
<aname="l00238"></a>00238 start = <aclass="code"href="group__threads.html#gaa36662628234799d205ff8c0cc6745c5"title="Returns a pointer to the current Thread.">chThdSelf</a>()->p_time;
<aname="l00239"></a>00239 end = start + <aclass="code"href="group__time.html#ga0a7e7bc6c6225bd9652c4f1567f1bc6a"title="Time conversion utility.">MS2ST</a>(duration);
<aname="l00241"></a>00241 now = <aclass="code"href="group__threads.html#gaa36662628234799d205ff8c0cc6745c5"title="Returns a pointer to the current Thread.">chThdSelf</a>()->p_time;
<aname="l00254"></a>00254 <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a><aclass="code"href="group__test.html#gac067dd7ee03b2c56d4d26ce9815ed3f7"title="Delays execution until next system time tick.">test_wait_tick</a>(<spanclass="keywordtype">void</span>) {
<aname="l00255"></a>00255
<aname="l00256"></a>00256 <aclass="code"href="group__threads.html#ga8b10a49e2ec522a5ddecabdc453afcab"title="Suspends the invoking thread for the specified time.">chThdSleep</a>(1);
<aname="l00257"></a>00257 <spanclass="keywordflow">return</span><aclass="code"href="group__time.html#ga137c8f67c450f34416a786d169be90e2"title="Current system time.">chTimeNow</a>();
<aname="l00264"></a>00264 <spanclass="comment">/** @brief Set to @p TRUE when the test timer reaches its deadline.*/</span>
<aname="l00265"></a><aclass="code"href="group__test.html#gad74c89f8a5049c1055b6a0f0596424b0">00265</a><aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a><aclass="code"href="group__test.html#gad74c89f8a5049c1055b6a0f0596424b0"title="Set to TRUE when the test timer reaches its deadline.">test_timer_done</a>;
<aname="l00279"></a>00279 <spanclass="keywordtype">void</span><aclass="code"href="group__test.html#gad4ce516117b9a9c8cd884c192c8f9bb1"title="Starts the test timer.">test_start_timer</a>(<spanclass="keywordtype">unsigned</span> ms) {
<aname="l00291"></a>00291 <spanclass="keyword">static</span><spanclass="keywordtype">void</span> execute_test(<spanclass="keyword">const</span><spanclass="keyword">struct</span><aclass="code"href="structtestcase.html"title="Structure representing a test case.">testcase</a> *tcp) {
<aname="l00297"></a>00297 <spanclass="keywordflow">for</span> (i = 0; i < MAX_THREADS; i++)
<aname="l00298"></a>00298 threads[i] = NULL;
<aname="l00299"></a>00299
<aname="l00300"></a>00300 <spanclass="keywordflow">if</span> (tcp-><aclass="code"href="structtestcase.html#a6834d2a8e6c4ba9047f548162f582b04"title="Test case preparation function.">setup</a> != NULL)
<aname="l00301"></a>00301 tcp-><aclass="code"href="structtestcase.html#a6834d2a8e6c4ba9047f548162f582b04"title="Test case preparation function.">setup</a>();
<aname="l00302"></a>00302 tcp-><aclass="code"href="structtestcase.html#af216996149ef003c44a83a57c57db2f0"title="Test case execution function.">execute</a>();
<aname="l00303"></a>00303 <spanclass="keywordflow">if</span> (tcp-><aclass="code"href="structtestcase.html#af49c801184c28dfd578bfe4a69a7f211"title="Test case clean up function.">teardown</a> != NULL)
<aname="l00304"></a>00304 tcp-><aclass="code"href="structtestcase.html#af49c801184c28dfd578bfe4a69a7f211"title="Test case clean up function.">teardown</a>();
<aname="l00305"></a>00305
<aname="l00306"></a>00306 <aclass="code"href="group__test.html#ga361d9d2685d79754206ae8af370a303c"title="Waits for the completion of all the test-spawned threads.">test_wait_threads</a>();
<aname="l00323"></a>00323 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__test.html#ga6b0a5b39f57674777d7b044e1a15603a"title="Test execution thread function.">TestThread</a>(<spanclass="keywordtype">void</span> *p) {
<aname="l00324"></a>00324 <spanclass="keywordtype">int</span> i, j;
<aname="l00325"></a>00325
<aname="l00326"></a>00326 chp = p;
<aname="l00327"></a>00327 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">""</span>);
<aname="l00328"></a>00328 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">"*** ChibiOS/RT test suite"</span>);
<aname="l00329"></a>00329 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">"***"</span>);
<aname="l00330"></a>00330 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"*** Kernel: "</span>);
<aname="l00331"></a>00331 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<aclass="code"href="group__kernel__info.html#gaf90f447ef5aa797647cbe5d1a6a958c3"title="Kernel version string.">CH_KERNEL_VERSION</a>);
<aname="l00333"></a>00333 <spanclass="preprocessor"></span><aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"*** GCC Version: "</span>);
<aname="l00334"></a>00334 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(__VERSION__);
<aname="l00336"></a>00336 <spanclass="preprocessor"></span><aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"*** Architecture: "</span>);
<aname="l00337"></a>00337 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<aclass="code"href="group__core.html#gaee128c531d64d5a635def6857fef3179"title="Name of the implemented architecture.">CH_ARCHITECTURE_NAME</a>);
<aname="l00339"></a>00339 <spanclass="preprocessor"></span><aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"*** Core Variant: "</span>);
<aname="l00340"></a>00340 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<aclass="code"href="group___a_v_r___c_o_r_e.html#gad807bcd87b78f852f9cdf25022c0f11b"title="Name of the architecture variant (optional).">CH_CORE_VARIANT_NAME</a>);
<aname="l00343"></a>00343 <spanclass="preprocessor"></span><aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"*** Platform: "</span>);
<aname="l00344"></a>00344 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<aclass="code"href="group___h_a_l___l_l_d.html#gaa4688daf0f1e6dda714351a6e5a394c2"title="Platform name.">PLATFORM_NAME</a>);
<aname="l00347"></a>00347 <spanclass="preprocessor"></span><aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"*** Test Board: "</span>);
<aname="l00348"></a>00348 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(BOARD_NAME);
<aname="l00350"></a>00350 <spanclass="preprocessor"></span><aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">""</span>);
<aname="l00358"></a>00358 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"--- Test Case "</span>);
<aname="l00359"></a>00359 <aclass="code"href="group__test.html#ga5551ca9506fe131cae2e4036c512cc98"title="Prints a decimal unsigned number.">test_printn</a>(i + 1);
<aname="l00360"></a>00360 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"."</span>);
<aname="l00361"></a>00361 <aclass="code"href="group__test.html#ga5551ca9506fe131cae2e4036c512cc98"title="Prints a decimal unsigned number.">test_printn</a>(j + 1);
<aname="l00362"></a>00362 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">" ("</span>);
<aname="l00363"></a>00363 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(patterns[i][j]->gettest());
<aname="l00364"></a>00364 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">")"</span>);
<aname="l00366"></a>00366 <spanclass="preprocessor"></span><aclass="code"href="group__threads.html#ga5aebc25e053a0094714abce4cad9f56f"title="Delays the invoking thread for the specified number of milliseconds.">chThdSleepMilliseconds</a>(<aclass="code"href="group__test.html#ga7417eac27c938fcd3e7bbbf36ea29d17"title="Delay inserted between test cases.">DELAY_BETWEEN_TESTS</a>);
<aname="l00370"></a>00370 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"--- Result: FAILURE (#"</span>);
<aname="l00371"></a>00371 <aclass="code"href="group__test.html#ga5551ca9506fe131cae2e4036c512cc98"title="Prints a decimal unsigned number.">test_printn</a>(failpoint);
<aname="l00372"></a>00372 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">" ["</span>);
<aname="l00373"></a>00373 print_tokens();
<aname="l00374"></a>00374 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">"])"</span>);
<aname="l00377"></a>00377 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">"--- Result: SUCCESS"</span>);
<aname="l00378"></a>00378 j++;
<aname="l00379"></a>00379 }
<aname="l00380"></a>00380 i++;
<aname="l00381"></a>00381 }
<aname="l00382"></a>00382 print_line();
<aname="l00383"></a>00383 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">""</span>);
<aname="l00384"></a>00384 <aclass="code"href="group__test.html#ga65f8ec6aa3d624a48d498f04efa2dce8"title="Prints a line without final end-of-line.">test_print</a>(<spanclass="stringliteral">"Final result: "</span>);
<aname="l00386"></a>00386 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">"FAILURE"</span>);
<aname="l00388"></a>00388 <aclass="code"href="group__test.html#gaf5e5d95b5ea7bd33f91ca52ee8088f4e"title="Prints a line.">test_println</a>(<spanclass="stringliteral">"SUCCESS"</span>);
<aname="l00389"></a>00389
<aname="l00390"></a>00390 <spanclass="keywordflow">return</span> (<aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a>)global_fail;
Generated on Sun Nov 28 2010 14:09:49 for ChibiOS/RT by <ahref="http://www.doxygen.org/index.html"><imgsrc="doxygen.png"alt="doxygen"align="middle"border="0"></a> 1.7.1</small></address>