diff options
author | Qiu Tingting <qiutt@fujitsu.com> | 2023-04-17 10:01:07 +0800 |
---|---|---|
committer | Qiu Tingting <qiutt@fujitsu.com> | 2023-04-21 00:39:23 +0000 |
commit | 8f83b67b8ac0a60ff4e3a5a5888474b3033f9b3a (patch) | |
tree | 1081c6f54ce67a1932290ec75968723e72aa8b86 | |
parent | 9b9fd4724424c9758cdb5f66b66ae61da177a8a6 (diff) |
agl-test-framework: Optimize common function log_process
Add new commone function log_process_gnu for the following tests:
acl
attr
bash
bc
bluez5
busybox
cpio
libpam
libxml2
zlib
SPEC-4758
Signed-off-by: Qiu Tingting <qiutt@fujitsu.com>
Change-Id: I92de3b781badac9cb6d55acd5cc0c601dc4a7c65
-rw-r--r-- | plugins/agl_test_log.py | 23 | ||||
-rw-r--r-- | tests/acl/run_tests.py | 4 | ||||
-rw-r--r-- | tests/attr/run_tests.py | 4 | ||||
-rw-r--r-- | tests/bash/parser.py | 20 | ||||
-rw-r--r-- | tests/bash/run_tests.py | 4 | ||||
-rw-r--r-- | tests/bc/parser.py | 34 | ||||
-rw-r--r-- | tests/bc/run_tests.py | 5 | ||||
-rw-r--r-- | tests/bluez5/parser.py | 20 | ||||
-rw-r--r-- | tests/bluez5/run_tests.py | 4 | ||||
-rw-r--r-- | tests/busybox/parser.py | 20 | ||||
-rw-r--r-- | tests/busybox/run_tests.py | 4 | ||||
-rw-r--r-- | tests/cpio/parser.py | 38 | ||||
-rw-r--r-- | tests/cpio/run_tests.py | 4 | ||||
-rw-r--r-- | tests/libpam/parser.py | 37 | ||||
-rw-r--r-- | tests/libpam/run_tests.py | 5 | ||||
-rw-r--r-- | tests/libxml2/parser.py | 38 | ||||
-rw-r--r-- | tests/libxml2/run_tests.py | 5 | ||||
-rw-r--r-- | tests/zlib/parser.py | 38 | ||||
-rw-r--r-- | tests/zlib/run_tests.py | 4 |
19 files changed, 43 insertions, 268 deletions
diff --git a/plugins/agl_test_log.py b/plugins/agl_test_log.py index 958a9a8..31c6b6d 100644 --- a/plugins/agl_test_log.py +++ b/plugins/agl_test_log.py @@ -52,9 +52,32 @@ gnome_desktop_testing log formate: PASS: glib/tls-database.test FAIL: glib/markup-escape.test SKIP: glib/testname.test + XFAIL: test/nfs/nfsacl.test + XPASS: xxx/xxxx.test + ERROR: xxx/xxxx.test ''' def log_process_gnome_desktop_testing(log): pattern = '^(FAIL|PASS|SKIP|XFAIL|XPASS|ERROR+?): (.+test?)' + return log_process_with_pattern(log, pattern) + +''' +Process the log and init test_cases_values_and_status. + +log : the path of log file + +log formate: + PASS: case_name + FAIL: case_name + SKIP: case_name + XFAIL: case_name + XPASS: case_name + ERROR: case_name +''' +def log_process_gnu(log): + pattern = '^(FAIL|PASS|SKIP|XFAIL|XPASS|ERROR+?): (.+)' + return log_process_with_pattern(log, pattern) + +def log_process_with_pattern(log, pattern): parse_result = log_parse(log, pattern) case_list = dict() if parse_result: diff --git a/tests/acl/run_tests.py b/tests/acl/run_tests.py index f4f7ef1..7768ac6 100644 --- a/tests/acl/run_tests.py +++ b/tests/acl/run_tests.py @@ -14,12 +14,12 @@ def rm_logs(log_path: pathlib.Path): class AclBase(PTESTBase): def __init__(self): super().__init__(test_name="acl") - # rm *.log *.trs from /usr/lib/acl/ptest/test/ + # rm *.log *.trs from /usr/lib/acl/ptest/test/ rm_logs(pathlib.Path("/usr/lib/acl/ptest/test/")) def log_process(self): log_file = self.get_logfile() - self.case_info_list = log.log_process_gnome_desktop_testing(log_file) + self.case_info_list = log.log_process_gnu(log_file) instance = AclBase() instance.run_ptest() diff --git a/tests/attr/run_tests.py b/tests/attr/run_tests.py index 148f4a6..d78a38f 100644 --- a/tests/attr/run_tests.py +++ b/tests/attr/run_tests.py @@ -14,12 +14,12 @@ def rm_logs(log_path: pathlib.Path): class AttrBase(PTESTBase): def __init__(self): super().__init__(test_name="attr") - # rm *.log *.trs from /usr/lib/attr/ptest/test/ + # rm *.log *.trs from /usr/lib/attr/ptest/test/ rm_logs(pathlib.Path("/usr/lib/attr/ptest/test/")) def log_process(self): log_file = self.get_logfile() - self.case_info_list = log.log_process_gnome_desktop_testing(log_file) + self.case_info_list = log.log_process_gnu(log_file) instance = AttrBase() instance.run_ptest() diff --git a/tests/bash/parser.py b/tests/bash/parser.py deleted file mode 100644 index 8f2b635..0000000 --- a/tests/bash/parser.py +++ /dev/null @@ -1,20 +0,0 @@ -import re - -def log_parse(log_file): - reObj = re.compile('^(PASS|FAIL+?): (run.+)', re.MULTILINE) - case_list = dict() - test_log = open(log_file, 'r') - - line = test_log.readline() - while line: - matchs = reObj.search(line) - - if matchs: - groups = matchs.groups() - case_list[groups[1]] = [groups[1], groups[0], ""] - - line = test_log.readline() - - test_log.close() - - return case_list diff --git a/tests/bash/run_tests.py b/tests/bash/run_tests.py index d18ecf0..b37f5fc 100644 --- a/tests/bash/run_tests.py +++ b/tests/bash/run_tests.py @@ -1,6 +1,6 @@ import pytest import pathlib -import tests.bash.parser as parser +import plugins.agl_test_log as log from plugins.agl_test_ptest_base import PTESTBase class BashBase(PTESTBase): @@ -9,7 +9,7 @@ class BashBase(PTESTBase): def log_process(self): log_file = self.get_logfile() - self.case_info_list = parser.log_parse(log_file) + self.case_info_list = log.log_process_gnu(log_file) def precheck(self): path_bash = pathlib.Path("/usr/bin/bash") diff --git a/tests/bc/parser.py b/tests/bc/parser.py deleted file mode 100644 index 8c3cd95..0000000 --- a/tests/bc/parser.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# this is a parser function specially designed for the 'bc.log' -# -import re - -def log_parse(log_file): - # set up rule for regex - reObj = re.compile('^(PASS|FAIL+?):\\sbc/(.+)[.]b', 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: - # checking regex status in line - matchs = reObj.search(line) - - # if the line fits the regex rule - if matchs: - # spliting elements into a tuple - groups = matchs.groups() - case_list[groups[1]] = [groups[1], groups[0], ""] - - # jump out if-else, read next line - line = test_log.readline() - - test_log.close() - - return case_list diff --git a/tests/bc/run_tests.py b/tests/bc/run_tests.py index 230727a..873a448 100644 --- a/tests/bc/run_tests.py +++ b/tests/bc/run_tests.py @@ -1,6 +1,5 @@ import pytest - -import tests.bc.parser as parser +import plugins.agl_test_log as log from plugins.agl_test_ptest_base import PTESTBase @@ -10,7 +9,7 @@ class BCBase(PTESTBase): def log_process(self): log_file = self.get_logfile() - self.case_info_list = parser.log_parse(log_file) + self.case_info_list = log.log_process_gnu(log_file) instance = BCBase() instance.run_ptest() diff --git a/tests/bluez5/parser.py b/tests/bluez5/parser.py deleted file mode 100644 index e21814f..0000000 --- a/tests/bluez5/parser.py +++ /dev/null @@ -1,20 +0,0 @@ -import re - -def log_parse(log_file): - reObj = re.compile('^(PASS|FAIL|SKIP): (.+)', re.MULTILINE) - case_list = dict() - test_log = open(log_file, 'r') - - line = test_log.readline() - while line: - matchs = reObj.search(line) - - if matchs: - groups = list(matchs.groups()) - case_list[groups[1]] = [groups[1], groups[0], ""] - - line = test_log.readline() - - test_log.close() - - return case_list diff --git a/tests/bluez5/run_tests.py b/tests/bluez5/run_tests.py index 238e2c7..569aedf 100644 --- a/tests/bluez5/run_tests.py +++ b/tests/bluez5/run_tests.py @@ -1,5 +1,5 @@ import pytest -import tests.bluez5.parser as parser +import plugins.agl_test_log as log from plugins.agl_test_ptest_base import PTESTBase class Bluez5Base(PTESTBase): @@ -8,7 +8,7 @@ class Bluez5Base(PTESTBase): def log_process(self): log_file = self.get_logfile() - self.case_info_list = parser.log_parse(log_file) + self.case_info_list = log.log_process_gnu(log_file) instance = Bluez5Base() instance.run_ptest() diff --git a/tests/busybox/parser.py b/tests/busybox/parser.py deleted file mode 100644 index e21814f..0000000 --- a/tests/busybox/parser.py +++ /dev/null @@ -1,20 +0,0 @@ -import re - -def log_parse(log_file): - reObj = re.compile('^(PASS|FAIL|SKIP): (.+)', re.MULTILINE) - case_list = dict() - test_log = open(log_file, 'r') - - line = test_log.readline() - while line: - matchs = reObj.search(line) - - if matchs: - groups = list(matchs.groups()) - case_list[groups[1]] = [groups[1], groups[0], ""] - - line = test_log.readline() - - test_log.close() - - return case_list diff --git a/tests/busybox/run_tests.py b/tests/busybox/run_tests.py index c6f3b8d..31c5c5b 100644 --- a/tests/busybox/run_tests.py +++ b/tests/busybox/run_tests.py @@ -1,7 +1,7 @@ import pytest import pathlib import subprocess -import tests.busybox.parser as parser +import plugins.agl_test_log as log from plugins.agl_test_ptest_base import PTESTBase class BusyboxBase(PTESTBase): @@ -10,7 +10,7 @@ class BusyboxBase(PTESTBase): def log_process(self): log_file = self.get_logfile() - self.case_info_list = parser.log_parse(log_file) + self.case_info_list = log.log_process_gnu(log_file) def precheck(self): path_bash = pathlib.Path("/usr/bin/busybox") diff --git a/tests/cpio/parser.py b/tests/cpio/parser.py deleted file mode 100644 index 290bbf4..0000000 --- a/tests/cpio/parser.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# this is a parser function specially designed for the 'cpio.log' -# -import re - -def log_parse(log_file): - - # set up rule for regex - reObj = re.compile('^(PASS|FAIL|SKIP+?): (.+)', 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: - - # checking regex status in line - matchs = reObj.search(line) - - # if the line fits the regex rule - if matchs: - # spliting elements into a tuple - groups = matchs.groups() - - # then just add a new key naming after case_name, along with its values - case_list[groups[1]] = [groups[1], groups[0], ""] - - # jump out if-else, read next line - line = test_log.readline() - - test_log.close() - - return case_list diff --git a/tests/cpio/run_tests.py b/tests/cpio/run_tests.py index 6be11da..cde6ed1 100644 --- a/tests/cpio/run_tests.py +++ b/tests/cpio/run_tests.py @@ -1,5 +1,5 @@ import pytest -import tests.cpio.parser as parser +import plugins.agl_test_log as log from plugins.agl_test_ptest_base import PTESTBase class CPIOBase(PTESTBase): @@ -8,7 +8,7 @@ class CPIOBase(PTESTBase): def log_process(self): log_file = self.get_logfile() - self.case_info_list = parser.log_parse(log_file) + self.case_info_list = log.log_process_gnu(log_file) instance = CPIOBase() instance.run_ptest() diff --git a/tests/libpam/parser.py b/tests/libpam/parser.py deleted file mode 100644 index dae4f12..0000000 --- a/tests/libpam/parser.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# this is a parser function specially designed for the 'libpam.log' -# -import re - -def log_parse(log_file): - - # set up rule for regex - reObj = re.compile('^(PASS|FAIL|SKIP+?): (.+)', 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: - - # checking regex status in line - matchs = reObj.search(line) - - # if the line fits the regex rule - if matchs: - # spliting elements into a tuple - groups = matchs.groups() - # then just add a new key naming after case_name, along with its values - case_list[groups[1]] = [groups[1], groups[0], ""] - - # jump out if-else, read next line - line = test_log.readline() - - test_log.close() - - return case_list diff --git a/tests/libpam/run_tests.py b/tests/libpam/run_tests.py index 9b2ffab..6899c50 100644 --- a/tests/libpam/run_tests.py +++ b/tests/libpam/run_tests.py @@ -1,6 +1,5 @@ import pytest - -import tests.libpam.parser as parser +import plugins.agl_test_log as log from plugins.agl_test_ptest_base import PTESTBase @@ -10,7 +9,7 @@ class LIBPAMBase(PTESTBase): def log_process(self): log_file = self.get_logfile() - self.case_info_list = parser.log_parse(log_file) + self.case_info_list = log.log_process_gnu(log_file) instance = LIBPAMBase() instance.run_ptest() diff --git a/tests/libxml2/parser.py b/tests/libxml2/parser.py deleted file mode 100644 index 558a68d..0000000 --- a/tests/libxml2/parser.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# this is a parser function specially designed for the 'libxml2.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: - - # checking regex status in line - matchs = reObj.search(line) - - # if the line fits the regex rule - if matchs: - # spliting elements into a tuple - groups = matchs.groups() - - # then just add a new key naming after case_name, along with its values - case_list[groups[1]] = [groups[1], groups[0], ""] - - # jump out if-else, read next line - line = test_log.readline() - - test_log.close() - - return case_list diff --git a/tests/libxml2/run_tests.py b/tests/libxml2/run_tests.py index 0043a94..c2b2a99 100644 --- a/tests/libxml2/run_tests.py +++ b/tests/libxml2/run_tests.py @@ -1,6 +1,5 @@ import pytest - -import tests.libxml2.parser as parser +import plugins.agl_test_log as log from plugins.agl_test_ptest_base import PTESTBase @@ -10,7 +9,7 @@ class LIBXML2Base(PTESTBase): def log_process(self): log_file = self.get_logfile() - self.case_info_list = parser.log_parse(log_file) + self.case_info_list = log.log_process_gnu(log_file) instance = LIBXML2Base() instance.run_ptest() diff --git a/tests/zlib/parser.py b/tests/zlib/parser.py deleted file mode 100644 index 183a0e3..0000000 --- a/tests/zlib/parser.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# this is a parser function specially designed for the 'zlib.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: - - # checking regex status in line - matchs = reObj.search(line) - - # if the line fits the regex rule - if matchs: - # spliting elements into a tuple - groups = matchs.groups() - - # then just add a new key naming after case_name, along with its values - case_list[groups[1]] = [groups[1], groups[0], ""] - - # jump out if-else, read next line - line = test_log.readline() - - test_log.close() - - return case_list diff --git a/tests/zlib/run_tests.py b/tests/zlib/run_tests.py index 47c984e..4bf6d67 100644 --- a/tests/zlib/run_tests.py +++ b/tests/zlib/run_tests.py @@ -1,5 +1,5 @@ import pytest -import tests.zlib.parser as parser +import plugins.agl_test_log as log from plugins.agl_test_ptest_base import PTESTBase class ZLIBBase(PTESTBase): @@ -8,7 +8,7 @@ class ZLIBBase(PTESTBase): def log_process(self): log_file = self.get_logfile() - self.case_info_list = parser.log_parse(log_file) + self.case_info_list = log.log_process_gnu(log_file) instance = ZLIBBase() instance.run_ptest() |