X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7a2df1bb215ba4fe6dd20a73a510366fd47b1d17..e9b0dc96439383147b02491962e8ccf8cfdeff6b:/tools/tesh/tesh.c diff --git a/tools/tesh/tesh.c b/tools/tesh/tesh.c index bf02bf5d6d..fa34d0b136 100644 --- a/tools/tesh/tesh.c +++ b/tools/tesh/tesh.c @@ -54,12 +54,9 @@ static void handle_line(const char * filepos, char *line) { dir--; VERB1("Saw cd '%s'",dir); if (chdir(dir)) { - char buff[256]; - strerror_r(errno, buff, 256); - - perror(bprintf("Chdir to %s failed: %s",dir,buff)); - ERROR1("Test suite `%s': NOK (system error)",testsuite_name); - exit(4); + ERROR2("Chdir to %s failed: %s",dir,strerror(errno)); + ERROR1("Test suite `%s': NOK (system error)", testsuite_name); + rctx_armageddon(rctx,4); } break; } /* else, pushline */ @@ -80,7 +77,7 @@ static void handle_line(const char * filepos, char *line) { default: ERROR2("[%s] Syntax error: %s",filepos, line); ERROR1("Test suite `%s': NOK (syntax error)",testsuite_name); - exit(1); + rctx_armageddon(rctx,1); break; } } @@ -91,7 +88,7 @@ static void handle_suite(const char* filename, FILE* IN) { int line_num=0; char file_pos[256]; - buff_t buff=buff_new(); + xbt_strbuff_t buff=xbt_strbuff_new(); int buffbegin = 0; rctx = rctx_new(); @@ -113,7 +110,7 @@ static void handle_suite(const char* filename, FILE* IN) { ERROR1("[%d] Error: no command found in this chunk of lines.", buffbegin); ERROR1("Test suite `%s': NOK (syntax error)",testsuite_name); - exit(1); + rctx_armageddon(rctx,1); } if (rctx->cmd) rctx_start(); @@ -138,12 +135,12 @@ static void handle_suite(const char* filename, FILE* IN) { } if (buff->used || to_be_continued) { - buff_append(buff,line); + xbt_strbuff_append(buff,line); if (!to_be_continued) { snprintf(file_pos,256,"%s:%d",filename,buffbegin); handle_line(file_pos, buff->data); - buff_empty(buff); + xbt_strbuff_empty(buff); } } else { @@ -162,7 +159,7 @@ static void handle_suite(const char* filename, FILE* IN) { /* Clear buffers */ if (line) free(line); - buff_free(buff); + xbt_strbuff_free(buff); } @@ -184,6 +181,7 @@ int main(int argc,char *argv[]) { /* Find the description file */ if (argc == 1) { INFO0("Test suite from stdin"); + testsuite_name = xbt_strdup("(stdin)"); handle_suite("stdin",stdin); INFO0("Test suite from stdin OK"); @@ -204,11 +202,11 @@ int main(int argc,char *argv[]) { if (!IN) { perror(bprintf("Impossible to open the suite file `%s'",argv[i])); ERROR1("Test suite `%s': NOK (system error)",testsuite_name); - exit(1); + rctx_armageddon(rctx,1); } handle_suite(suitename,IN); rctx_wait_bg(); - fclose(IN); //->leads to segfault on amd64... + fclose(IN); INFO1("Test suite `%s' OK",suitename); free(suitename); }