Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to disable timeouts
[simgrid.git] / tools / tesh / run_context.c
index b234a08..03ab386 100644 (file)
@@ -85,7 +85,7 @@ void rctx_armageddon(rctx_t initiator, int exitcode) {
   } 
 
   /* Cleanup the place */
-  xbt_dynar_free(&bg_jobs);
+  //  xbt_dynar_free(&bg_jobs);
 
   exit(exitcode);
 }
@@ -200,8 +200,11 @@ void rctx_pushline(const char* filepos, char kind, char *line) {
     if (rctx->cmd)
       rctx_start();
 
-    if (!strncmp(line,"set timeout ",strlen("set timeout "))) {
-      timeout_value=atoi(line+strlen("set timeout"));
+    if (!strncmp(line,"timeout no",strlen("timeout no"))) {
+      VERB1("[%s] (disable timeout)", filepos);
+      timeout_value = -1;
+    } else if (!strncmp(line,"timeout ",strlen("timeout "))) {
+      timeout_value=atoi(line+strlen("timeout"));
       VERB2("[%s] (new timeout value: %d)",
             filepos,timeout_value);
 
@@ -331,7 +334,10 @@ void rctx_start(void) {
     close(child_out[1]);
     rctx->child_from = child_out[0];
 
-    rctx->end_time = time(NULL) + timeout_value;
+    if (timeout_value > 0)
+       rctx->end_time = time(NULL) + timeout_value;
+    else 
+       rctx->end_time = -1;
 
     rctx->reader_done = 0;
     rctx->reader = xbt_thread_create(thread_reader,(void*)rctx);
@@ -389,14 +395,14 @@ void *rctx_wait(void* r) {
           rctx->cmd);
 
   /* Wait for the child to die or the timeout to happen (or an armageddon to happen) */
-  while (!rctx->interrupted && !rctx->reader_done && rctx->end_time >= now) {
+  while (!rctx->interrupted && !rctx->reader_done && (rctx->end_time <0 ||rctx->end_time >= now)) {
     usleep(100);
     now = time(NULL);
   }
    
   xbt_mutex_lock(rctx->interruption);
 
-  if (!rctx->interrupted && rctx->end_time < now) {    
+  if (!rctx->interrupted && rctx->end_time > 0 && rctx->end_time < now) {    
     INFO1("<%s> timeouted. Kill the process.",rctx->filepos);
     rctx->timeout = 1;
     kill(rctx->pid,SIGTERM);
@@ -491,8 +497,7 @@ void *rctx_wait(void* r) {
           || strcmp(rctx->output_got->data, rctx->output_wanted->data))) {
     if (XBT_LOG_ISENABLED(tesh,xbt_log_priority_info)) {
        char *diff= xbt_str_diff(rctx->output_wanted->data,rctx->output_got->data);       
-       ERROR1("Output mismatch:\n%s",
-             diff);
+       ERROR2("Output of <%s> mismatch:\n%s",rctx->filepos,diff);
        free(diff);
     }     
     ERROR2("Test suite `%s': NOK (<%s> output mismatch)", 
@@ -500,7 +505,7 @@ void *rctx_wait(void* r) {
      
     errcode=2;
   } else if (rctx->output == e_output_ignore) {
-    INFO0("(ignoring the output as requested)");
+    INFO1("(ignoring the output of <%s> as requested)",rctx->filepos);
   } else if (rctx->output == e_output_display) {
     xbt_dynar_t a = xbt_str_split(rctx->output_got->data, "\n");
     char *out = xbt_str_join(a,"\n||");