t/run-fio-tests: improve error handling
authorVincent Fu <vincent.fu@wdc.com>
Mon, 11 Nov 2019 16:30:55 +0000 (11:30 -0500)
committerJens Axboe <axboe@kernel.dk>
Thu, 14 Nov 2019 21:07:25 +0000 (14:07 -0700)
More gracefully handle errors when running a test. Also change the
EXAMPLE to refer to fio's canonical git repository.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/run-fio-tests.py

index 1b8ca0a2f508f08a18c551710499d643c21dbfc8..cf8de093d57c53068eea337ffa3c974985f08457 100755 (executable)
@@ -14,7 +14,7 @@
 #
 #
 # EXAMPLE
-# # git clone [fio-repository]
+# # git clone git://git.kernel.dk/fio.git
 # # cd fio
 # # make -j
 # # python3 t/run-fio-tests.py
@@ -123,6 +123,7 @@ class FioExeTest(FioTest):
         stderr_file = open(self.stderr_file, "w+")
         exticode_file = open(self.exticode_file, "w+")
         try:
+            proc = None
             # Avoid using subprocess.run() here because when a timeout occurs,
             # fio will be stopped with SIGKILL. This does not give fio a
             # chance to clean up and means that child processes may continue
@@ -142,9 +143,10 @@ class FioExeTest(FioTest):
             assert proc.poll()
             self.output['failure'] = 'timeout'
         except Exception:
-            if not proc.poll():
-                proc.terminate()
-                proc.communicate()
+            if proc:
+                if not proc.poll():
+                    proc.terminate()
+                    proc.communicate()
             self.output['failure'] = 'exception'
             self.output['exc_info'] = sys.exc_info()
         finally: