t/run-fio-tests: improve json data decoding
authorVincent Fu <vincent.fu@samsung.com>
Tue, 24 May 2022 14:23:24 +0000 (14:23 +0000)
committerJens Axboe <axboe@kernel.dk>
Sat, 28 May 2022 02:37:17 +0000 (20:37 -0600)
Instead of skipping up to five lines, just skip everything until the
opening curly brace when trying to decode JSON data.

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
Link: https://lore.kernel.org/r/20220524142229.135808-5-vincent.fu@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/run-fio-tests.py

index ecceb67e93649d8148c58b4ca6bd7829bef059c6..32cdbc19928808dda1b7b178d64c67ec9830ca56 100755 (executable)
@@ -311,21 +311,15 @@ class FioJobTest(FioExeTest):
         #
         # Sometimes fio informational messages are included at the top of the
         # JSON output, especially under Windows. Try to decode output as JSON
-        # data, lopping off up to the first four lines
+        # data, skipping everything until the first {
         #
         lines = file_data.splitlines()
-        for i in range(5):
-            file_data = '\n'.join(lines[i:])
-            try:
-                self.json_data = json.loads(file_data)
-            except json.JSONDecodeError:
-                continue
-            else:
-                logging.debug("Test %d: skipped %d lines decoding JSON data", self.testnum, i)
-                return
-
-        self.failure_reason = "{0} unable to decode JSON data,".format(self.failure_reason)
-        self.passed = False
+        file_data = '\n'.join(lines[lines.index("{"):])
+        try:
+            self.json_data = json.loads(file_data)
+        except json.JSONDecodeError:
+            self.failure_reason = "{0} unable to decode JSON data,".format(self.failure_reason)
+            self.passed = False
 
 
 class FioJobTest_t0005(FioJobTest):