blob: 218a8980fd2bb352f97b7a4d3113b3546f57a94e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
import subprocess
import pathlib
from plugins.agl_test_base import AGLBaseTest
PTEST_CMD = "/usr/bin/ptest-runner"
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[2] == ""):
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"
elif (case_info[1] == "XPASS"):
case_info[2] = "xpassed"
elif (case_info[1] == "XFAIL"):
case_info[2] = "xfailed"
else:
case_info[2] = "failed"
self.update_caseinfo_by_name(case_id, case_info)
assert case_info[2] != "failed"
def precheck(self):
# check for common
check_common = super().precheck()
# check for ptest-runner
path = pathlib.Path(PTEST_CMD)
check_ptest_cmd = path.is_file()
# check self test scripts
test_script = pathlib.Path("/usr/lib/" + super().get_name() + "/ptest/run-ptest")
check_test_script = test_script.is_file()
if((check_common and check_ptest_cmd and check_test_script) == False):
#write test suite info to file
self.write_skip_info()
return check_common and check_ptest_cmd and check_test_script
def run_ptest(self):
if(self.precheck() == True):
self.run_test_fun()
#write test suite info to file
self.write_run_info()
self.log_process()
def get_ptest_path(self):
return "/usr/lib/" + self.get_name() + "/ptest/"
def get_ptest_tests_path(self):
return self.get_ptest_path() + "tests/"
|