示例#1
0
FIXTURE_TEST_CASE(Test1LocalDep, EmptyFixture) {
    rc_t rc = 0;

    const char SRR413283[] = "SRR413283";

    VPath* acc = NULL;
    REQUIRE_RC(VFSManagerMakePath(vmgr, &acc, SRR413283));
    const VPath *local = NULL;
    REQUIRE_RC_FAIL(VResolverLocal(resolver, acc, &local));
    RELEASE(VPath, acc);

    const VDatabase *db = NULL;
    REQUIRE_RC(VDBManagerOpenDBRead(mgr, &db, NULL, SRR413283));

    const VDBDependencies *dep = NULL;

    //                                             missing
    REQUIRE_RC(VDatabaseListDependencies(db, &dep, true));
    uint32_t count = 1;
    REQUIRE_RC(VDBDependenciesCount(dep, &count));
    CHECK_EQUAL(count, (uint32_t)0);
    RELEASE(VDBDependencies, dep);

    REQUIRE_RC(VDatabaseListDependencies(db, &dep, false));
    REQUIRE_RC(VDBDependenciesCount(dep, &count));
    CHECK_EQUAL(count, (uint32_t)1);
    RELEASE(VDBDependencies, dep);

    RELEASE(VDatabase, db);
    RELEASE(VPath, local);
}
示例#2
0
FIXTURE_TEST_CASE(TestManyNoDep, EmptyFixture) {
    rc_t rc = 0;

    const char SRR543323[] = "SRR543323";

    VPath* acc = NULL;
    REQUIRE_RC(VFSManagerMakePath(vmgr, &acc, SRR543323));
    const VPath *local = NULL;
    REQUIRE_RC_FAIL(VResolverLocal(resolver, acc, &local));
    RELEASE(VPath, acc);

	struct VSchema *schema;
	REQUIRE_RC(VDBManagerMakeSRASchema(mgr, &schema));

    const VDatabase *db = NULL;
    REQUIRE_RC(VDBManagerOpenDBRead(mgr, &db, schema, SRR543323));
    REQUIRE_RC(VSchemaRelease(schema));

    const VDBDependencies *dep = NULL;

    //                                             missing
    REQUIRE_RC(VDatabaseListDependencies(db, &dep, true));
    uint32_t count = 1;
    REQUIRE_RC(VDBDependenciesCount(dep, &count));
    CHECK_EQUAL(count, (uint32_t)21);
    RELEASE(VDBDependencies, dep);

    REQUIRE_RC(VDatabaseListDependencies(db, &dep, false));
    REQUIRE_RC(VDBDependenciesCount(dep, &count));
    CHECK_EQUAL(count, (uint32_t)21);
    RELEASE(VDBDependencies, dep);

    RELEASE(VDatabase, db);
    RELEASE(VPath, local);
}
示例#3
0
文件: reref.c 项目: mariux/sratoolkit
static rc_t resolve_accession( VFSManager * vfs_mgr, const char * accession, const String ** path )
{
    VResolver * resolver;
    rc_t rc = VFSManagerGetResolver( vfs_mgr, &resolver );
    if ( rc == 0 )
    {
        const VPath * vpath;
        rc = VPathMakeSysPath( ( VPath** )&vpath, accession );
        if ( rc == 0 )
        {
            const VPath * rpath;
            rc = VResolverLocal( resolver, vpath, &rpath );
            if ( GetRCState( rc ) == rcNotFound )
                rc = VResolverRemote( resolver, vpath, &rpath, NULL );
            if ( rc == 0 )
            {
                const String * s;
                rc = VPathMakeString( rpath, &s );
                if ( rc == 0 )
                {
                    rc = StringCopy ( path, s );
                    free ((void*)s);
                }
                VPathRelease ( rpath );
            }
            VPathRelease ( vpath );
        }
        VResolverRelease( resolver );
    }
    return rc;
}
示例#4
0
FIXTURE_TEST_CASE(Test1YesDep, RefseqFixture) {
    if (siteless) {
        TEST_MESSAGE("Test skipped because site repository does not exist");
        return;
    }

    rc_t rc = 0;

    const VDatabase *db = NULL;
    const char SRR619505[] = "SRR619505";
    REQUIRE_RC(VDBManagerOpenDBRead(mgr, &db, NULL, SRR619505));
    RELEASE(VDatabase, db);

    VPath* acc = NULL;
    REQUIRE_RC(VFSManagerMakePath(vmgr, &acc, SRR619505));
    const VPath *local = NULL;
    REQUIRE_RC(VResolverLocal(resolver, acc, &local));
    RELEASE(VPath, acc);
    const String *s = NULL;
    REQUIRE_RC(VPathMakeString(local, &s));
    REQUIRE(s && s->addr);

    REQUIRE_RC(VDBManagerOpenDBRead(mgr, &db, NULL, s->addr));

    const VDBDependencies *dep = NULL;

    //                                             missing
    REQUIRE_RC(VDatabaseListDependencies(db, &dep, true));
    uint32_t count = 1;
    REQUIRE_RC(VDBDependenciesCount(dep, &count));
    CHECK_EQUAL(count, (uint32_t)0);
    RELEASE(VDBDependencies, dep);

    REQUIRE_RC(VDatabaseListDependencies(db, &dep, false));
    REQUIRE_RC(VDBDependenciesCount(dep, &count));
    CHECK_EQUAL(count, (uint32_t)1);
    RELEASE(VDBDependencies, dep);

    RELEASE(VDatabase, db);
    free(const_cast<String*>(s));
    RELEASE(VPath, local);
}
示例#5
0
string CVResolver::Resolve(const string& acc_or_path) const
{
    if ( !CVPath::IsPlainAccession(acc_or_path) ) {
        // already a path
        return acc_or_path;
    }
    CVPath acc(m_Mgr, acc_or_path, CVPath::eAcc);
    const VPath* path;
    rc_t rc = VResolverLocal(*this, acc, &path);
    if ( rc ) {
        rc = VResolverRemote(*this, eProtocolNone, acc, &path);
    }
    if ( rc ) {
        if ( CDirEntry(acc_or_path).Exists() ) {
            // local file
            return acc_or_path;
        }
        NCBI_THROW2_FMT(CSraException, eNotFound,
                        "Cannot find acc path: "<<acc_or_path, rc);
    }
    return CVPath(path).ToString();
}
示例#6
0
/* ResolveTablePath
 *  takes either an accession or path
 *  substitutes any arguments
 *  resolves via SRAPath mgr if present
 */
