From 3a505a61298a803e8d5f25dc01fc5e35047c2dc0 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Tue, 14 Jan 2025 18:27:55 +0000 Subject: [PATCH] t/fiotestlib: improve JSON decoding Instead of skipping up to a fixed number of lines when trying to decode JSON output, just skip everything until the first opening {. Signed-off-by: Vincent Fu --- t/fiotestlib.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/t/fiotestlib.py b/t/fiotestlib.py index 466e482d..61adca14 100755 --- a/t/fiotestlib.py +++ b/t/fiotestlib.py @@ -322,19 +322,16 @@ class FioJobCmdTest(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: - return True + file_data = '\n'.join(lines[lines.index("{"):]) + try: + self.json_data = json.loads(file_data) + except json.JSONDecodeError: + return False - return False + return True @staticmethod def check_empty(job): -- 2.25.1