diff options
author | Qiu Tingting <qiutt@fujitsu.com> | 2022-09-22 15:11:02 +0800 |
---|---|---|
committer | du erp <duep.fnst@fujitsu.com> | 2023-01-03 09:20:43 +0000 |
commit | 65b57dc02df59e251cba2e94eff44173fa34b14c (patch) | |
tree | e5120581d1d24921f96554bcfc9e0d3f779453e7 /tests/python3 | |
parent | 5d580b48ba3fc26735f7858461a47a7347baceec (diff) |
agl-test-framework: enable ptest of python3
Add test scripts for enabling ptest of python3.
This test will cost 1h50min time in raspberrypi4.
Bug-AGL: SPEC-4345
Signed-off-by: Qiu Tingting <qiutt@fujitsu.com>
Change-Id: I840f4fa3e2d457f87260ec79fc72a06327157f22
Diffstat (limited to 'tests/python3')
-rw-r--r-- | tests/python3/__init__.py | 0 | ||||
-rw-r--r-- | tests/python3/parser.py | 104 | ||||
-rw-r--r-- | tests/python3/run_tests.py | 30 |
3 files changed, 134 insertions, 0 deletions
diff --git a/tests/python3/__init__.py b/tests/python3/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/python3/__init__.py diff --git a/tests/python3/parser.py b/tests/python3/parser.py new file mode 100644 index 0000000..c4f916c --- /dev/null +++ b/tests/python3/parser.py @@ -0,0 +1,104 @@ +import re +import sys + +# log sample +#== Tests result: FAILURE == +# +#365 tests OK. +# +#8 tests failed: +# test_ctypes test_distutils test_email test_mmap test_shutil +# test_site test_sysconfig test_venv +# +#28 tests skipped: +# test_asdl_parser test_clinic test_curses test_dbm_gnu +# test_dbm_ndbm test_devpoll test_gdb test_idle test_kqueue +# test_msilib test_ossaudiodev test_smtpnet test_socketserver +# test_startfile test_tcl test_timeout test_tix test_tk +# test_ttk_guionly test_ttk_textonly test_turtle test_urllib2net +# test_urllibnet test_winconsoleio test_winreg test_winsound +# test_xmlrpc_net test_zipfile64 +# +#Total duration: 1 hour 7 min +#Tests result: FAILURE +def log_parse(log_file): + # init all tests with PASS + case_list = dict() + log_message = 'PASS' + key = '^[0-9]+:[0-9]+:[0-9]+ load avg: .*\\] (test_.+)' + case_list = init_tests(log_file, key, log_message) + + # update FAIL test + log_message = "FAIL" + start_key = '^[0-9]+ tests failed:' + end_key = ['^[0-9]+ tests skipped:', '^Total duration: .*'] + fail_list = search_tests_with_key(log_file, start_key, end_key) + for item in fail_list.split(): + case_list[item] = [item, log_message, ""] + + #update skipped tests + log_message = "SKIP" + start_key = '^[0-9]+ tests skipped:' + end_key = ['^Total duration: .*'] + skip_list = search_tests_with_key(log_file, start_key, end_key) + for item in skip_list.split(): + case_list[item] = [item, log_message, ""] + + return case_list + +def init_tests(log_file, key, log_message): + case_list = dict() + reObj = re.compile(key, re.MULTILINE) + test_log = open(log_file, 'r') + line = test_log.readline() + while line: + matchs = reObj.search(line) + if matchs: + groups = matchs.groups() + # get the fisrt part from groups[0] + # e.g. + # goups[0]:test_zipimport -- test_zipfile64 skipped (resource denied) + # name:test_zipimport + name = groups[0].split()[0] + case_list[name] = [name, log_message, ""] + line = test_log.readline() + test_log.close() + return case_list + +def search_tests_with_key(log_file, start_key, end_key): + # search line with start key + reObj_start = re.compile(start_key, re.MULTILINE) + test_log = open(log_file, 'r') + line = test_log.readline() + while line: + matchs_start = reObj_start.search(line) + if matchs_start: + break; + line = test_log.readline() + line = test_log.readline() + + # search tests before end_key + tests_list = "" + while line: + end_flag = False; + for key in end_key: + reObj_end = re.compile(key, re.MULTILINE) + matchs_end = reObj_end.search(line) + if matchs_end: + end_flag = True + break; + if end_flag: + break; + tests_list = tests_list + line.strip() + " " + line = test_log.readline() + test_log.close() + return tests_list + +if __name__ == "__main__": + log_file = sys.argv[1] + key = sys.argv[2] + case_list = log_parse(log_file) + for case in case_list: + if case_list[case][1] == key: + print(case_list[case]) + diff --git a/tests/python3/run_tests.py b/tests/python3/run_tests.py new file mode 100644 index 0000000..63b1a77 --- /dev/null +++ b/tests/python3/run_tests.py @@ -0,0 +1,30 @@ +import pytest + +import tests.python3.parser as parser + +from plugins.agl_test_ptest_base import PTESTBase + +class Python3Base(PTESTBase): + def __init__(self): + super().__init__(test_name="python3") + + def log_process(self): + log_file = self.get_logfile() + self.case_info_list = parser.log_parse(log_file) + self.init_case_status() + +instance = Python3Base() +instance.run_ptest() + +@pytest.fixture(scope='module') +def testbase(): + yield instance + #package log files and make report file + instance.log_report() + +@pytest.mark.parametrize('case_name', instance.case_info_list.keys()) +def test_python3(testbase: Python3Base, case_name): + testbase.run_case(case_name) + +if __name__ == '__main__': + pytest.main("-s run_tests") |