cfs/test/fsproc/fsFuncTest1.cc
// for the file pointed by kStatFilePath, stat().
// NOTE: if T1 is run after T2, it will not be executed.
//        because T2 will call tearDownFsProc() and set gFsProcPtr to nullptr.
for the file pointed by kStatFilePath, stat().
NOTE: if T1 is run after T2, it will not be executed.
because T2 will call tearDownFsProc() and set gFsProcPtr to nullptr.
for the file pointed by kStatFilePath stat () . NOTE : if T1 is run after T2 it will not be executed . because T2 will call tearDownFsProc () and set gFsProcPtr to nullptr .
TEST(FS_FUNC_TEST1, T1) {
  initFsProc(&gFsProcPtr, &devPtr, &gFsWorker, allTestsDone, kTestCaseNum);
  if (gFsProcPtr != nullptr) {
    EXPECT_NE(gFsWorker, nullptr);
    auto app = gFsWorker->testOnlyGetAppProc(0);
    MockAppProc mockApp(app);
    int curSid = 0;
    auto cop = mockApp.emulateGetClientOp(curSid);
    struct stat statbuf;
    fillStatOp(cop,  kStatFilePath, &statbuf);
    mockApp.emulateClientOpSubmit(curSid);
    int fsWorkerRecvSid = 0;
    cfs_tid_t curTid = cfsGetTid();
    FsWorkerLoadStatsLocal lpstats;
    auto startTs = tap_ustime();
    auto endTs = tap_ustime();
    int loopEffectiveNum = 0;
    while ((endTs - startTs) <= 1e6) {
      gFsWorker->workerRunLoopInner(&fsWorkerRecvSid, curTid, lpstats);
      if (lpstats.loopEffective) {
        loopEffectiveNum += 1;
      }
      endTs = tap_ustime();
    }
    EXPECT_EQ(cop->op.stat.ret, 0);
    EXPECT_EQ(cop->op.stat.statbuf.st_size, 0);
    EXPECT_GT(loopEffectiveNum, 0);
    allTestsDone[0] = 1;
    tearDownFsProc(&gFsProcPtr, &devPtr, &gFsWorker, allTestsDone);
  }
}
TEST ( FS_FUNC_TEST1 , T1 ) { initFsProc ( & gFsProcPtr , & devPtr , & gFsWorker , allTestsDone , kTestCaseNum ) ; if ( gFsProcPtr != nullptr ) { EXPECT_NE ( gFsWorker , nullptr ) ; auto app = gFsWorker -> testOnlyGetAppProc ( 0 ) ; MockAppProc mockApp ( app ) ; int curSid = 0 ; auto cop = mockApp . emulateGetClientOp ( curSid ) ; struct stat statbuf ; fillStatOp ( cop , kStatFilePath , & statbuf ) ; mockApp . emulateClientOpSubmit ( curSid ) ; int fsWorkerRecvSid = 0 ; cfs_tid_t curTid = cfsGetTid ( ) ; FsWorkerLoadStatsLocal lpstats ; auto startTs = tap_ustime ( ) ; auto endTs = tap_ustime ( ) ; int loopEffectiveNum = 0 ; while ( ( endTs - startTs ) <= 1e6 ) { gFsWorker -> workerRunLoopInner ( & fsWorkerRecvSid , curTid , lpstats ) ; if ( lpstats . loopEffective ) { loopEffectiveNum += 1 ; } endTs = tap_ustime ( ) ; } EXPECT_EQ ( cop -> op . stat . ret , 0 ) ; EXPECT_EQ ( cop -> op . stat . statbuf . st_size , 0 ) ; EXPECT_GT ( loopEffectiveNum , 0 ) ; allTestsDone [ 0 ] = 1 ; tearDownFsProc ( & gFsProcPtr , & devPtr , & gFsWorker , allTestsDone ) ; } }
for the file pointed by kStatFilePath, stat().
for the file pointed by kStatFilePath stat () .
// We do not allow gFsProcPtr to be initialized twice. /*path*/ // the return value of fs_stat() is 0 for normal case.