diff -r cf332d440466 -r 6a13fe0fc19e test/harness/testcaseio.c --- a/test/harness/testcaseio.c Fri Jan 27 23:59:51 2012 +0000 +++ b/test/harness/testcaseio.c Mon Jan 30 00:36:31 2012 +0000 @@ -4,6 +4,7 @@ #include #include #include "testcaseparser.h" +#include "testcaseinput.h" #include "testcaseio.h" /* @@ -15,7 +16,8 @@ { Testcase *testcase; TestcaseParser *parser; - char *s; + TestcaseInput *input=NULL; + char *s,*arg; const char *tag,*text; gboolean found_tag=FALSE; parser=testcase_parser_new_from_file(filename); @@ -34,12 +36,44 @@ *s='\0'; while(testcase_parser_get_next_tag(parser,&tag,&text)) { - if (!testcase->input && !strcmp(tag,"INPUT")) - testcase->input=g_strdup(text); + if (!input && !strcmp(tag,"INPUT")) + input=testcase_input_new("TEST-XXXXXX",text); + else if (g_str_has_prefix(tag,"INPUT(") && tag[strlen(tag)-1]==')') + { + arg=g_strndup(tag+6,strlen(tag)-7); + s=g_path_get_dirname(arg); + if (strcmp(s,".")) + { + /* + * Otherwise it would be possible to overwrite an arbitary + * file on somebody's computer by getting them to run a + * testcase! + */ + fprintf(stderr, + "%s: Input files may not have a directory component\n",arg); + g_free(s); + g_free(arg); + testcase_free(testcase); + testcase_parser_free(parser); + return NULL; + } + g_free(s); + testcase->inputs=g_slist_prepend(testcase->inputs, + testcase_input_new(arg,text)); + if (!strstr(arg,"XXXXXX")) + testcase->flags|=TESTCASE_TMP_DIR; + g_free(arg); + } else if (!testcase->expected && !strcmp(tag,"EXPECTED")) testcase->expected=g_strdup(text); else if (!testcase->encoding && !strcmp(tag,"ENCODING")) testcase->encoding=g_strchomp(g_strdup(text)); + else if (!testcase->encoding && !strcmp(tag,"OPTIONS")) + { + testcase->options=g_strsplit(text,"\n",0); + g_free(testcase->options[g_strv_length(testcase->options)-1]); + testcase->options[g_strv_length(testcase->options)-1]=NULL; + } else { fprintf(stderr,"%s: Not a valid testcase (%s)\n",filename,tag); @@ -61,6 +95,9 @@ testcase_parser_free(parser); return NULL; } + if (!input) + input=testcase_input_new("TEST-XXXXXX",NULL); + testcase->inputs=g_slist_prepend(testcase->inputs,input); testcase_parser_free(parser); return testcase; }