int main(int argc, char **argv) { RTR3InitExe(argc, &argv, 0); /* * Process all arguments (including the executable). */ int cErrors = 0; for (int i = 0; i < argc; i++) { RTPrintf("tstRTFsQueries: '%s'...\n", argv[i]); uint32_t u32Serial; int rc = RTFsQuerySerial(argv[i], &u32Serial); if (RT_SUCCESS(rc)) RTPrintf("tstRTFsQueries: u32Serial=%#010RX32\n", u32Serial); else { RTPrintf("tstRTFsQueries: RTFsQuerySerial failed, rc=%Rrc\n", rc); cErrors++; } RTFOFF cbTotal = 42; RTFOFF cbFree = 42; uint32_t cbBlock = 42; uint32_t cbSector = 42; rc = RTFsQuerySizes(argv[i], &cbTotal, &cbFree, &cbBlock, &cbSector); if (RT_SUCCESS(rc)) RTPrintf("tstRTFsQueries: cbTotal=%RTfoff cbFree=%RTfoff cbBlock=%d cbSector=%d\n", cbTotal, cbFree, cbBlock, cbSector); else { RTPrintf("tstRTFsQueries: RTFsQuerySerial failed, rc=%Rrc\n", rc); cErrors++; } rc = RTFsQuerySizes(argv[i], NULL, NULL, NULL, NULL); if (RT_FAILURE(rc)) { RTPrintf("tstRTFsQueries: RTFsQuerySizes(nop) failed, rc=%Rrc\n", rc); cErrors++; } RTFSTYPE enmType; rc = RTFsQueryType(argv[i], &enmType); if (RT_SUCCESS(rc)) RTPrintf("tstRTFsQueries: file system type is '%s'\n", RTFsTypeName(enmType)); else { RTPrintf("tstRTFsQueries: RTFsQueryType failed, rc=%Rrc\n", rc); cErrors++; } RTFSPROPERTIES Props; rc = RTFsQueryProperties(argv[i], &Props); if (RT_SUCCESS(rc)) RTPrintf("tstRTFsQueries: cbMaxComponent=%u %s %s %s %s %s %s\n", Props.cbMaxComponent, Props.fCaseSensitive ? "case" : "not-case", Props.fCompressed ? "compressed" : "not-compressed", Props.fFileCompression ? "file-compression" : "no-file-compression", Props.fReadOnly ? "readonly" : "readwrite", Props.fRemote ? "remote" : "not-remote", Props.fSupportsUnicode ? "supports-unicode" : "doesn't-support-unicode"); else { RTPrintf("tstRTFsQueries: RTFsQueryProperties failed, rc=%Rrc\n", rc); cErrors++; } } if (!cErrors) RTPrintf("tstRTFsQueries: SUCCESS\n"); else RTPrintf("tstRTFsQueries: FAIlURE - %u errors\n", cErrors); return !!cErrors; }
int main() { int rc = RTTestInitAndCreate("tstRTFileAio", &g_hTest); if (rc) return rc; /* Check if the API is available. */ RTTestSub(g_hTest, "RTFileAioGetLimits"); RTFILEAIOLIMITS AioLimits; RT_ZERO(AioLimits); RTTESTI_CHECK_RC(rc = RTFileAioGetLimits(&AioLimits), VINF_SUCCESS); if (RT_SUCCESS(rc)) { RTTestSub(g_hTest, "Write"); RTFILE hFile; RTFSTYPE enmType; bool fAsyncMayFail = false; rc = RTFsQueryType("tstFileAio#1.tst", &enmType); if ( RT_SUCCESS(rc) && enmType == RTFSTYPE_TMPFS) fAsyncMayFail = true; rc = RTFileOpen(&hFile, "tstFileAio#1.tst", RTFILE_O_READWRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE | RTFILE_O_ASYNC_IO); RTTESTI_CHECK( rc == VINF_SUCCESS || (rc == VERR_ACCESS_DENIED && fAsyncMayFail)); if (RT_SUCCESS(rc)) { uint8_t *pbTestBuf = (uint8_t *)RTTestGuardedAllocTail(g_hTest, TSTFILEAIO_BUFFER_SIZE); for (unsigned i = 0; i < TSTFILEAIO_BUFFER_SIZE; i++) pbTestBuf[i] = i % 256; uint32_t cReqsMax = AioLimits.cReqsOutstandingMax < TSTFILEAIO_MAX_REQS_IN_FLIGHT ? AioLimits.cReqsOutstandingMax : TSTFILEAIO_MAX_REQS_IN_FLIGHT; /* Basic write test. */ RTTestIPrintf(RTTESTLVL_ALWAYS, "Preparing test file, this can take some time and needs quite a bit of harddisk space...\n"); tstFileAioTestReadWriteBasic(hFile, true /*fWrite*/, pbTestBuf, TSTFILEAIO_BUFFER_SIZE, 100*_1M, cReqsMax); /* Reopen the file before doing the next test. */ RTTESTI_CHECK_RC(RTFileClose(hFile), VINF_SUCCESS); if (RTTestErrorCount(g_hTest) == 0) { RTTestSub(g_hTest, "Read/Write"); RTTESTI_CHECK_RC(rc = RTFileOpen(&hFile, "tstFileAio#1.tst", RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_ASYNC_IO), VINF_SUCCESS); if (RT_SUCCESS(rc)) { tstFileAioTestReadWriteBasic(hFile, false /*fWrite*/, pbTestBuf, TSTFILEAIO_BUFFER_SIZE, 100*_1M, cReqsMax); RTFileClose(hFile); } } /* Cleanup */ RTFileDelete("tstFileAio#1.tst"); } } /* * Summary */ return RTTestSummaryAndDestroy(g_hTest); }