static void testAPI(RTTEST hTest) { testMappingsQuery(hTest); testMappingsQueryName(hTest); testMapFolder(hTest); testUnmapFolder(hTest); testCreate(hTest); testClose(hTest); testRead(hTest); testWrite(hTest); testLock(hTest); testFlush(hTest); testDirList(hTest); testReadLink(hTest); testFSInfo(hTest); testRemove(hTest); testRename(hTest); testSymlink(hTest); testMappingsAdd(hTest); testMappingsRemove(hTest); /* testSetStatusLed(hTest); */ }
int main(int argc, char **argv) { int status; rsComm_t *Comm; /* rErrMsg_t errMsg;*/ rodsArguments_t myRodsArgs; char *mySubName; char *myName; int didOne; rodsServerConfig_t serverConfig; Comm = (rsComm_t*)malloc (sizeof (rsComm_t)); memset (Comm, 0, sizeof (rsComm_t)); parseCmdLineOpt(argc, argv, "", 0, &myRodsArgs); rodsLogLevel(LOG_NOTICE); rodsLogSqlReq(1); if (argc < 2) { printf("Usage: test_chl testName [args...]\n"); exit(3); } status = getRodsEnv (&myEnv); if (status < 0) { rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d", status); exit (1); } if (strstr(myEnv.rodsDebug, "CAT") != NULL) { chlDebug(myEnv.rodsDebug); } memset(&serverConfig, 0, sizeof(serverConfig)); status = readServerConfig(&serverConfig); strncpy(Comm->clientUser.userName, myEnv.rodsUserName, sizeof Comm->clientUser.userName); strncpy(Comm->clientUser.rodsZone, myEnv.rodsZone, sizeof Comm->clientUser.rodsZone); /* char rodsUserName[NAME_LEN]; char rodsZone[NAME_LEN]; userInfo_t clientUser; char userName[NAME_LEN]; char rodsZone[NAME_LEN]; */ if ((status = chlOpen(serverConfig.DBUsername, serverConfig.DBPassword)) != 0) { rodsLog (LOG_SYS_FATAL, "initInfoWithRcat: chlopen Error. Status = %d", status); free(Comm); // cppcheck - Memory leak: Comm return (status); } didOne=0; if (strcmp(argv[1],"reg")==0) { status = testRegDataObj(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"regmulti")==0) { status = testRegDataMulti(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"mod")==0) { status = testModDataObjMeta(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"mod2")==0) { status = testModDataObjMeta2(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"modr")==0) { status = testModRuleMeta(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"modc")==0) { status = testModColl(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"rmrule")==0) { status = testDelRule(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"modrfs")==0) { status = testModResourceFreeSpace(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"rep")==0) { if (argc < 6) { printf("too few arguments\n"); exit(1); } status = testRegReplica(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } /* if (strcmp(argv[1],"cml")==0) { status = testCml(Comm); didOne=1; } */ if (strcmp(argv[1],"rmuser")==0) { status = testDelUser(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"mkdir")==0) { status = testRegColl(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"rmdir")==0) { status = testDelColl(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"sql")==0) { status = testSimpleQ(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"rm")==0) { status = testDelFile(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"rmtrash")==0) { status = testDelFileTrash(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"rmpriv")==0) { status = testDelFilePriv(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"chmod")==0) { status = testChmod(Comm, argv[2], argv[3], argv[4], argv[5]); didOne=1; } if (strcmp(argv[1],"regrule")==0) { status = testRegRule(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"rename")==0) { status = testRename(Comm, argv[2], argv[3]); testCurrent(Comm); /* exercise this as part of rename; testCurrent needs a SQL context */ didOne=1; } if (strcmp(argv[1],"login")==0) { status = testLogin(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"move")==0) { status = testMove(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"checkauth")==0) { status = testCheckAuth(Comm, argv[2], argv[3], argv[4]); didOne=1; } if (strcmp(argv[1],"temppw")==0) { status = testTempPw(Comm); didOne=1; } if (strcmp(argv[1],"tpc")==0) { status = testTempPwConvert(argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"tpw")==0) { status = testTempPwCombined(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"tpwforother")==0) { status = testTempPwForOther(Comm, argv[2], argv[3]); didOne=1; } if (strcmp(argv[1],"serverload")==0) { status = testServerLoad(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"purgeload")==0) { status = testPurgeServerLoad(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"serverdigest")==0) { status = testServerLoadDigest(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"purgedigest")==0) { status = testPurgeServerLoadDigest(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"checkquota")==0) { if (argc < 5) { status = testCheckQuota(Comm, argv[2], argv[3], NULL, NULL); } else { status = testCheckQuota(Comm, argv[2], argv[3], argv[4], argv[5]); } didOne=1; } if (strcmp(argv[1],"open")==0) { int i; for (i=0;i<3;i++) { status = chlClose(); if (status) { printf ("close %d error", i); } if ((status = chlOpen(serverConfig.DBUsername, serverConfig.DBPassword)) != 0) { rodsLog (LOG_SYS_FATAL, "initInfoWithRcat: chlopen %d Error. Status = %d", i, status); return (status); } } didOne=1; } if (strcmp(argv[1],"addrule")==0) { status = testAddRule(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]); didOne=1; } if (strcmp(argv[1],"versionrulebase")==0) { status = testVersionRuleBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"versiondvmbase")==0) { status = testVersionDvmBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"versionfnmbase")==0) { status = testVersionFnmBase(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"insfnmtable")==0) { status = testInsFnmTable(Comm, argv[2], argv[3], argv[4], argv[5] ); didOne=1; } if (strcmp(argv[1],"insdvmtable")==0) { status = testInsDvmTable(Comm, argv[2], argv[3], argv[4], argv[5] ); didOne=1; } if (strcmp(argv[1],"insmsrvctable")==0) { status = testInsMsrvcTable(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); if (status==0) { /* do it a second time to test another logic path and different SQL. Since no commit is part of the chl function, and there is not corresponding Delete call, this is an easy way to do this. */ status = testInsMsrvcTable(Comm, argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); } didOne=1; } if (strcmp(argv[1],"getlocalzone")==0) { status = testGetLocalZone(Comm, argv[2]); didOne=1; } if (strcmp(argv[1],"getpampw")==0) { status = testGetPamPw(Comm, argv[2], argv[3]); didOne=1; } if (status != 0) { /* if (Comm->rError) { rError_t *Err; rErrMsg_t *ErrMsg; int i, len; Err = Comm->rError; len = Err->len; for (i=0;i<len;i++) { ErrMsg = Err->errMsg[i]; rodsLog(LOG_ERROR, "Level %d: %s",i, ErrMsg->msg); } } */ myName = rodsErrorName(status, &mySubName); rodsLog (LOG_ERROR, "%s failed with error %d %s %s", argv[1], status, myName, mySubName); } else { if (didOne) printf("Completed successfully\n"); } if (didOne==0) { printf("Unknown test type: %s\n", argv[1]); } exit(status); }