Changeset 38214 in vbox
- Timestamp:
- Jul 28, 2011 9:36:21 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstGuestCtrlParseBuffer.cpp
r38210 r38214 66 66 { "foo=bar2", 0, 50, 50, 0, VERR_INVALID_PARAMETER }, 67 67 /* Empty buffers. */ 68 { "", 1, 0, 1,0, VERR_MORE_DATA },69 { "\0", 1, 0, 1,0, VERR_MORE_DATA },68 { "", 1, 0, 1, 0, VERR_MORE_DATA }, 69 { "\0", 1, 0, 1, 0, VERR_MORE_DATA }, 70 70 /* Incomplete buffer (missing components). */ 71 { szUnterm1, 5, 0, 0,0, VERR_MORE_DATA },72 { "foo1", sizeof("foo1"), 0, 0,0, VERR_MORE_DATA },73 { "=bar\0", sizeof("=bar"), 0, 0, 0, VERR_MORE_DATA },71 { szUnterm1, 5, 0, 0, 0, VERR_MORE_DATA }, 72 { "foo1", sizeof("foo1"), 0, 0, 0, VERR_MORE_DATA }, 73 { "=bar\0", sizeof("=bar"), 0, 0, 0, VERR_MORE_DATA }, 74 74 /* Last sequence is incomplete -- new offset should point to it. */ 75 75 { "hug=sub\0incomplete", sizeof("hug=sub\0incomplete"), 0, sizeof("hug=sub"), 1, VERR_MORE_DATA }, … … 98 98 } aTests2[] = 99 99 { 100 { "\0\0\0\0", sizeof("\0\0\0\0"), 0, V ERR_MORE_DATA},100 { "\0\0\0\0", sizeof("\0\0\0\0"), 0, VINF_SUCCESS }, 101 101 { "off=rab\0\0zab=oob", sizeof("off=rab\0\0zab=oob"), 2, VINF_SUCCESS }, 102 102 { "\0\0\0soo=foo\0goo=loo\0\0zab=oob", sizeof("\0\0\0soo=foo\0goo=loo\0\0zab=oob"), 2, VINF_SUCCESS }, 103 { "qoo=uoo\0\0\0\0asdf=\0\0", sizeof("qoo=uoo\0\0\0\0asdf=\0\0"), 2, V ERR_MORE_DATA},104 { "foo=bar\0\0\0\0\0\0", sizeof("foo=bar\0\0\0\0\0\0"), 1, V ERR_MORE_DATA},105 { "qwer=cvbnr\0\0\0gui=uig\0\0\0", sizeof("qwer=cvbnr\0\0\0gui=uig\0\0\0"), 2, V ERR_MORE_DATA}103 { "qoo=uoo\0\0\0\0asdf=\0\0", sizeof("qoo=uoo\0\0\0\0asdf=\0\0"), 2, VINF_SUCCESS }, 104 { "foo=bar\0\0\0\0\0\0", sizeof("foo=bar\0\0\0\0\0\0"), 1, VINF_SUCCESS }, 105 { "qwer=cvbnr\0\0\0gui=uig\0\0\0", sizeof("qwer=cvbnr\0\0\0gui=uig\0\0\0"), 2, VINF_SUCCESS } 106 106 }; 107 107 … … 114 114 RTTestBanner(hTest); 115 115 116 RT Printf("Initializing COM...\n");116 RTTestIPrintf(RTTESTLVL_DEBUG, "Initializing COM...\n"); 117 117 rc = com::Initialize(); 118 118 if (FAILED(rc)) … … 142 142 GuestProcessStream stream; 143 143 int iResult = stream.AddData((BYTE*)aTests[iTest].pbData, aTests[iTest].cbData); 144 if (RT_ FAILURE(iResult))144 if (RT_SUCCESS(iResult)) 145 145 { 146 RTTestFailed(hTest, "\tAdding data returned %Rrc, expected VINF_SUCCESS", 147 iResult); 148 continue; 149 } 150 151 iResult = stream.Parse(); 152 153 if (iResult != aTests[iTest].iResult) 154 { 155 RTTestFailed(hTest, "\tReturned %Rrc, expected %Rrc", 156 iResult, aTests[iTest].iResult); 157 } 158 else if (stream.GetNumPairs() != aTests[iTest].uMapElements) 159 { 160 RTTestFailed(hTest, "\tMap has %u elements, expected %u", 161 stream.GetNumPairs(), aTests[iTest].uMapElements); 162 } 163 else if (stream.GetOffset() != aTests[iTest].uOffsetAfter) 164 { 165 RTTestFailed(hTest, "\tOffset %u wrong, expected %u", 166 uOffset, aTests[iTest].uOffsetAfter); 167 } 168 else if (iResult == VERR_MORE_DATA) 169 { 170 RTTestIPrintf(RTTESTLVL_DEBUG, "\tMore data (Offset: %u)\n", uOffset); 171 172 /* There is remaining data left in the buffer (which needs to be merged 173 * with a following buffer) -- print it. */ 174 size_t uToWrite = aTests[iTest].cbData - uOffset; 175 if (uToWrite) 176 { 177 const char *pszRemaining = aTests[iTest].pbData; 178 RTTestIPrintf(RTTESTLVL_DEBUG, "\tRemaining (%u):\n", uToWrite); 179 RTStrmWriteEx(g_pStdOut, &aTests[iTest].pbData[uOffset], uToWrite - 1, NULL); 180 RTTestIPrintf(RTTESTLVL_DEBUG, "\n"); 146 iResult = stream.Parse(); 147 if (iResult != aTests[iTest].iResult) 148 { 149 RTTestFailed(hTest, "\tReturned %Rrc, expected %Rrc", 150 iResult, aTests[iTest].iResult); 151 } 152 else if (stream.GetNumPairs() != aTests[iTest].uMapElements) 153 { 154 RTTestFailed(hTest, "\tMap has %u elements, expected %u", 155 stream.GetNumPairs(), aTests[iTest].uMapElements); 156 } 157 else if (stream.GetOffsetParser() != aTests[iTest].uOffsetAfter) 158 { 159 RTTestFailed(hTest, "\tOffset %u wrong, expected %u", 160 stream.GetOffsetParser(), aTests[iTest].uOffsetAfter); 161 } 162 else if (iResult == VERR_MORE_DATA) 163 { 164 RTTestIPrintf(RTTESTLVL_DEBUG, "\tMore data (Offset: %u)\n", uOffset); 165 166 /* There is remaining data left in the buffer (which needs to be merged 167 * with a following buffer) -- print it. */ 168 size_t uToWrite = aTests[iTest].cbData - uOffset; 169 if (uToWrite) 170 { 171 const char *pszRemaining = aTests[iTest].pbData; 172 RTTestIPrintf(RTTESTLVL_DEBUG, "\tRemaining (%u):\n", uToWrite); 173 RTStrmWriteEx(g_pStdOut, &aTests[iTest].pbData[uOffset], uToWrite - 1, NULL); 174 RTTestIPrintf(RTTESTLVL_DEBUG, "\n"); 175 } 181 176 } 182 177 } … … 198 193 { 199 194 iResult = stream.Parse(); 200 if (iResult == VERR_MORE_DATA) 201 uNumBlocks++; 195 RTTestIPrintf(RTTESTLVL_DEBUG, "\tReturned with %Rrc\n", iResult); 196 if ( iResult == VINF_SUCCESS 197 || iResult == VERR_MORE_DATA) 198 { 199 /* Only count block which have at least one pair. */ 200 if (stream.GetNumPairs()) 201 { 202 uNumBlocks++; 203 stream.ClearPairs(); 204 } 205 } 202 206 if (uNumBlocks > 32) 203 207 break; /* Give up if unreasonable big. */ … … 219 223 } 220 224 221 RT Printf("Shutting down COM...\n");225 RTTestIPrintf(RTTESTLVL_DEBUG, "Shutting down COM...\n"); 222 226 com::Shutdown(); 223 227
Note:
See TracChangeset
for help on using the changeset viewer.