Пример #1
0
/* =============================================================================================== */
rc_t test_ref_list( Args * args )
{
    uint32_t nodebug, skipempty;
    trans_opt opt;
    trans_ctx ctx;

    rc_t rc = make_trans_opt( &opt, args );
    if ( rc != 0 )
        LOGERR( klogInt, rc, "make_trans_opt() failed" );

    if ( rc == 0 )
        rc = get_uint32_option( args, OPTION_NDBG, &nodebug, 0 );
    if ( rc == 0 )
        rc = get_uint32_option( args, OPTION_SKE, &skipempty, 1 );

    if ( rc == 0 )
    {
        rc = make_trans_ctx( &ctx, &opt, true );
        if ( rc != 0 )
            LOGERR( klogInt, rc, "make_trans_ctx() failed" );
    }

    if ( rc == 0 )
    {
        if ( nodebug == 0 )
        {
            OUTMSG(( "testing ref_iterator on >%s<\n", opt.fname ));
        }
        /* ============================================================================= */
        rc = test_ref_iterator( &ctx, opt.ref_name, opt.ref_offset[0], opt.ref_len[0],
                                ( skipempty != 0 ), ( nodebug != 0 ) );
        /* ============================================================================= */
    }

    free_trans_ctx( &ctx );
    return rc;
}
Пример #2
0
rc_t CC KMain ( int argc, char *argv [] )
{
    Args * args;

    rc_t rc = ArgsMakeAndHandle ( &args, argc, argv, 1,
                QfileTestOptions, sizeof ( QfileTestOptions ) / sizeof ( OptDef ) );
    if ( rc != 0 )
    {
        OUTMSG(( "ArgsMakeAndHandle( ... ) failed: %R\n", rc ));
    }
    else
    {
        uint32_t arg_count = 0;
        rc = ArgsParamCount ( args, &arg_count );
        if ( rc != 0 )
        {
            OUTMSG(( "ArgsParamCount( ... ) failed: %R\n", rc ));
        }
        else
        {
            KDirectory *dir = NULL;
            uint64_t position = get_uint64_option( args, OPTION_POS, 0 );
            uint64_t count = get_uint64_option( args, OPTION_COUNT, 0 );
            uint32_t qsize = get_uint32_option( args, OPTION_QSIZE, 1024 );
            uint32_t bsize = get_uint32_option( args, OPTION_BSIZE, 0 );
            uint32_t csize = get_uint32_option( args, OPTION_CSIZE, 1024 );
            uint64_t pos2 = get_uint64_option( args, OPTION_POS2, 0 );

            OUTMSG(( "start-position : %lu\n", position ));
            if ( pos2 > 0 )
            {
                OUTMSG(( "2nd position   : %lu\n", pos2 ));
            }
            if ( count > 0 )
            {
                OUTMSG(( "count          : %lu\n", count ));
            }
            OUTMSG(( "queue-size     : %u\n",  qsize ));
            OUTMSG(( "block-size     : %u\n",  bsize ));
            OUTMSG(( "chunk-size     : %u\n",  csize ));

            rc = KDirectoryNativeDir( &dir );
            if ( rc != 0 )
            {
                OUTMSG(( "KDirectoryNativeDir( ... ) failed: %R\n", rc ));
            }
            else
            {
                uint32_t i;
                for ( i = 0; i < arg_count && rc == 0; ++i )
                {
                    const char * filename;
                    rc = ArgsParamValue ( args, i, &filename );
                    if ( rc != 0 )
                    {
                        OUTMSG(( "ArgsParamValue( %d ) failed: %R\n", i, rc ));
                    }
                    else
                    {
                        OUTMSG(( "file to read   : '%s'\n", filename ));
                        rc = perform_test( dir, filename, position, pos2,
                                           count, qsize, bsize, csize );
                    }
                }
                KDirectoryRelease( dir );
            }
        }
        ArgsWhack ( args );
    }

    return rc;
}