aboutsummaryrefslogtreecommitdiffstats
path: root/tests/LTP/syscalls/run_tests.py
blob: 5421f281566ac1e3a83b991e21528e668c294d0e (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
import os
import pytest
import pathlib
import platform
import subprocess

from tests.LTP.agl_test_ltp_base import LTPBase

class SyscallsBase(LTPBase):
    def __init__(self):
        super().__init__(test_name="syscalls")

    # a function that checks for .config related issues
    def set_test_env(self):
        # skip file generated and overwrited with essential skip list
        init_skipfile_cmd = "cat syscalls.skip.essential > " + self.get_skip_file_path()
        # work dir in /resource/
        cwd_buf = self.get_workdir()
        subprocess.run(init_skipfile_cmd, shell=True,
            cwd=cwd_buf, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        # check into /proc/config.gz
        pathObj_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"
        pathObj_config = pathlib.Path(config_file_path)
        if not pathObj_gz.is_file() and not pathObj_config.is_file():
            # set ENV "KCONFIG_SKIP_CHECK" to skip .config check
            os.environ['KCONFIG_SKIP_CHECK'] = "True"
            # add skip append to original skip file
            append_cmd = "cat syscalls.skip.append >> " + self.get_skip_file_path()
            subprocess.run(append_cmd, shell=True,
                cwd=cwd_buf, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        # check into group "ltp_add_key05_1" existence, ltp bug in 20210121
        with open("/etc/group", 'r') as f:
            text = f.read()
            if "ltp_add_key05_1" in text:
                rm_gourp_cmd = "groupdel ltp_add_key05_1"
                subprocess.run(rm_gourp_cmd, shell=True,
                    cwd=cwd_buf, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

instance = SyscallsBase()
skip_msg = "The current environment does not match the test requirements."
pytestmark = pytest.mark.skipif(instance.precheck() == False, reason = skip_msg)
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', case_list)
def test_ltp_syscalls(testbase: SyscallsBase, case_name):
    testbase.run_ltp_test(case_name)
    testbase.run_case(case_name)

if __name__ == '__main__':
    pytest.main("-s run_tests")