summaryrefslogtreecommitdiffstats
path: root/plugins/agl_test_ptest_base.py
diff options
context:
space:
mode:
authorduerpei <duep.fnst@fujitsu.com>2022-06-11 18:20:50 +0800
committerduerpei <duep.fnst@fujitsu.com>2022-06-11 18:20:50 +0800
commit18633e747c6bb469f31d2bc2e595b85099865b4f (patch)
tree0a3c11e2256416faedaee2c94604ce120fd03bd2 /plugins/agl_test_ptest_base.py
parentcb256cee0fe43430b461dcee392267dc65514e41 (diff)
agl-test-framework: add PTESTBaseTest class
Add PTESTBaseTest class for test sets called from ptest. It inherits from AGLBaseTest class. It contains two common functions used to run the ptest test set. In test suite, please create a child class based on PTESTBaseTest. Then it is easy to init, run tests, check results and make a repoter. By the way, delete the useless code in agl_test_report.py Bug-AGL: SPEC-4345 Signed-off-by: duerpei <duep.fnst@fujitsu.com> Change-Id: Ief99073e4f63a44bde387b8c42d029c47fbf0943
Diffstat (limited to 'plugins/agl_test_ptest_base.py')
-rw-r--r--plugins/agl_test_ptest_base.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/agl_test_ptest_base.py b/plugins/agl_test_ptest_base.py
new file mode 100644
index 0000000..f7b5829
--- /dev/null
+++ b/plugins/agl_test_ptest_base.py
@@ -0,0 +1,30 @@
+import subprocess
+
+from plugins.agl_test_base import AGLBaseTest
+
+class PTESTBase(AGLBaseTest):
+
+ def __init__(self, test_name: str):
+ super().__init__(name=test_name)
+
+ #Run test by ptest-runner
+ def run_test_fun(self):
+ log_file = self.get_logfile()
+ with open(log_file,'w') as log_f:
+ subprocess.run(['ptest-runner', super().get_name()],
+ stdout=log_f, stderr=log_f)
+ log_f.close()
+
+ def run_case(self, case_id):
+ case_info = self.get_caseinfo_by_name(case_id)
+ if (case_info[1] == "PASS"):
+ case_info[2] = "passed"
+ elif (case_info[1] == "FAIL"):
+ case_info[2] = "failed"
+ elif (case_info[1] == "SKIP"):
+ case_info[2] = "skipped"
+ else:
+ case_info[2] = "failed"
+
+ self.update_caseinfo_by_name(case_id, case_info)
+ assert case_info[2] == "passed" or case_info[2] == "skipped"