<ahref="testqueues_8c.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">/*</span>
<aname="l00027"></a>00027 <spanclass="preprocessor">#include "<aclass="code"href="ch_8h.html"title="ChibiOS/RT main include file.">ch.h</a>"</span>
<aname="l00028"></a>00028 <spanclass="preprocessor">#include "<aclass="code"href="test_8h.html"title="Tests support header.">test.h</a>"</span>
<aname="l00100"></a>00100 <spanclass="comment">/* Initial empty state */</span>
<aname="l00101"></a>00101 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(1, <aclass="code"href="group__io__queues.html#ga01d87285eb173d213eb9849514969d7d"title="Evaluates to TRUE if the specified Input Queue is empty.">chIQIsEmpty</a>(&iq), <spanclass="stringliteral">"not empty"</span>);
<aname="l00106"></a>00106 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(2, <aclass="code"href="group__io__queues.html#ga3b87d6f7e4110c882b13870930db5cbb"title="Evaluates to TRUE if the specified Input Queue is full.">chIQIsFull</a>(&iq), <spanclass="stringliteral">"still has space"</span>);
<aname="l00107"></a>00107 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(3, <aclass="code"href="group__io__queues.html#ga23b72ba9803de5a20caa84ffd0c193fc"title="Input queue write.">chIQPutI</a>(&iq, 0) == <aclass="code"href="group__io__queues.html#ga6c462ef0a5b01afbd0d94a8e1ac8575a"title="Returned by the queue functions if the queue is full.">Q_FULL</a>, <spanclass="stringliteral">"failed to report Q_FULL"</span>);
<aname="l00110"></a>00110 <spanclass="keywordflow">for</span> (i = 0; i < TEST_QUEUES_SIZE; i++)
<aname="l00111"></a>00111 <aclass="code"href="group__test.html#gab3d9527d7616b3f9f8cba60cda0211a8"title="Emits a token into the tokens buffer.">test_emit_token</a>(<aclass="code"href="group__io__queues.html#ga677247f42b796cedc0c0b58a15c11794"title="Input queue read.">chIQGet</a>(&iq));
<aname="l00112"></a>00112 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(4, <aclass="code"href="group__io__queues.html#ga01d87285eb173d213eb9849514969d7d"title="Evaluates to TRUE if the specified Input Queue is empty.">chIQIsEmpty</a>(&iq), <spanclass="stringliteral">"still full"</span>);
<aname="l00119"></a>00119 <spanclass="comment">/* Reading the whole thing */</span>
<aname="l00120"></a>00120 n = <aclass="code"href="group__io__queues.html#gaddf6fc39af7d905c9f23afde14d8d764"title="Input queue read with timeout.">chIQReadTimeout</a>(&iq, wa[1], TEST_QUEUES_SIZE * 2, <aclass="code"href="group__scheduler.html#gad1ac15e9e5fc17810a94a779257f3d29"title="Zero time specification for some syscalls with a timeout specification.">TIME_IMMEDIATE</a>);
<aname="l00121"></a>00121 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(6, n == TEST_QUEUES_SIZE, <spanclass="stringliteral">"wrong returned size"</span>);
<aname="l00122"></a>00122 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(7, <aclass="code"href="group__io__queues.html#ga01d87285eb173d213eb9849514969d7d"title="Evaluates to TRUE if the specified Input Queue is empty.">chIQIsEmpty</a>(&iq), <spanclass="stringliteral">"still full"</span>);
<aname="l00123"></a>00123
<aname="l00124"></a>00124 <spanclass="comment">/* Queue filling again */</span>
<aname="l00125"></a>00125 <spanclass="keywordflow">for</span> (i = 0; i < TEST_QUEUES_SIZE; i++)
<aname="l00129"></a>00129 n = <aclass="code"href="group__io__queues.html#gaddf6fc39af7d905c9f23afde14d8d764"title="Input queue read with timeout.">chIQReadTimeout</a>(&iq, wa[1], TEST_QUEUES_SIZE / 2, <aclass="code"href="group__scheduler.html#gad1ac15e9e5fc17810a94a779257f3d29"title="Zero time specification for some syscalls with a timeout specification.">TIME_IMMEDIATE</a>);
<aname="l00130"></a>00130 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(8, n == TEST_QUEUES_SIZE / 2, <spanclass="stringliteral">"wrong returned size"</span>);
<aname="l00131"></a>00131 n = <aclass="code"href="group__io__queues.html#gaddf6fc39af7d905c9f23afde14d8d764"title="Input queue read with timeout.">chIQReadTimeout</a>(&iq, wa[1], TEST_QUEUES_SIZE / 2, <aclass="code"href="group__scheduler.html#gad1ac15e9e5fc17810a94a779257f3d29"title="Zero time specification for some syscalls with a timeout specification.">TIME_IMMEDIATE</a>);
<aname="l00132"></a>00132 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(9, n == TEST_QUEUES_SIZE / 2, <spanclass="stringliteral">"wrong returned size"</span>);
<aname="l00133"></a>00133 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(10, <aclass="code"href="group__io__queues.html#ga01d87285eb173d213eb9849514969d7d"title="Evaluates to TRUE if the specified Input Queue is empty.">chIQIsEmpty</a>(&iq), <spanclass="stringliteral">"still full"</span>);
<aname="l00137"></a>00137 <aclass="code"href="group__io__queues.html#ga2252ca3e5d6ee6d8d323d025365aee59"title="Resets an input queue.">chIQResetI</a>(&iq);
<aname="l00138"></a>00138 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(11, <aclass="code"href="group__io__queues.html#ga01d87285eb173d213eb9849514969d7d"title="Evaluates to TRUE if the specified Input Queue is empty.">chIQIsEmpty</a>(&iq), <spanclass="stringliteral">"still full"</span>);
<aname="l00141"></a>00141 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(12, <aclass="code"href="group__io__queues.html#ga142d0e885ac3a695f5f033a65f49abd0"title="Input queue read with timeout.">chIQGetTimeout</a>(&iq, 10) == <aclass="code"href="group__io__queues.html#gaed5efaf47ab37022f69e8080610bcb8b"title="Returned by the queue functions if a timeout occurs.">Q_TIMEOUT</a>, <spanclass="stringliteral">"wrong timeout return"</span>);
<aname="l00142"></a>00142 }
<aname="l00143"></a>00143
<aname="l00144"></a>00144 <spanclass="keyword">const</span><spanclass="keyword">struct </span><aclass="code"href="structtestcase.html"title="Structure representing a test case.">testcase</a> testqueues1 = {
<aname="l00173"></a>00173 <spanclass="comment">/* Initial empty state */</span>
<aname="l00174"></a>00174 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(1, <aclass="code"href="group__io__queues.html#gabf0eb1ba20cde6d4d9afa1139eaac19d"title="Evaluates to TRUE if the specified Output Queue is empty.">chOQIsEmpty</a>(&oq), <spanclass="stringliteral">"not empty"</span>);
<aname="l00179"></a>00179 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(2, <aclass="code"href="group__io__queues.html#gaca8b2bc8aae722ba9f47f21c358420f9"title="Evaluates to TRUE if the specified Output Queue is full.">chOQIsFull</a>(&oq), <spanclass="stringliteral">"still has space"</span>);
<aname="l00182"></a>00182 <spanclass="keywordflow">for</span> (i = 0; i < TEST_QUEUES_SIZE; i++)
<aname="l00183"></a>00183 <aclass="code"href="group__test.html#gab3d9527d7616b3f9f8cba60cda0211a8"title="Emits a token into the tokens buffer.">test_emit_token</a>(<aclass="code"href="group__io__queues.html#ga34a5a71f39e94fcfdd88935da92a8ce9"title="Output queue read.">chOQGetI</a>(&oq));
<aname="l00184"></a>00184 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(3, <aclass="code"href="group__io__queues.html#gabf0eb1ba20cde6d4d9afa1139eaac19d"title="Evaluates to TRUE if the specified Output Queue is empty.">chOQIsEmpty</a>(&oq), <spanclass="stringliteral">"still full"</span>);
<aname="l00186"></a>00186 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(5, <aclass="code"href="group__io__queues.html#ga34a5a71f39e94fcfdd88935da92a8ce9"title="Output queue read.">chOQGetI</a>(&oq) == <aclass="code"href="group__io__queues.html#ga9d3fcfacb433cb513882db4515ac348b"title="Returned by the queue functions if the queue is empty.">Q_EMPTY</a>, <spanclass="stringliteral">"failed to report Q_EMPTY"</span>);
<aname="l00187"></a>00187
<aname="l00188"></a>00188 <spanclass="comment">/* Writing the whole thing */</span>
<aname="l00189"></a>00189 n = <aclass="code"href="group__io__queues.html#ga1e90d41fa021107d72b1bed81186aae8"title="Output queue write with timeout.">chOQWriteTimeout</a>(&oq, wa[1], TEST_QUEUES_SIZE * 2, <aclass="code"href="group__scheduler.html#gad1ac15e9e5fc17810a94a779257f3d29"title="Zero time specification for some syscalls with a timeout specification.">TIME_IMMEDIATE</a>);
<aname="l00190"></a>00190 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(6, n == TEST_QUEUES_SIZE, <spanclass="stringliteral">"wrong returned size"</span>);
<aname="l00191"></a>00191 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(7, <aclass="code"href="group__io__queues.html#gaca8b2bc8aae722ba9f47f21c358420f9"title="Evaluates to TRUE if the specified Output Queue is full.">chOQIsFull</a>(&oq), <spanclass="stringliteral">"not full"</span>);
<aname="l00194"></a>00194 <aclass="code"href="group__io__queues.html#ga0a35a7de945e4b56b5fb5f5c8567e296"title="Resets an output queue.">chOQResetI</a>(&oq);
<aname="l00195"></a>00195 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(8, <aclass="code"href="group__io__queues.html#gabf0eb1ba20cde6d4d9afa1139eaac19d"title="Evaluates to TRUE if the specified Output Queue is empty.">chOQIsEmpty</a>(&oq), <spanclass="stringliteral">"still full"</span>);
<aname="l00198"></a>00198 n = <aclass="code"href="group__io__queues.html#ga1e90d41fa021107d72b1bed81186aae8"title="Output queue write with timeout.">chOQWriteTimeout</a>(&oq, wa[1], TEST_QUEUES_SIZE / 2, <aclass="code"href="group__scheduler.html#gad1ac15e9e5fc17810a94a779257f3d29"title="Zero time specification for some syscalls with a timeout specification.">TIME_IMMEDIATE</a>);
<aname="l00199"></a>00199 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(9, n == TEST_QUEUES_SIZE / 2, <spanclass="stringliteral">"wrong returned size"</span>);
<aname="l00200"></a>00200 n = <aclass="code"href="group__io__queues.html#ga1e90d41fa021107d72b1bed81186aae8"title="Output queue write with timeout.">chOQWriteTimeout</a>(&oq, wa[1], TEST_QUEUES_SIZE / 2, <aclass="code"href="group__scheduler.html#gad1ac15e9e5fc17810a94a779257f3d29"title="Zero time specification for some syscalls with a timeout specification.">TIME_IMMEDIATE</a>);
<aname="l00201"></a>00201 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(10, n == TEST_QUEUES_SIZE / 2, <spanclass="stringliteral">"wrong returned size"</span>);
<aname="l00202"></a>00202 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(11, <aclass="code"href="group__io__queues.html#gaca8b2bc8aae722ba9f47f21c358420f9"title="Evaluates to TRUE if the specified Output Queue is full.">chOQIsFull</a>(&oq), <spanclass="stringliteral">"not full"</span>);
<aname="l00205"></a>00205 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(12, <aclass="code"href="group__io__queues.html#ga3df1926602eb698119990b311b097ad9"title="Output queue write with timeout.">chOQPutTimeout</a>(&oq, 0, 10) == <aclass="code"href="group__io__queues.html#gaed5efaf47ab37022f69e8080610bcb8b"title="Returned by the queue functions if a timeout occurs.">Q_TIMEOUT</a>, <spanclass="stringliteral">"wrong timeout return"</span>);
<aname="l00206"></a>00206 }
<aname="l00207"></a>00207
<aname="l00208"></a>00208 <spanclass="keyword">const</span><spanclass="keyword">struct </span><aclass="code"href="structtestcase.html"title="Structure representing a test case.">testcase</a> testqueues2 = {
<aname="l00219"></a><aclass="code"href="testqueues_8h.html#afe1974bd4d756841503a8e97ecef5bec">00219</a><spanclass="keyword">const</span><spanclass="keyword">struct </span><aclass="code"href="structtestcase.html"title="Structure representing a test case.">testcase</a> * <spanclass="keyword">const</span><aclass="code"href="testqueues_8c.html#aabddff37abe7d59b774db69e4e9203c2"title="Test sequence for queues.">patternqueues</a>[] = {
Generated on Sun Oct 24 2010 09:40:38 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>