Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to disable timeouts
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 8 Jun 2007 14:33:50 +0000 (14:33 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 8 Jun 2007 14:33:50 +0000 (14:33 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3595 48e7efb5-ca39-0410-a469-dd3cf9ba447f

tools/tesh/README.tesh
tools/tesh/catch-timeout.tesh
tools/tesh/run_context.c
tools/tesh/set-timeout.tesh

index c9361fa..9d78a15 100644 (file)
@@ -14,7 +14,7 @@ blank and is ignored):
  `<' input to pass to the command
  `>' output expected from the command
  `!' metacommand, which can be one of:
-     `set timeout' <integer>
+     `timeout' <integer>|no
      `expect signal' <signal name>
      `expect return' <integer>
      `output' <ignore|display>
@@ -76,9 +76,10 @@ TIMEOUTS
 --------
 
 By default, all commands are given 5 seconds to execute
-(cf. catch-timeout.tesh). You can change this with the "set timeout", which
+(cf. catch-timeout.tesh). You can change this with the "timeout", which
 takes an integer as argument. The change only apply to the next command
-(cf. set-timeout.tesh).
+(cf. set-timeout.tesh). If you pass "no" as argument, the command
+cannot timeout.
 
 OUTPUT
 ------
index 40aa37a..d4c6f14 100644 (file)
@@ -4,7 +4,7 @@
 # before sleeping 6 secs.
 
 ! expect return 3
-< ! set timeout 1
+< ! timeout 1
 < $ sleep 6
 > Test suite from stdin
 > [stdin:2] sleep 6
index 7acab0f..03ab386 100644 (file)
@@ -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);
index 6069780..7f94ed9 100644 (file)
@@ -3,5 +3,5 @@
 # This suite must be functional because we changed the timeout value to 10
 # before sleeping 6 secs.
 
-! set timeout 10
+! timeout 10
 $ sleep 6