1 /* run_context -- stuff in which TESH runs a command */
3 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include <sys/types.h>
17 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
20 xbt_dynar_t bg_jobs = NULL;
21 rctx_t armageddon_initiator = NULL;
22 xbt_os_mutex_t armageddon_mutex = NULL;
26 } oldact[3]; /* SIGINT, SIGQUIT, SIGTERM */
28 xbt_os_thread_t sigwaiter_thread;
29 xbt_os_mutex_t sigwaiter_mutex;
30 xbt_os_cond_t sigwaiter_cond;
31 int armageddon_requested = 0;
32 int caught_signum = 0;
38 static void armageddon_sighandler(int signum)
40 xbt_os_mutex_acquire(sigwaiter_mutex);
41 caught_signum = signum;
42 armageddon_requested = 1;
43 xbt_os_cond_signal(sigwaiter_cond);
44 xbt_os_mutex_release(sigwaiter_mutex);
47 static void *armageddon_sigwaiter(_XBT_GNUC_UNUSED void *arg)
49 xbt_os_mutex_acquire(sigwaiter_mutex);
50 /* Inform main thread that it started. */
51 xbt_os_cond_signal(sigwaiter_cond);
52 /* Wait for ending signal... */
53 xbt_os_cond_wait(sigwaiter_cond, sigwaiter_mutex);
54 if (armageddon_requested) {
55 ERROR2("Test suite `%s': caught signal %d", testsuite_name, caught_signum);
56 rctx_armageddon(rctx, 3);
58 xbt_os_mutex_release(sigwaiter_mutex);
62 static void wait_it(rctx_t rctx)
64 VERB2("Join thread %p which were running background cmd <%s>",
65 rctx->runner, rctx->filepos);
66 xbt_os_thread_join(rctx->runner, NULL);
69 static void kill_it(void *r)
71 rctx_t rctx = *(rctx_t *) r;
78 struct sigaction newact;
81 bg_jobs = xbt_dynar_new_sync(sizeof(rctx_t), kill_it);
82 armageddon_mutex = xbt_os_mutex_init();
83 armageddon_initiator = NULL;
84 sigwaiter_mutex = xbt_os_mutex_init();
85 sigwaiter_cond = xbt_os_cond_init();
86 xbt_os_mutex_acquire(sigwaiter_mutex);
87 sigwaiter_thread = xbt_os_thread_create("Armaggedon request waiter",
88 armageddon_sigwaiter, NULL, NULL);
89 /* Wait for thread to start... */
90 xbt_os_cond_wait(sigwaiter_cond, sigwaiter_mutex);
91 xbt_os_mutex_release(sigwaiter_mutex);
92 memset(&newact, 0, sizeof(newact));
93 newact.sa_handler = armageddon_sighandler;
94 oldact[0].num = SIGINT;
95 oldact[1].num = SIGQUIT;
96 oldact[2].num = SIGTERM;
97 for (i = 0; i < 3; i++)
98 sigaction(oldact[i].num, &newact, &oldact[i].act);
104 for (i = 0; i < 3; i++)
105 sigaction(oldact[i].num, &oldact[i].act, NULL);
106 xbt_os_cond_signal(sigwaiter_cond);
107 xbt_os_thread_join(sigwaiter_thread, NULL);
108 xbt_dynar_free(&bg_jobs);
109 xbt_os_cond_destroy(sigwaiter_cond);
110 xbt_os_mutex_destroy(sigwaiter_mutex);
111 xbt_os_mutex_destroy(armageddon_mutex);
114 void rctx_wait_bg(void)
116 /* Do not use xbt_dynar_free or it will lock the dynar, preventing armageddon
118 while (xbt_dynar_length(bg_jobs)) {
119 rctx_t rctx = xbt_dynar_getlast_as(bg_jobs, rctx_t);
121 xbt_dynar_pop(bg_jobs, &rctx);
124 xbt_dynar_reset(bg_jobs);
127 static void rctx_armageddon_kill_one(rctx_t initiator, const char *filepos,
130 if (rctx != initiator) {
131 INFO2("Kill <%s> because <%s> failed", rctx->filepos, filepos);
132 xbt_os_mutex_acquire(rctx->interruption);
133 if (!rctx->reader_done) {
134 rctx->interrupted = 1;
135 kill(rctx->pid, SIGTERM);
137 kill(rctx->pid, SIGKILL);
139 xbt_os_mutex_release(rctx->interruption);
143 void rctx_armageddon(rctx_t initiator, int exitcode)
147 const char *filepos = initiator && initiator->filepos ?
148 initiator->filepos : "(master)";
150 DEBUG2("Armageddon request by <%s> (exit=%d)", filepos, exitcode);
151 xbt_os_mutex_acquire(armageddon_mutex);
152 if (armageddon_initiator != NULL) {
153 VERB0("Armageddon already started. Let it go");
154 xbt_os_mutex_release(armageddon_mutex);
157 DEBUG1("Armageddon request by <%s> got the lock. Let's go amok",
159 armageddon_initiator = initiator;
160 xbt_os_mutex_release(armageddon_mutex);
162 /* Kill foreground command */
164 rctx_armageddon_kill_one(initiator, filepos, rctx);
166 /* Kill any background commands */
167 xbt_dynar_foreach(bg_jobs, cursor, job) {
168 rctx_armageddon_kill_one(initiator, filepos, job);
171 /* Give runner threads a chance to acknowledge the processes deaths */
173 /* Ensure that nobody is running rctx_wait on exit */
175 xbt_os_mutex_acquire(rctx->interruption);
176 xbt_dynar_foreach(bg_jobs, cursor, job)
177 xbt_os_mutex_acquire(job->interruption);
178 VERB0("Shut everything down!");
186 void rctx_empty(rctx_t rc)
195 /* avoid race with rctx_armageddon log messages */
196 filepos = rc->filepos;
200 for (i = 0, env_it = environ; *env_it; i++, env_it++);
202 for (env_it = rctx->env + i; *env_it; env_it++)
206 rc->env_size = i + 1;
207 rc->env = malloc(rc->env_size * sizeof(char *));
208 memcpy(rc->env, environ, rc->env_size * sizeof(char *));
211 rc->is_background = 0;
212 rc->is_stoppable = 0;
213 rc->output = e_output_check;
218 xbt_strbuff_empty(rc->input);
219 xbt_strbuff_empty(rc->output_wanted);
220 xbt_strbuff_empty(rc->output_got);
226 rctx_t res = xbt_new0(s_rctx_t, 1);
228 res->input = xbt_strbuff_new();
229 res->output_sort = 0;
230 res->output_wanted = xbt_strbuff_new();
231 res->output_got = xbt_strbuff_new();
232 res->interruption = xbt_os_mutex_init();
237 void rctx_free(rctx_t rctx)
239 DEBUG1("RCTX: Free %p", rctx);
240 rctx_dump(rctx, "free");
251 for (i = 0, env_it = environ; *env_it; i++, env_it++);
252 for (env_it = rctx->env + i; *env_it; env_it++)
256 xbt_os_mutex_destroy(rctx->interruption);
257 xbt_strbuff_free(rctx->input);
258 xbt_strbuff_free(rctx->output_got);
259 xbt_strbuff_free(rctx->output_wanted);
263 void rctx_dump(rctx_t rctx, const char *str)
265 DEBUG9("%s RCTX %p={in%p={%d,%10s}, want={%d,%10s}, out={%d,%10s}}",
267 rctx->input, rctx->input->used, rctx->input->data,
268 rctx->output_wanted->used, rctx->output_wanted->data,
269 rctx->output_got->used, rctx->output_got->data);
270 DEBUG5("%s RCTX %p=[cmd%p=%10s, pid=%d]",
271 str, rctx, rctx->cmd, rctx->cmd, rctx->pid);
276 * Getting instructions from the file
279 void rctx_pushline(const char *filepos, char kind, char *line)
286 if (!rctx->is_empty) {
288 ("[%s] More than one command in this chunk of lines (previous: %s).\n"
289 " Cannot guess which input/output belongs to which command.",
291 ERROR1("Test suite `%s': NOK (syntax error)", testsuite_name);
292 rctx_armageddon(rctx, 1);
296 VERB1("[%s] More than one command in this chunk of lines", filepos);
299 rctx->is_background = 1;
301 rctx->is_background = 0;
303 rctx->cmd = xbt_strdup(line);
304 rctx->filepos = xbt_strdup(filepos);
305 INFO3("[%s] %s%s", filepos, rctx->cmd,
306 ((rctx->is_background) ? " (background command)" : ""));
312 xbt_strbuff_append(rctx->input, line);
313 xbt_strbuff_append(rctx->input, "\n");
318 xbt_strbuff_append(rctx->output_wanted, line);
319 xbt_strbuff_append(rctx->output_wanted, "\n");
326 if (!strncmp(line, "timeout no", strlen("timeout no"))) {
327 VERB1("[%s] (disable timeout)", filepos);
329 } else if (!strncmp(line, "timeout ", strlen("timeout "))) {
330 timeout_value = atoi(line + strlen("timeout"));
331 VERB2("[%s] (new timeout value: %d)", filepos, timeout_value);
333 } else if (!strncmp(line, "expect signal ", strlen("expect signal "))) {
334 rctx->expected_signal = strdup(line + strlen("expect signal "));
335 xbt_str_trim(rctx->expected_signal, " \n");
336 VERB2("[%s] (next command must raise signal %s)",
337 filepos, rctx->expected_signal);
339 } else if (!strncmp(line, "expect return ", strlen("expect return "))) {
340 rctx->expected_return = atoi(line + strlen("expect return "));
341 VERB2("[%s] (next command must return code %d)",
342 filepos, rctx->expected_return);
344 } else if (!strncmp(line, "output sort", strlen("output sort"))) {
345 rctx->output_sort = 1;
346 VERB1("[%s] (sort output of next command)", filepos);
348 } else if (!strncmp(line, "output ignore", strlen("output ignore"))) {
349 rctx->output = e_output_ignore;
350 VERB1("[%s] (ignore output of next command)", filepos);
352 } else if (!strncmp(line, "output display", strlen("output display"))) {
353 rctx->output = e_output_display;
354 VERB1("[%s] (ignore output of next command)", filepos);
356 } else if (!strncmp(line, "setenv ", strlen("setenv "))) {
357 int len = strlen("setenv ");
358 char *eq = strchr(line + len, '=');
359 char *key = bprintf("%.*s", (int) (eq - line - len), line + len);
360 xbt_dict_set(env, key, xbt_strdup(eq + 1), xbt_free_f);
363 rctx->env = realloc(rctx->env, ++(rctx->env_size) * sizeof(char *));
364 rctx->env[rctx->env_size - 2] = xbt_strdup(line + len);
365 rctx->env[rctx->env_size - 1] = NULL;
366 VERB2("[%s] setenv %s", filepos, line + len);
369 ERROR2("%s: Malformed metacommand: %s", filepos, line);
370 ERROR1("Test suite `%s': NOK (syntax error)", testsuite_name);
371 rctx_armageddon(rctx, 1);
379 * Actually doing the job
382 /* The IO of the childs are handled by the two following threads
383 (one pair per child) */
385 static void *thread_writer(void *r)
388 rctx_t rctx = (rctx_t) r;
389 for (posw = 0; posw < rctx->input->used && !rctx->brokenpipe;) {
391 DEBUG1("Still %d chars to write", rctx->input->used - posw);
393 write(rctx->child_to, rctx->input->data + posw,
394 rctx->input->used - posw);
398 if (errno == EPIPE) {
399 rctx->brokenpipe = 1;
400 } else if (errno != EINTR && errno != EAGAIN && errno != EPIPE) {
401 perror("Error while writing input to child");
402 ERROR1("Test suite `%s': NOK (system error)", testsuite_name);
403 rctx_armageddon(rctx, 4);
407 DEBUG1("written %d chars so far", posw);
412 rctx->input->data[0] = '\0';
413 rctx->input->used = 0;
414 close(rctx->child_to);
419 static void *thread_reader(void *r)
421 rctx_t rctx = (rctx_t) r;
422 char *buffout = malloc(4096);
426 posr = read(rctx->child_from, buffout, 4095);
427 if (posr < 0 && errno != EINTR && errno != EAGAIN) {
428 perror("Error while reading output of child");
429 ERROR1("Test suite `%s': NOK (system error)", testsuite_name);
430 rctx_armageddon(rctx, 4);
434 buffout[posr] = '\0';
435 xbt_strbuff_append(rctx->output_got, buffout);
439 } while (!rctx->timeout && posr != 0);
442 /* let this thread wait for the child so that the main thread can detect the timeout without blocking on the wait */
443 got_pid = waitpid(rctx->pid, &rctx->status, 0);
444 if (got_pid != rctx->pid) {
446 ("(%s) Cannot wait for the child %s (got pid %d where pid %d were expected;status=%d)",
447 xbt_thread_self_name(), rctx->cmd, (int) got_pid,
448 (int) rctx->pid, rctx->status));
449 ERROR1("Test suite `%s': NOK (system error)", testsuite_name);
450 rctx_armageddon(rctx, 4);
454 rctx->reader_done = 1;
458 /* Special command: mkfile is a built-in creating a file with the input data as content */
459 static void rctx_mkfile(void)
461 char *filename = xbt_strdup(rctx->cmd + strlen("mkfile "));
464 xbt_str_trim(filename, NULL);
465 OUT = fopen(filename, "w");
467 THROW3(system_error, errno, "%s: Cannot create file %s: %s",
468 rctx->filepos, filename, strerror(errno));
470 err = (fprintf(OUT, "%s", rctx->input->data) < 0);
471 err = (fclose(OUT) == -1) || err;
473 THROW3(system_error, errno, "%s: Cannot write file %s: %s",
474 rctx->filepos, filename, strerror(errno));
479 /* function to be called from the child to start the actual process */
480 static void start_command(rctx_t rctx)
483 char *binary_name = NULL;
489 if (!strncmp(rctx->cmd, "mkfile ", strlen("mkfile "))) {
491 /* Valgrind detects memory leaks here.
492 * To correct those leaks, we must free objects allocated in main() or in
493 * handle_suite(), but we have no more reference to them at this point.
494 * A quick and dirty hack to make valgrind happy it to uncomment the
497 /* execlp("true", "true", (const char *)0); */
498 exit(0); /* end the working child */
501 cmd = xbt_str_split_quoted(rctx->cmd);
502 xbt_dynar_get_cpy(cmd, 0, &binary_name);
503 args = xbt_new(char *, xbt_dynar_length(cmd) + 1);
504 xbt_dynar_foreach(cmd, it, str) {
505 args[it] = xbt_strdup(str);
508 xbt_dynar_free_container(&cmd);
510 /* To search for the right executable path when not trivial */
511 struct stat stat_buf;
513 /* build the command line */
514 if (stat(binary_name, &stat_buf)) {
515 /* Damn. binary not in current dir. We'll have to dig the PATH to find it */
518 for (i = 0; environ[i]; i++) {
519 if (!strncmp("PATH=", environ[i], 5)) {
520 xbt_dynar_t path = xbt_str_split(environ[i] + 5, ":");
522 xbt_dynar_foreach(path, it, str) {
525 binary_name = bprintf("%s/%s", str, args[0]);
526 if (!stat(binary_name, &stat_buf)) {
528 DEBUG1("Looked in the PATH for the binary. Found %s",
530 xbt_dynar_free(&path);
534 xbt_dynar_free(&path);
535 if (stat(binary_name, &stat_buf)) {
537 printf("TESH_ERROR Command %s not found\n", args[0]);
544 binary_name = xbt_strdup(args[0]);
547 errcode = execve(binary_name, args, rctx->env);
548 printf("TESH_ERROR %s: Cannot start %s: %s\n", rctx->filepos, rctx->cmd,
553 /* Start a new child, plug the pipes as expected and fire up the
554 helping threads. Is also waits for the child to end if this is a
555 foreground job, or fire up a thread to wait otherwise. */
556 void rctx_start(void)
561 DEBUG1("Cmd before rewriting %s", rctx->cmd);
562 rctx->cmd = xbt_str_varsubst(rctx->cmd, env);
563 VERB2("Start %s %s", rctx->cmd,
564 (rctx->is_background ? "(background job)" : ""));
565 xbt_os_mutex_acquire(armageddon_mutex);
566 if (armageddon_initiator) {
567 VERB0("Armageddon in progress. Do not start job.");
568 xbt_os_mutex_release(armageddon_mutex);
571 if (pipe(child_in) || pipe(child_out)) {
572 perror("Cannot open the pipes");
573 ERROR1("Test suite `%s': NOK (system error)", testsuite_name);
574 xbt_os_mutex_release(armageddon_mutex);
575 rctx_armageddon(rctx, 4);
580 perror("Cannot fork the command");
581 ERROR1("Test suite `%s': NOK (system error)", testsuite_name);
582 xbt_os_mutex_release(armageddon_mutex);
583 rctx_armageddon(rctx, 4);
587 if (rctx->pid) { /* father */
589 rctx->child_to = child_in[1];
592 rctx->child_from = child_out[0];
594 if (timeout_value > 0)
595 rctx->end_time = time(NULL) + timeout_value;
599 rctx->reader_done = 0;
601 xbt_os_thread_create("reader", thread_reader, (void *) rctx, NULL);
603 xbt_os_thread_create("writer", thread_writer, (void *) rctx, NULL);
607 dup2(child_in[0], 0);
611 dup2(child_out[1], 1);
612 dup2(child_out[1], 2);
618 rctx->is_stoppable = 1;
620 if (!rctx->is_background) {
622 xbt_os_mutex_release(armageddon_mutex);
626 /* Damn. Copy the rctx and launch a thread to handle it */
628 xbt_os_thread_t runner;
631 DEBUG2("RCTX: new bg=%p, new fg=%p", old, rctx);
633 DEBUG2("Launch a thread to wait for %s %d", old->cmd, old->pid);
634 runner = xbt_os_thread_create(old->cmd, rctx_wait, (void *) old, NULL);
635 old->runner = runner;
636 VERB3("Launched thread %p to wait for %s %d", runner, old->cmd,
638 xbt_dynar_push(bg_jobs, &old);
639 xbt_os_mutex_release(armageddon_mutex);
643 /* Helper function to sort the output */
644 static int cmpstringp(const void *p1, const void *p2) {
645 /* Sort only using the 19 first chars (date+pid)
646 * If the dates are the same, then, sort using pointer address (be stable wrt output of each process)
648 const char *s1 = *((const char**) p1);
649 const char *s2 = *((const char**) p2);
651 DEBUG2("Compare strings '%s' and '%s'", s1, s2);
653 int res = strncmp(s1, s2, 19);
660 /* Waits for the child to end (or to timeout), and check its
661 ending conditions. This is launched from rctx_start but either in main
662 thread (for foreground jobs) or in a separate one for background jobs.
663 That explains the prototype, forced by xbt_os_thread_create. */
665 void *rctx_wait(void *r)
667 rctx_t rctx = (rctx_t) r;
669 int now = time(NULL);
671 rctx_dump(rctx, "wait");
673 if (!rctx->is_stoppable)
674 THROW1(unknown_error, 0, "Cmd '%s' not started yet. Cannot wait it",
677 /* Wait for the child to die or the timeout to happen (or an armageddon to happen) */
678 while (!rctx->reader_done
679 && (rctx->end_time < 0 || rctx->end_time >= now)) {
684 xbt_os_mutex_acquire(rctx->interruption);
685 if (!rctx->interrupted && rctx->end_time > 0 && rctx->end_time < now) {
686 INFO1("<%s> timeouted. Kill the process.", rctx->filepos);
688 kill(rctx->pid, SIGTERM);
690 kill(rctx->pid, SIGKILL);
693 /* Make sure helper threads die.
694 Cannot block since they wait for the child we just killed
695 if not already dead. */
696 xbt_os_thread_join(rctx->writer, NULL);
697 xbt_os_thread_join(rctx->reader, NULL);
699 /* xbt_os_mutex_release(rctx->interruption);
700 if (rctx->interrupted)
702 xbt_os_mutex_acquire(rctx->interruption); */
704 xbt_strbuff_chomp(rctx->output_got);
705 xbt_strbuff_chomp(rctx->output_wanted);
706 xbt_strbuff_trim(rctx->output_got);
707 xbt_strbuff_trim(rctx->output_wanted);
709 /* Check for broken pipe */
710 if (rctx->brokenpipe)
712 ("Warning: Child did not consume all its input (I got broken pipe)");
714 /* Check for timeouts */
716 if (rctx->output_got->data[0])
717 INFO2("<%s> Output on timeout:\n%s",
718 rctx->filepos, rctx->output_got->data);
720 INFO1("<%s> No output before timeout", rctx->filepos);
721 ERROR3("Test suite `%s': NOK (<%s> timeout after %d sec)",
722 testsuite_name, rctx->filepos, timeout_value);
723 DEBUG2("<%s> Interrupted = %d", rctx->filepos, rctx->interrupted);
724 if (!rctx->interrupted) {
725 xbt_os_mutex_release(rctx->interruption);
726 rctx_armageddon(rctx, 3);
731 DEBUG2("RCTX=%p (pid=%d)", rctx, rctx->pid);
732 DEBUG3("Status(%s|%d)=%d", rctx->cmd, rctx->pid, rctx->status);
734 if (!rctx->interrupted) {
735 if (WIFSIGNALED(rctx->status) && !rctx->expected_signal) {
736 ERROR3("Test suite `%s': NOK (<%s> got signal %s)",
737 testsuite_name, rctx->filepos,
738 signal_name(WTERMSIG(rctx->status), NULL));
739 errcode = WTERMSIG(rctx->status) + 4;
742 if (WIFSIGNALED(rctx->status) && rctx->expected_signal &&
743 strcmp(signal_name(WTERMSIG(rctx->status), rctx->expected_signal),
744 rctx->expected_signal)) {
745 ERROR4("Test suite `%s': NOK (%s got signal %s instead of %s)",
746 testsuite_name, rctx->filepos,
747 signal_name(WTERMSIG(rctx->status), rctx->expected_signal),
748 rctx->expected_signal);
749 errcode = WTERMSIG(rctx->status) + 4;
752 if (!WIFSIGNALED(rctx->status) && rctx->expected_signal) {
753 ERROR3("Test suite `%s': NOK (child %s expected signal %s)",
754 testsuite_name, rctx->filepos, rctx->expected_signal);
758 if (WIFEXITED(rctx->status)
759 && WEXITSTATUS(rctx->status) != rctx->expected_return) {
760 if (rctx->expected_return)
762 ("Test suite `%s': NOK (<%s> returned code %d instead of %d)",
763 testsuite_name, rctx->filepos, WEXITSTATUS(rctx->status),
764 rctx->expected_return);
766 ERROR3("Test suite `%s': NOK (<%s> returned code %d)",
767 testsuite_name, rctx->filepos, WEXITSTATUS(rctx->status));
768 errcode = 40 + WEXITSTATUS(rctx->status);
771 rctx->expected_return = 0;
773 if (rctx->expected_signal) {
774 free(rctx->expected_signal);
775 rctx->expected_signal = NULL;
778 while (rctx->output_got->used
779 && !strncmp(rctx->output_got->data, "TESH_ERROR ",
780 strlen("TESH_ERROR "))) {
781 int marklen = strlen("TESH_ERROR ");
782 char *endline = strchr(rctx->output_got->data, '\n');
784 CRITICAL2("%.*s", (int) (endline - rctx->output_got->data - marklen),
785 rctx->output_got->data + marklen);
786 memmove(rctx->output_got->data, rctx->output_got->data + marklen,
787 rctx->output_got->used - marklen);
788 rctx->output_got->used -= endline - rctx->output_got->data + 1;
789 rctx->output_got->data[rctx->output_got->used] = '\0';
793 if (rctx->output_sort) {
794 xbt_dynar_t a = xbt_str_split(rctx->output_got->data, "\n");
795 xbt_dynar_sort(a,cmpstringp);
796 char *sorted_output = xbt_str_join(a, "\n");
797 strcpy(rctx->output_got->data, sorted_output);
798 xbt_free(sorted_output);
800 /* If an empty line moved in first position, move it back to the end */
801 if (rctx->output_got->data[0]=='\n') {
802 fprintf(stderr,"XXX");
803 memmove(rctx->output_got->data,rctx->output_got->data+1,rctx->output_got->used-1);
804 rctx->output_got->data[rctx->output_got->used-1] = '\n';
807 if ((errcode && errcode != 1) || rctx->interrupted) {
808 /* checking output, and matching */
809 xbt_dynar_t a = xbt_str_split(rctx->output_got->data, "\n");
810 char *out = xbt_str_join(a, "\n||");
812 INFO2("Output of <%s> so far: \n||%s", rctx->filepos, out);
814 } else if (rctx->output == e_output_check
815 && (rctx->output_got->used != rctx->output_wanted->used
816 || strcmp(rctx->output_got->data,
817 rctx->output_wanted->data))) {
818 if (XBT_LOG_ISENABLED(tesh, xbt_log_priority_info)) {
820 xbt_str_diff(rctx->output_wanted->data, rctx->output_got->data);
821 ERROR2("Output of <%s> mismatch:\n%s", rctx->filepos, diff);
824 ERROR2("Test suite `%s': NOK (<%s> output mismatch)",
825 testsuite_name, rctx->filepos);
828 } else if (rctx->output == e_output_ignore) {
829 INFO1("(ignoring the output of <%s> as requested)", rctx->filepos);
830 } else if (rctx->output == e_output_display) {
831 xbt_dynar_t a = xbt_str_split(rctx->output_got->data, "\n");
832 char *out = xbt_str_join(a, "\n||");
834 INFO1("Here is the (ignored) command output: \n||%s", out);
838 if (!rctx->is_background) {
839 xbt_os_mutex_acquire(armageddon_mutex);
840 /* Don't touch rctx if armageddon is in progress. */
841 if (!armageddon_initiator)
843 xbt_os_mutex_release(armageddon_mutex);
846 if (!rctx->interrupted) {
847 xbt_os_mutex_release(rctx->interruption);
848 rctx_armageddon(rctx, errcode);
853 xbt_os_mutex_release(rctx->interruption);