rc_t ResolveTablePath ( const SRAMgr *mgr,
    char *path, size_t psize, const char *spec, va_list args )
{
#if OLD_SRAPATH_MGR
    int len;
    char tblpath [ 4096 ];
    const SRAPath *pmgr = mgr -> _pmgr;

    /* if no path manager or if the spec string has embedded path separators,
       then this can't be an accession - just print it out */
    if ( mgr -> _pmgr == NULL || strchr( spec, '/' ) != NULL )
    {
        len = vsnprintf ( path, psize, spec, args );
        if ( len < 0 || ( size_t ) len >= psize )
            return RC ( rcSRA, rcTable, rcOpening, rcPath, rcExcessive );
        return 0;
    }

    /* create a copy - not likely to be too large */
    len = vsnprintf ( tblpath, sizeof tblpath, spec, args );
    if ( len < 0 || ( size_t ) len >= sizeof tblpath )
        return RC ( rcSRA, rcTable, rcOpening, rcPath, rcExcessive );

    /* test if the path exists in current directory, i.e. with assumed dot */
    if ( ! SRAPathTest ( pmgr, tblpath ) )
    {
        rc_t rc = SRAPathFind ( pmgr, tblpath, path, psize );
        if ( rc == 0 )
            return 0;
    }

    /* use the path given */
    if ( ( size_t ) len >= psize )
        return RC ( rcSRA, rcTable, rcOpening, rcBuffer, rcInsufficient );
    strcpy ( path, tblpath );

    return 0;
#else
    VFSManager *vfs;
    rc_t rc = VFSManagerMake ( & vfs );
    if ( rc == 0 )
    {
        VPath *accession;
        const VPath *tblpath = NULL;
        rc = VFSManagerVMakePath ( vfs, & accession, spec, args );
        if ( rc == 0 )
        {
            rc = VResolverLocal ( ( const VResolver* ) mgr -> _pmgr, accession, & tblpath );
            if ( rc == 0 )
            {
                size_t size;
                rc = VPathReadPath ( tblpath, path, psize, & size );
                VPathRelease ( tblpath );
            }
            VPathRelease ( accession );
        }

        VFSManagerRelease ( vfs );
    }
    return rc;
#endif
}