blob: 8ed99e5f9316882dadb8adb688458c2e91ed64ce (
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
|
import os
import pytest
import pathlib
import platform
from tests.LTP.agl_test_ltp_base import LTPBase
class CveBase(LTPBase):
def __init__(self):
super().__init__(test_name="cve")
def set_test_env(self):
# check into /proc/config.gz
path_Obj_gz = pathlib.Path("/proc/config.gz")
# check into /lib.modules/ for .config
release_info = platform.release()
config_file_path = "/lib/modules/" + release_info + "/build/.config"
path_Obj_config = pathlib.Path(config_file_path)
if not path_Obj_gz.is_file() and not path_Obj_config.is_file():
# set ENV "KCONFIG_SKIP_CHECK" to skip .config check
os.environ['KCONFIG_SKIP_CHECK'] = "True"
instance = CveBase()
skip_msg = "The current environment does not match the test requirements."
pytestmark = pytest.mark.skipif(instance.precheck() == False, reason = skip_msg)
test_case_list = instance.get_test_case_list()
@pytest.fixture(scope='module')
def testbase():
instance.set_test_env()
yield instance
#package log files and make report file
instance.log_report()
@pytest.mark.parametrize('case_name', test_case_list)
def test_ltp_cve(testbase: CveBase, case_name):
testbase.run_ltp_test(case_name)
testbase.run_case(case_name)
if __name__ == '__main__':
pytest.main("-s run_tests")
|