Changeset 100679 in vbox for trunk/src/VBox/GuestHost/SharedClipboard
- Timestamp:
- Jul 21, 2023 2:19:42 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardHttpServer.cpp
r100676 r100679 33 33 #include <iprt/message.h> 34 34 #include <iprt/path.h> 35 #include <iprt/rand.h> 35 36 #include <iprt/string.h> 36 37 #include <iprt/test.h> … … 68 69 69 70 return RTTimeMilliTS() - msStartTS <= g_msRuntime ? VINF_SUCCESS : VERR_TIMEOUT; 71 } 72 73 static void tstCreateTransferSingle(RTTEST hTest, PSHCLTRANSFERCTX pTransferCtx, PSHCLHTTPSERVER pSrv, 74 const char *pszFile, PSHCLTXPROVIDER pProvider) 75 { 76 PSHCLTRANSFER pTx; 77 RTTEST_CHECK_RC_OK(hTest, ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, NULL /* Callbacks */, &pTx)); 78 RTTEST_CHECK_RC_OK(hTest, ShClTransferSetProvider(pTx, pProvider)); 79 RTTEST_CHECK_RC_OK(hTest, ShClTransferInit(pTx)); 80 RTTEST_CHECK_RC_OK(hTest, ShClTransferRootsInitFromFile(pTx, pszFile)); 81 RTTEST_CHECK_RC_OK(hTest, ShClTransferCtxRegister(pTransferCtx, pTx, NULL)); 82 RTTEST_CHECK_RC_OK(hTest, ShClTransferHttpServerRegisterTransfer(pSrv, pTx)); 70 83 } 71 84 … … 211 224 case VINF_GETOPT_NOT_OPTION: 212 225 { 213 PSHCLTRANSFER pTx; 214 RTTEST_CHECK_RC_OK(hTest, ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, NULL /* Callbacks */, &pTx)); 215 RTTEST_CHECK_RC_OK(hTest, ShClTransferSetProvider(pTx, &Provider)); 216 RTTEST_CHECK_RC_OK(hTest, ShClTransferInit(pTx)); 217 RTTEST_CHECK_RC_OK(hTest, ShClTransferRootsInitFromFile(pTx, ValueUnion.psz)); 218 RTTEST_CHECK_RC_OK(hTest, ShClTransferCtxRegister(&TxCtx, pTx, NULL)); 219 RTTEST_CHECK_RC_OK(hTest, ShClTransferHttpServerRegisterTransfer(&HttpSrv, pTx)); 226 tstCreateTransferSingle(hTest, &TxCtx, &HttpSrv, ValueUnion.psz, &Provider); 220 227 break; 221 228 } … … 226 233 } 227 234 235 char szRandomTestFile[RTPATH_MAX] = { 0 }; 236 228 237 uint32_t const cTx = ShClTransferCtxGetTotalTransfers(&TxCtx); 229 238 if (!cTx) 230 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "No files to serve specified!\n"); 239 { 240 RTTEST_CHECK_RC_OK(hTest, RTPathTemp(szRandomTestFile, sizeof(szRandomTestFile))); 241 RTTEST_CHECK_RC_OK(hTest, RTPathAppend(szRandomTestFile, sizeof(szRandomTestFile), "tstClipboardHttpServer-XXXXXX")); 242 RTTEST_CHECK_RC_OK(hTest, RTFileCreateTemp(szRandomTestFile, 0600)); 243 244 size_t cbExist = RTRandU32Ex(0, _256M); 245 246 RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "Random test file (%zu bytes): %s\n", cbExist, szRandomTestFile); 247 248 RTFILE hFile; 249 rc = RTFileOpen(&hFile, szRandomTestFile, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE); 250 if (RT_SUCCESS(rc)) 251 { 252 uint8_t abBuf[_64K] = { 42 }; 253 254 while (cbExist > 0) 255 { 256 size_t cbToWrite = sizeof(abBuf); 257 if (cbToWrite > cbExist) 258 cbToWrite = cbExist; 259 rc = RTFileWrite(hFile, abBuf, cbToWrite, NULL); 260 if (RT_FAILURE(rc)) 261 { 262 RTTestIFailed("RTFileWrite(%#x) -> %Rrc\n", cbToWrite, rc); 263 break; 264 } 265 cbExist -= cbToWrite; 266 } 267 268 RTTESTI_CHECK_RC(RTFileClose(hFile), VINF_SUCCESS); 269 270 if (RT_SUCCESS(rc)) 271 { 272 tstCreateTransferSingle(hTest, &TxCtx, &HttpSrv, szRandomTestFile, &Provider); 273 } 274 } 275 else 276 RTTestIFailed("RTFileOpen(%s) -> %Rrc\n", szRandomTestFile, rc); 277 } 278 279 if (RTTestErrorCount(hTest)) 280 return RTTestSummaryAndDestroy(hTest); 231 281 232 282 /* Create thread for our HTTP server. */ … … 241 291 } 242 292 243 244 293 if (RT_SUCCESS(rc)) 245 294 { … … 270 319 for (unsigned a = 0; a < 3; a++) /* Repeat downloads to stress things. */ 271 320 { 272 for (uint32_t i = 0; i < cTx; i++)321 for (uint32_t i = 0; i < ShClTransferCtxGetTotalTransfers(&TxCtx); i++) 273 322 { 274 323 PSHCLTRANSFER pTx = ShClTransferCtxGetTransferByIndex(&TxCtx, i); … … 299 348 ShClTransferCtxDestroy(&TxCtx); 300 349 350 if (strlen(szRandomTestFile)) 351 RTTEST_CHECK_RC_OK(hTest, RTFileDelete(szRandomTestFile)); 352 301 353 /* 302 354 * Summary
Note:
See TracChangeset
for help on using the changeset viewer.