From 18633e747c6bb469f31d2bc2e595b85099865b4f Mon Sep 17 00:00:00 2001 From: duerpei Date: Sat, 11 Jun 2022 18:20:50 +0800 Subject: 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 Change-Id: Ief99073e4f63a44bde387b8c42d029c47fbf0943 --- plugins/agl_test_ptest_base.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 plugins/agl_test_ptest_base.py (limited to 'plugins/agl_test_ptest_base.py') 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" -- cgit 1.2.3-korg