summaryrefslogtreecommitdiffstats
path: root/plugins/agl_test_ptest_base.py
blob: f7b58291061acd1d2a1150a20c48669bfb099d9a (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
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"