X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a94c908b9acf9a86f175c7f1c29b2c52e72eb2d2..4137195804cd6cf88d6077d42a80cd6b41e09814:/tools/tesh/run_context.c diff --git a/tools/tesh/run_context.c b/tools/tesh/run_context.c index ea3ec6e47a..c6113367ad 100644 --- a/tools/tesh/run_context.c +++ b/tools/tesh/run_context.c @@ -79,7 +79,7 @@ void rctx_init(void) struct sigaction newact; int i; fg_job = 0; - bg_jobs = xbt_dynar_new_sync(sizeof(rctx_t), kill_it); + bg_jobs = xbt_dynar_new(sizeof(rctx_t), kill_it); armageddon_mutex = xbt_os_mutex_init(); armageddon_initiator = NULL; sigwaiter_mutex = xbt_os_mutex_init(); @@ -325,6 +325,7 @@ void rctx_pushline(const char *filepos, char kind, char *line) rctx->is_empty = 0; xbt_strbuff_append(rctx->output_wanted, line); xbt_strbuff_append(rctx->output_wanted, "\n"); + XBT_DEBUG("wanted:%s",rctx->output_wanted->data); break; case '!': @@ -741,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; @@ -776,6 +777,22 @@ void *rctx_wait(void *r) xbt_dynar_free(&a); } + if (rctx->output_sort) { // Sorting output wanted + char *newbuf; + xbt_dynar_t a = xbt_str_split(rctx->output_wanted->data, "\n"); + + stable_sort(a); + /* If empty lines moved in first position, remove them */ + while (!xbt_dynar_is_empty(a) && *xbt_dynar_getfirst_as(a, char*) == '\0') + xbt_dynar_shift(a, NULL); + + newbuf = xbt_str_join(a, "\n"); + strcpy(rctx->output_wanted->data, newbuf); + rctx->output_wanted->used = strlen(newbuf); + xbt_free(newbuf); + + xbt_dynar_free(&a); + } xbt_strbuff_chomp(rctx->output_got); xbt_strbuff_chomp(rctx->output_wanted); xbt_strbuff_trim(rctx->output_got);