[Fuego] [PATCH 15/30] run-test: add support for timeout, rebuild, reboot flags

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Mon Jun 4 07:17:49 UTC 2018


Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 engine/scripts/ftc | 44 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index 091be7e..ac9a28b 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -3200,6 +3200,41 @@ def do_run_test(conf, options):
         options.remove('-p')
         os.environ["FUEGO_TEST_PHASES"] = test_phases
 
+    # FIXTHIS: default values should be obtained from test_class
+
+    if '--timeout' in options:
+        try:
+            timeout = options[options.index('--timeout') + 1]
+        except IndexError:
+            error_out('Timeout (e.g. 30m) not provided after --timeout.')
+
+        if re.match('^\d+[dhms]', timeout) is None:
+            error_out('%s: Timeout format not supported.' % timeout)
+        options.remove(timeout)
+        options.remove('--timeout')
+    else:
+        timeout = "30m"
+
+    if '--rebuild' in options:
+        try:
+            rebuild = options[options.index('--rebuild') + 1]
+        except IndexError:
+            error_out('Rebuild option not provided after --rebuild')
+        if rebuild not in ['true', 'false']:
+            error_out("Invalid rebuild option '%s'" % rebuild)
+    else:
+        rebuild = 'false'
+
+    if '--reboot' in options:
+        try:
+            reboot = options[options.index('--reboot') + 1]
+        except IndexError:
+            error_out('Reboot option not provided after --reboot')
+        if reboot not in ['true', 'false']:
+            error_out("Invalid reboot option '%s'" % reboot)
+    else:
+        reboot = 'false'
+
     if '--precleanup' in options:
         try:
             precleanup = options[options.index('--precleanup') + 1]
@@ -3262,11 +3297,8 @@ def do_run_test(conf, options):
     build_data.job_name = job_name
     build_data.workspace = conf.FUEGO_RW+"/buildzone"
     build_data.start_time = long(time.time() * 1000)
-
-    # force these for now, but
-    # FIXTHIS - do_run_test: read flag options (e.g. reboot) from command line (from 'options')
-    build_data.reboot_flag = "false"
-    build_data.rebuild_flag = "false"
+    build_data.reboot_flag = reboot
+    build_data.rebuild_flag = rebuild
     build_data.precleanup_flag = precleanup
     build_data.postcleanup_flag = postcleanup
 
@@ -3383,8 +3415,6 @@ def do_run_test(conf, options):
     fcntl.fcntl(tail_fd, fcntl.F_SETFL, flag | os.O_NONBLOCK)
 
     command = "/bin/bash -xe %s" % (tempfilename)
-    # FIXTHIS - in do_run_test: timeout is hardcoded to 5 minutes
-    timeout = 300    # 5 minutes
     rcode = ftc_exec_command(command, timeout)
     log.flush()
 
-- 
2.7.4




More information about the Fuego mailing list