void NaturalMappingSchemeTests::setUp() { // We need a built index as a fixture, and we don't want to rebuild it for // every test. // Set up a temporary directory to put the index in. tempDir = make_tempdir(); // Make a new index builder. FMDIndexBuilder builder(tempDir + "/index.basename"); // Add the haplotypes file builder.add(filename); // Finish the index. FMDIndex* tmpIndex = builder.build(); // Don't leak it. delete tmpIndex; // Save a pointer to a new index that we just load (so we don't have the // full SA). index = new FMDIndex(tempDir + "/index.basename"); // Make the mapping scheme, using a view of the whole index with no merging. scheme = new NaturalMappingScheme(FMDIndexView(*index)); }
FMDIndexTests::FMDIndexTests() { // We need a built index as a fixture, and we don't want to rebuild it for // every test. // Set up a temporary directory to put the index in. tempDir = make_tempdir(); // Make a new index builder. FMDIndexBuilder builder(tempDir + "/index.basename"); // Add the haplotypes file builder.add(filename); // Finish the index. FMDIndex* tmpIndex = builder.build(); // Don't leak it. delete tmpIndex; // Save a pointer to a new index that we just load (so we don't have the // full SA). index = new FMDIndex(tempDir + "/index.basename"); }
/* Expands %i and %o in the args to the full temp files within the temp directory. */ static int expand_args(struct exec_info *info,const char *args_in) { const char *ch = args_in; membuf_t command; info->flags.use_temp_files=0; info->flags.keep_temp_files=0; if(DBG_EXTPROG) log_debug("expanding string \"%s\"\n",args_in); init_membuf (&command, 100); while(*ch!='\0') { if(*ch=='%') { char *append=NULL; ch++; switch(*ch) { case 'O': info->flags.keep_temp_files=1; /* fall through */ case 'o': /* out */ if(!info->flags.madedir) { if(make_tempdir(info)) goto fail; } append=info->tempfile_out; info->flags.use_temp_files=1; break; case 'I': info->flags.keep_temp_files=1; /* fall through */ case 'i': /* in */ if(!info->flags.madedir) { if(make_tempdir(info)) goto fail; } append=info->tempfile_in; info->flags.use_temp_files=1; break; case '%': append="%"; break; } if(append) put_membuf_str (&command, append); } else put_membuf (&command, ch, 1); ch++; } put_membuf (&command, "", 1); /* Terminate string. */ info->command = get_membuf (&command, NULL); if (!info->command) return gpg_error_from_syserror (); if(DBG_EXTPROG) log_debug("args expanded to \"%s\", use %u, keep %u\n",info->command, info->flags.use_temp_files,info->flags.keep_temp_files); return 0; fail: xfree (get_membuf (&command, NULL)); return G10ERR_GENERAL; }
/* Expands %i and %o in the args to the full temp files within the temp directory. */ static int expand_args(struct exec_info *info,const char *args_in) { const char *ch=args_in; unsigned int size,len; info->use_temp_files=0; info->keep_temp_files=0; if(DBG_EXTPROG) log_debug("expanding string \"%s\"\n",args_in); size=100; info->command=m_alloc(size); len=0; info->command[0]='\0'; while(*ch!='\0') { if(*ch=='%') { char *append=NULL; ch++; switch(*ch) { case 'O': info->keep_temp_files=1; /* fall through */ case 'o': /* out */ if(!info->madedir) { if(make_tempdir(info)) goto fail; } append=info->tempfile_out; info->use_temp_files=1; break; case 'I': info->keep_temp_files=1; /* fall through */ case 'i': /* in */ if(!info->madedir) { if(make_tempdir(info)) goto fail; } append=info->tempfile_in; info->use_temp_files=1; break; case '%': append="%"; break; } if(append) { size_t applen=strlen(append); if(applen+len>size-1) { if(applen<100) applen=100; size+=applen; info->command=m_realloc(info->command,size); } strcat(info->command,append); len+=strlen(append); } } else { if(len==size-1) /* leave room for the \0 */ { size+=100; info->command=m_realloc(info->command,size); } info->command[len++]=*ch; info->command[len]='\0'; } ch++; } if(DBG_EXTPROG) log_debug("args expanded to \"%s\", use %d, keep %d\n", info->command,info->use_temp_files,info->keep_temp_files); return 0; fail: m_free(info->command); info->command=NULL; return G10ERR_GENERAL; }