From: Paul Bédaride Date: Fri, 29 Mar 2013 16:29:03 +0000 (+0100) Subject: Tesh sort wanted output X-Git-Tag: v3_9_90~412^2~69 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/97205f69c3ff45b271a439e9feedd372c587656e?hp=f58c9bcd23aa191e8071a41450d00dda0d182e34 Tesh sort wanted output --- diff --git a/tools/tesh/run_context.c b/tools/tesh/run_context.c index f58c80edc9..747976806c 100644 --- a/tools/tesh/run_context.c +++ b/tools/tesh/run_context.c @@ -742,7 +742,7 @@ void *rctx_wait(void *r) return NULL; xbt_os_mutex_acquire(rctx->interruption); */ - { + { // Sorting output got xbt_dynar_t a = xbt_str_split(rctx->output_got->data, "\n"); xbt_dynar_t b = xbt_dynar_new(sizeof(char *), NULL); unsigned cpt; @@ -777,6 +777,40 @@ void *rctx_wait(void *r) xbt_dynar_free(&a); } + { // Sorting output wanted + xbt_dynar_t a = xbt_str_split(rctx->output_wanted->data, "\n"); + xbt_dynar_t b = xbt_dynar_new(sizeof(char *), NULL); + unsigned cpt; + char *str; + xbt_dynar_foreach(a, cpt, str) { + if (strncmp(str, "TESH_ERROR ", (sizeof "TESH_ERROR ") - 1) == 0) { + XBT_CRITICAL("%s", str); + errcode = 1; + } else if (coverage && + strncmp(str, "profiling:", (sizeof "profiling:") - 1) == 0) { + XBT_DEBUG("Remove line [%u]: '%s'", cpt, str); + } else { + xbt_dynar_push_as(b, char *, str); + } + } + + if (rctx->output_sort) { + stable_sort(b); + /* If empty lines moved in first position, remove them */ + while (!xbt_dynar_is_empty(b) && *xbt_dynar_getfirst_as(b, char*) == '\0') + xbt_dynar_shift(b, NULL); + } + + if (rctx->output_sort || xbt_dynar_length(b) != xbt_dynar_length(a)) { + char *newbuf = xbt_str_join(b, "\n"); + strcpy(rctx->output_wanted->data, newbuf); + rctx->output_wanted->used = strlen(newbuf); + xbt_free(newbuf); + } + + xbt_dynar_free(&b); + xbt_dynar_free(&a); + } xbt_strbuff_chomp(rctx->output_got); xbt_strbuff_chomp(rctx->output_wanted); xbt_strbuff_trim(rctx->output_got);