<ahref="testmbox_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="l00088"></a>00088 <aclass="code"href="group__mailboxes.html#gaff65b97bfdbf9144e9727a100a9be93a"title="Initializes a Mailbox object.">chMBInit</a>(&mb1, (<aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> *)test.wa.T0, MB_SIZE);
<aname="l00092"></a>00092 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg1, msg2;
<aname="l00098"></a>00098 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(1, <aclass="code"href="group__mailboxes.html#ga883666d096d855c8c372c0241fc47142"title="Returns the free space into the mailbox.">chMBGetEmpty</a>(&mb1) == MB_SIZE, <spanclass="stringliteral">"wrong size"</span>);
<aname="l00103"></a>00103 <spanclass="keywordflow">for</span> (i = 0; i < MB_SIZE - 1; i++) {
<aname="l00104"></a>00104 msg1 = <aclass="code"href="group__mailboxes.html#ga9bafcc634765886f59cf68c0e35d070d"title="Posts a message into a mailbox.">chMBPost</a>(&mb1, <spanclass="charliteral">'B'</span> + i, <aclass="code"href="group__scheduler.html#gae1568cf3090c973c3bc47f86ae2f5afb"title="Infinite time specification for all the syscalls with a timeout specification.">TIME_INFINITE</a>);
<aname="l00107"></a>00107 msg1 = <aclass="code"href="group__mailboxes.html#ga55c5b8890b78127bc1fa5a324252d5e6"title="Posts an high priority message into a mailbox.">chMBPostAhead</a>(&mb1, <spanclass="charliteral">'A'</span>, <aclass="code"href="group__scheduler.html#gae1568cf3090c973c3bc47f86ae2f5afb"title="Infinite time specification for all the syscalls with a timeout specification.">TIME_INFINITE</a>);
<aname="l00113"></a>00113 msg1 = <aclass="code"href="group__mailboxes.html#ga9bafcc634765886f59cf68c0e35d070d"title="Posts a message into a mailbox.">chMBPost</a>(&mb1, <spanclass="charliteral">'X'</span>, 1);
<aname="l00114"></a>00114 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(4, msg1 == <aclass="code"href="group__scheduler.html#gaf28d5427eeeb8f737cc7db495157780c"title="Low level message sent to a thread awakened by a timeout.">RDY_TIMEOUT</a>, <spanclass="stringliteral">"wrong wake-up message"</span>);
<aname="l00119"></a>00119 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(5, <aclass="code"href="group__mailboxes.html#ga883666d096d855c8c372c0241fc47142"title="Returns the free space into the mailbox.">chMBGetEmpty</a>(&mb1) == 0, <spanclass="stringliteral">"still empty"</span>);
<aname="l00120"></a>00120 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(6, <aclass="code"href="group__mailboxes.html#gad41c9e058c4a35cceeecbf21038f4c03"title="Returns the number of messages into the mailbox.">chMBGetFull</a>(&mb1) == MB_SIZE, <spanclass="stringliteral">"not full"</span>);
<aname="l00121"></a>00121 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(7, mb1.mb_rdptr == mb1.mb_wrptr, <spanclass="stringliteral">"pointers not aligned"</span>);
<aname="l00126"></a>00126 <spanclass="keywordflow">for</span> (i = 0; i < MB_SIZE; i++) {
<aname="l00127"></a>00127 msg1 = <aclass="code"href="group__mailboxes.html#ga61543bf11d0caa737f5818c67548c055"title="Retrieves a message from a mailbox.">chMBFetch</a>(&mb1, &msg2, <aclass="code"href="group__scheduler.html#gae1568cf3090c973c3bc47f86ae2f5afb"title="Infinite time specification for all the syscalls with a timeout specification.">TIME_INFINITE</a>);
<aname="l00129"></a>00129 <aclass="code"href="group__test.html#gab3d9527d7616b3f9f8cba60cda0211a8"title="Emits a token into the tokens buffer.">test_emit_token</a>(msg2);
<aname="l00136"></a>00136 msg1 = <aclass="code"href="group__mailboxes.html#ga9bafcc634765886f59cf68c0e35d070d"title="Posts a message into a mailbox.">chMBPost</a>(&mb1, <spanclass="charliteral">'B'</span> + i, <aclass="code"href="group__scheduler.html#gae1568cf3090c973c3bc47f86ae2f5afb"title="Infinite time specification for all the syscalls with a timeout specification.">TIME_INFINITE</a>);
<aname="l00138"></a>00138 msg1 = <aclass="code"href="group__mailboxes.html#ga61543bf11d0caa737f5818c67548c055"title="Retrieves a message from a mailbox.">chMBFetch</a>(&mb1, &msg2, <aclass="code"href="group__scheduler.html#gae1568cf3090c973c3bc47f86ae2f5afb"title="Infinite time specification for all the syscalls with a timeout specification.">TIME_INFINITE</a>);
<aname="l00146"></a>00146 msg1 = <aclass="code"href="group__mailboxes.html#ga61543bf11d0caa737f5818c67548c055"title="Retrieves a message from a mailbox.">chMBFetch</a>(&mb1, &msg2, 1);
<aname="l00147"></a>00147 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(14, msg1 == <aclass="code"href="group__scheduler.html#gaf28d5427eeeb8f737cc7db495157780c"title="Low level message sent to a thread awakened by a timeout.">RDY_TIMEOUT</a>, <spanclass="stringliteral">"wrong wake-up message"</span>);
<aname="l00152"></a>00152 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(15, <aclass="code"href="group__mailboxes.html#ga883666d096d855c8c372c0241fc47142"title="Returns the free space into the mailbox.">chMBGetEmpty</a>(&mb1) == MB_SIZE, <spanclass="stringliteral">"not empty"</span>);
<aname="l00153"></a>00153 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(16, <aclass="code"href="group__mailboxes.html#gad41c9e058c4a35cceeecbf21038f4c03"title="Returns the number of messages into the mailbox.">chMBGetFull</a>(&mb1) == 0, <spanclass="stringliteral">"still full"</span>);
<aname="l00154"></a>00154 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(17, mb1.mb_rdptr == mb1.mb_wrptr, <spanclass="stringliteral">"pointers not aligned"</span>);
<aname="l00159"></a>00159 <aclass="code"href="group__mailboxes.html#ga4199e224456395c3dbc74dbc889dff94"title="Resets a Mailbox object.">chMBReset</a>(&mb1);
<aname="l00164"></a>00164 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(18, <aclass="code"href="group__mailboxes.html#ga883666d096d855c8c372c0241fc47142"title="Returns the free space into the mailbox.">chMBGetEmpty</a>(&mb1) == MB_SIZE, <spanclass="stringliteral">"not empty"</span>);
<aname="l00165"></a>00165 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(19, <aclass="code"href="group__mailboxes.html#gad41c9e058c4a35cceeecbf21038f4c03"title="Returns the number of messages into the mailbox.">chMBGetFull</a>(&mb1) == 0, <spanclass="stringliteral">"still full"</span>);
<aname="l00166"></a>00166 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(20, mb1.mb_buffer == mb1.mb_wrptr, <spanclass="stringliteral">"write pointer not aligned to base"</span>);
<aname="l00167"></a>00167 <aclass="code"href="group__test.html#ga835cb17ca3869922b49435d95324a68b"title="Test assertion.">test_assert</a>(21, mb1.mb_buffer == mb1.mb_rdptr, <spanclass="stringliteral">"read pointer not aligned to base"</span>);
<aname="l00168"></a>00168 }
<aname="l00169"></a>00169
<aname="l00170"></a>00170 <spanclass="keyword">const</span><spanclass="keyword">struct </span><aclass="code"href="structtestcase.html"title="Structure representing a test case.">testcase</a> testmbox1 = {
<aname="l00182"></a><aclass="code"href="testmbox_8h.html#a45aeebc792cfcc14493abd2b854b4350">00182</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="testmbox_8c.html#a92dec0157564833faf1169169648dee9"title="Test sequence for mailboxes.">patternmbox</a>[] = {
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>