summaryrefslogtreecommitdiffstats
path: root/tests/bzip2/parser.py
diff options
context:
space:
mode:
authoryanxk <yanxk.fnst@fujitsu.com>2022-07-11 15:23:19 +0800
committeryanxk <yanxk.fnst@fujitsu.com>2022-07-11 15:23:19 +0800
commite35e4d16b0a231ed34a744bcb0a08c1278874df9 (patch)
tree2f39e5214878f4c65de929237b9dee04ae0e798a /tests/bzip2/parser.py
parent85ceffe6e67c45492818e83bec53763a16ce9e72 (diff)
agl-test-framework: enable Ptest of "bzip2"
Base on the agl-test-framework, the test results of OSS "bzip2" can now be collected, analyzed and then reported. Bug-AGL: SPEC-4345 Signed-off-by: yanxk <yanxk.fnst@fujitsu.com> Change-Id: I28df7079cfc0bc4b95b3ca195119f435b9ba8b6b
Diffstat (limited to 'tests/bzip2/parser.py')
-rw-r--r--tests/bzip2/parser.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/bzip2/parser.py b/tests/bzip2/parser.py
new file mode 100644
index 0000000..276e811
--- /dev/null
+++ b/tests/bzip2/parser.py
@@ -0,0 +1,50 @@
+#
+# this is a parser function specially designed for the 'bzip2.log'
+#
+import re
+
+def log_parse(log_file):
+ # set up rule for regex
+ reObj = re.compile('^(PASS|FAIL+?): (.+)', re.MULTILINE)
+
+ # init a dictionary, it stores the return result
+ case_list = dict()
+
+ # open file
+ test_log = open(log_file, 'r')
+
+ # start to read the new line
+ line = test_log.readline()
+
+ while line:
+ if ("Testing decompression and recompression..." in line):
+ # dectect trigger line for part 2, change regex rule
+ reObj = re.compile('^(PASS|FAIL+?): /usr/lib/bzip2/ptest/bzip2-tests/(.+)', re.MULTILINE)
+
+ elif ("Testing detection of bad input data..." in line):
+ # dectect trigger line for part 3, change regex rule
+ reObj = re.compile('^(PASS|FAIL+?): .+/usr/lib/bzip2/ptest/bzip2-tests/(.+)', re.MULTILINE)
+
+ # checking regex status in line
+ matchs = reObj.search(line)
+
+ # if the line fits the regex rule
+ if matchs:
+ # spliting elements into a tuple
+ # it looks like ('PASS', '<File_Name Test_Name>')
+ groups = matchs.groups()
+
+ # adjust name
+ tmp_name = groups[1]
+ tmp_name = tmp_name.strip()
+ case_name = tmp_name.replace('.bad', '.bad Check Integrity')
+
+ # then just add a new key naming after case_name, along with its values
+ case_list[case_name] = [case_name, groups[0], ""]
+
+ # jump out if-else, read next line
+ line = test_log.readline()
+
+ test_log.close()
+
+ return case_list