コード例 #1
0
ファイル: test_genq.cpp プロジェクト: dthain/irods
int
main( int argc, char **argv ) {
    int i1 = 0, i2 = 0, i3 = 0, i = 0;
    genQueryInp_t genQueryInp;
    int i1a[10];
    int i2a[10];
    int done = 0;
    int mode = 0;
    char *condVal[2];
    char v1[20];

    /* remove this call or change to LOG_NOTICE for more verbosity */
    rodsLogLevel( LOG_ERROR );

    /* this will cause the sql to be printed, comment this out to skip it  */
    rodsLogSqlReq( 1 );

    i1 = 7;
    i2 = 5;

    done = 0;
    mode = 0;
    if ( argc >= 2 ) {
        if ( strcmp( argv[1], "gen" ) == 0 ) {
            mode = 1;
        }
        if ( strcmp( argv[1], "ls" ) == 0 ) {
            mode = 2;
        }
        if ( strcmp( argv[1], "gen2" ) == 0 ) {
            mode = 3;
        }
        if ( strcmp( argv[1], "gen3" ) == 0 ) {
            mode = 4;
        }
        if ( strcmp( argv[1], "gen4" ) == 0 ) {
            mode = 5;
        }
        if ( strcmp( argv[1], "gen5" ) == 0 ) {
            mode = 6;
        }
        if ( strcmp( argv[1], "gen6" ) == 0 ) {
            mode = 7;
        }
        if ( strcmp( argv[1], "gen7" ) == 0 ) {
            mode = 8;
        }
        if ( strcmp( argv[1], "gen8" ) == 0 ) {
            mode = 9;
        }
        if ( strcmp( argv[1], "gen9" ) == 0 ) {
            mode = 10;
        }
        if ( strcmp( argv[1], "gen10" ) == 0 ) {
            mode = 11;
        }
        if ( strcmp( argv[1], "gen11" ) == 0 ) {
            mode = 12;
        }
        if ( strcmp( argv[1], "gen12" ) == 0 ) {
            mode = 13;
        }
        if ( strcmp( argv[1], "gen13" ) == 0 ) {
            mode = 14;
        }
        if ( strcmp( argv[1], "lsr" ) == 0 ) {
            mode = 15;
        }
        if ( strcmp( argv[1], "gen15" ) == 0 ) {
            mode = 16;
        }
    }

    if ( argc == 3 && mode == 0 ) {
        i1 = atoi( argv[1] );
        i2 = atoi( argv[2] );
        sTest( i1, i2 );
        done++;
    }

    if ( argc == 4 && mode == 0 ) {
        i1 = atoi( argv[1] );
        i2 = atoi( argv[2] );
        i3 = atoi( argv[3] );
        sTest2( i1, i2, i3 );
        done++;
    }

    if ( argc == 2 && mode == 0 ) {
        int j;
        j = atoi( argv[1] );
        if ( j >= 0 ) {
            printf( "finding cycles starting with table %d\n", j );
            i = findCycles( j );
            printf( "status = %d\n", i );
        }
        else {
            printf( "finding cycles for all tables\n" );
            printf( "last test should be -816000 if last table finished\n" );
            i = 0;
            for ( j = 0; i == 0; j++ ) {
                i = findCycles( j );
                printf( "starting with table %d status = %d\n", j, i );
            }
            if ( j > 70 && i == CAT_INVALID_ARGUMENT ) {
                printf(
                    "Success: Searched all tables (0 to %d) and no cycles found\n",
                    j - 1 );
                exit( 0 );
            }
            else {
                exit( 5 );
            }
        }
        done++;
    }

    memset( ( char* )&genQueryInp, 0, sizeof( genQueryInp ) );

    genQueryInp.maxRows = 10;
    genQueryInp.continueInx = 0;
    /*
      (another test case that could be used)
    i1a[0]=COL_R_RESC_NAME;
    i1a[1]=COL_R_ZONE_NAME;
    i1a[2]=COL_R_TYPE_NAME;
    i1a[3]=COL_R_CLASS_NAME;
    */
    /*   i1a[0]=COL_COLL_INHERITANCE; */
    i1a[0] = COL_COLL_NAME;

    genQueryInp.selectInp.inx = i1a;
    genQueryInp.selectInp.len = 1;

    i2a[0] = COL_D_DATA_PATH;
    genQueryInp.sqlCondInp.inx = i2a;
    strcpy( v1, "='b'" );
    condVal[0] = v1;
    genQueryInp.sqlCondInp.value = condVal;
    genQueryInp.sqlCondInp.len = 1;

    if ( mode == 1 ) {
        if ( argc == 3 ) {
            i1a[0] = atoi( argv[2] );
        }
    }
    if ( done == 0 ) {
        int status;
        genQueryOut_t result;
        rodsEnv myEnv;

        memset( ( char * )&result, 0, sizeof( result ) );
        memset( ( char * )&myEnv, 0, sizeof( myEnv ) );
        status = getRodsEnv( &myEnv );
        if ( status < 0 ) {
            rodsLog( LOG_ERROR, "main: getRodsEnv error. status = %d",
                     status );
            exit( 1 );
        }

        // capture server properties
        irods::server_properties::getInstance().capture();

        if ( ( status = chlOpen() ) != 0 ) {

            rodsLog( LOG_SYS_FATAL,
                     "chlopen Error. Status = %d",
                     status );
            return status;
        }


        /* This is no longer ifdef'ed GEN_QUERY_AC (since msiAclPolicy
        now used), so just do it.   */
        chlGenQueryAccessControlSetup( myEnv.rodsUserName,
                                       myEnv.rodsZone,
                                       "",
                                       LOCAL_PRIV_USER_AUTH, 1 );

        if ( strstr( myEnv.rodsDebug, "CAT" ) != NULL ) {
            chlDebug( myEnv.rodsDebug );
        }

        if ( mode == 2 ) {
            /*	 doLs(); */
            doLs2();
            exit( 0 );
        }
        if ( mode == 3 ) {
            doTest2();
            exit( 0 );
        }
        if ( mode == 4 ) {
            doTest3();
            exit( 0 );
        }
        if ( mode == 5 ) {
            doTest4();
            exit( 0 );
        }
        if ( mode == 6 ) {
            doTest5();
            exit( 0 );
        }
        if ( mode == 7 ) {
            doTest6( argv[2] );
            exit( 0 );
        }

        if ( mode == 8 ) {
            status = doTest7( argv[2], argv[3], argv[4], argv[5] );
            if ( status < 0 ) {
                exit( 1 );
            }
            exit( 0 );
        }

        if ( mode == 9 ) {
            status = doTest8( argv[2], argv[3], argv[4] );
            if ( status < 0 ) {
                exit( 2 );
            }
            exit( 0 );
        }

        if ( mode == 10 ) {
            status = doTest9( argv[2], argv[3] );
            if ( status < 0 ) {
                exit( 2 );
            }
            exit( 0 );
        }

        if ( mode == 11 ) {
            status = doTest10( argv[2], argv[3], argv[4], argv[5] );
            if ( status < 0 ) {
                exit( 2 );
            }
            exit( 0 );
        }

        if ( mode == 12 ) {
            status = doTest11( argv[2], argv[3], argv[4], argv[5], argv[6] );
            if ( status < 0 ) {
                exit( 2 );
            }
            exit( 0 );
        }
        if ( mode == 13 ) {
            status = doTest12( argv[2], argv[3], argv[4], argv[5] );
            if ( status < 0 ) {
                exit( 2 );
            }
            exit( 0 );
        }
        if ( mode == 14 ) {
            status = doTest13( argv[2], argv[3], argv[4], argv[5], argv[6] );
            if ( status < 0 ) {
                exit( 2 );
            }
            exit( 0 );
        }
        if ( mode == 15 ) {
            try {
                int reps = boost::lexical_cast<int>( argv[2] );
                reps = reps > 0 && reps <= std::numeric_limits<int>::max() ? reps : 0;
                status = doLs3( reps );
            } catch ( boost::bad_lexical_cast e ) {
                exit( 2 );
            }
            if ( status < 0 ) {
                exit( 2 );
            }
            exit( 0 );
        }
        if ( mode == 16 ) {
            status = doTest15( argv[2], argv[3], argv[4] );
            if ( status < 0 ) {
                exit( 2 );
            }
            exit( 0 );
        }

        genQueryInp.maxRows = 2;
        i = chlGenQuery( genQueryInp, &result );
        printf( "chlGenQuery status=%d\n", i );
        printf( "result.rowCnt=%d\n", result.rowCnt );
        if ( result.rowCnt > 0 ) {
            int i;
            for ( i = 0; i < result.rowCnt; i++ ) {
                printf( "result.SqlResult[%d].value=%s\n", i,
                        result.sqlResult[i].value );
            }
        }
    }
    exit( 0 );
}
コード例 #2
0
ファイル: test_genu.c プロジェクト: UPPMAX/irods
int
main(int argc, char **argv) {
   int mode;
   rodsServerConfig_t serverConfig;
   int status;
   rodsEnv myEnv;

   /* remove this call or change to LOG_NOTICE for more verbosity */
   rodsLogLevel(LOG_ERROR);

   /* this will cause the sql to be printed, comment this out to skip it  */
   rodsLogSqlReq(1);

   mode = 0;
   if (strcmp(argv[1],"1")==0) mode=1;
   if (strcmp(argv[1],"2")==0) mode=2;
   if (strcmp(argv[1],"3")==0) mode=3;
   if (strcmp(argv[1],"4")==0) mode=4;
   if (strcmp(argv[1],"5")==0) mode=5;
   if (strcmp(argv[1],"6")==0) mode=6;

   memset((char *)&myEnv, 0, sizeof(myEnv));
   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);

   if ((status = chlOpen(serverConfig.DBUsername,
			 serverConfig.DBPassword)) != 0) {
      rodsLog (LOG_SYS_FATAL,
	       "chlopen Error. Status = %d",
	       status);
      return (status);
   }
   if (mode==1) {
      status = doTest1(argv[2], argv[3], argv[4], argv[5]);
      if (status <0) exit(2);
      exit(0);
   }
   if (mode==2) {
      status = doTest2(argv[2], argv[3], argv[4], argv[5]);
      if (status <0) exit(2);
      exit(0);
   }
   if (mode==3) {
      status = doTest3(argv[2], argv[3], argv[4], argv[5]);
      if (status <0) exit(2);
      exit(0);
   }
   if (mode==4) {
      status = doTest4(argv[2], argv[3], argv[4], argv[5]);
      if (status <0) exit(2);
      exit(0);
   }
   if (mode==5) {
      status = doTest5(argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]);
      if (status <0) exit(2);
      exit(0);
   }
   if (mode==6) {
      status = doTest6(argv[2], argv[3], argv[4], argv[5]);
      if (status <0) exit(2);
      exit(0);
   }
   exit(0);
}