summaryrefslogtreecommitdiffstats
path: root/tests/openssl
diff options
context:
space:
mode:
authoryanxk <yanxk.fnst@fujitsu.com>2022-08-14 11:49:05 +0800
committeryanxk <yanxk.fnst@fujitsu.com>2022-08-14 11:49:05 +0800
commit4bc58fc5cc29a5deae8ede984ab8e68e7874f615 (patch)
tree06d92e1f36c4af4da169e36141bff0c607905e63 /tests/openssl
parent4f19f467865cd3b6b49ce5c39502a031525cfc16 (diff)
agl-test-framework: enable ptest of 'openssl'
Base on the agl-test-framework, the ptest results of 'openssl' can now be collected, analyzed and then reported. Here are 3 samples that the output result might look like: tests/openssl/run_tests.py::test_openssl[30-test_evp_fetch_prov] PASSED tests/openssl/run_tests.py::test_openssl[30-test_evp_kdf] PASSED tests/openssl/run_tests.py::test_openssl[30-test_evp_libctx] PASSED Bug-AGL: SPEC-4345 Signed-off-by: yanxk <yanxk.fnst@fujitsu.com> Change-Id: Id28a36ce081e8cfb49dcb7af8db369244f1fd258
Diffstat (limited to 'tests/openssl')
-rw-r--r--tests/openssl/__init__.py1
-rw-r--r--tests/openssl/parser.py41
-rw-r--r--tests/openssl/run_tests.py30
3 files changed, 72 insertions, 0 deletions
diff --git a/tests/openssl/__init__.py b/tests/openssl/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/tests/openssl/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/openssl/parser.py b/tests/openssl/parser.py
new file mode 100644
index 0000000..9bf8f67
--- /dev/null
+++ b/tests/openssl/parser.py
@@ -0,0 +1,41 @@
+#
+# this is a parser function specially designed for the 'openssl.log'
+#
+import re
+
+def log_parse(log_file):
+ # set up rule for regex, default one, failed cases are not collected
+ reObj = re.compile('^(PASS|SKIP+?):\\s.*(\\d{2}-test_.+)[.]t', 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:
+ # specially switch regex rule to a new one in fit of the 'FAILED' cases
+ if("Test Summary Report" in line):
+ reObj = re.compile('^(\\d{2}-test_.+)[.]t', 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
+ groups = matchs.groups()
+ if(len(groups) == 1):
+ case_list[groups[0]] = [groups[0], "FAIL", ""]
+ else:
+ 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/openssl/run_tests.py b/tests/openssl/run_tests.py
new file mode 100644
index 0000000..f1a5177
--- /dev/null
+++ b/tests/openssl/run_tests.py
@@ -0,0 +1,30 @@
+import pytest
+
+import tests.openssl.parser as parser
+
+from plugins.agl_test_ptest_base import PTESTBase
+
+class OPENSSLBase(PTESTBase):
+ def __init__(self):
+ super().__init__(test_name="openssl")
+
+ def log_process(self):
+ log_file = self.get_logfile()
+ self.case_info_list = parser.log_parse(log_file)
+ self.init_case_status()
+
+instance = OPENSSLBase()
+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_openssl(testbase: OPENSSLBase, case_name):
+ testbase.run_case(case_name)
+
+if __name__ == '__main__':
+ pytest.main("-s run_tests")