blob: c751faf8fbe5cc399be0ea6e838cbfab71b3fc2d (
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
|
import pytest
import subprocess
import plugins.agl_test_utils as agl_test_utils
from plugins.agl_test_base import AGLBaseTest
class RPMBase(AGLBaseTest):
def __init__(self):
super().__init__(name="rpm")
def run_case(self, case_id):
case_info = self.get_caseinfo_by_name(case_id)
if (case_info[1] == "TEST-PASS"):
case_info[2] = "passed"
else:
case_info[2] == "failed"
self.update_caseinfo_by_name(case_id, case_info)
assert case_info[2] == "passed"
#Run test, and redirect the log into the file of rpm.log
def run_test_fun(self):
log_file = self.get_logfile()
cwd = self.get_workdir()
with open(log_file,'w') as log_f:
subprocess.run(['sh','rpm_test.sh'],cwd=cwd,stdout=log_f,stderr=log_f)
log_f.close()
@pytest.fixture(scope='module')
def testbase():
#init instance for test
instance = RPMBase()
#run test scripts
instance.run_test_fun()
#parser log
instance.log_process()
yield instance
#package log files and make report file
instance.log_report()
def setup_module(testbase: RPMBase):
agl_test_utils.find_cmd("rpm")
@pytest.mark.oss_default
def test_rpm01(testbase: RPMBase):
name = "rpm01"
testbase.run_case(name)
@pytest.mark.oss_default
def test_rpm02(testbase: RPMBase):
name = "rpm02"
testbase.run_case(name)
@pytest.mark.oss_default
def test_rpm03(testbase: RPMBase):
name = "rpm03"
testbase.run_case(name)
if __name__ == '__main__':
pytest.main("-s run_tests")
|