diff options
author | yanxk <yanxk.fnst@fujitsu.com> | 2021-03-30 16:53:03 +0800 |
---|---|---|
committer | yanxk <yanxk.fnst@fujitsu.com> | 2021-03-30 16:53:03 +0800 |
commit | 581b83641ff0ecd114d87a8b7eab04f81fd2e7f5 (patch) | |
tree | 6fc82a5fee88fa0c856266d8fd982a66e7e96df2 | |
parent | 5386506f863cc951f618f622d61adf93596eb6a0 (diff) |
agl-test-framework: add LTP syscalls tests into framework
syscalls in LTP version 20220121 contains some bugs, those have
been adjusted in order to provide trustable test reports.
Bug-AGL: SPEC-4345
Signed-off-by: yanxk <yanxk.fnst@fujitsu.com>
Change-Id: I41aba8e64e9b916066f9a60ffac863ffdbabbf47
-rw-r--r-- | tests/LTP/agl_test_ltp_base.py | 16 | ||||
-rw-r--r-- | tests/LTP/syscalls/__init__.py | 0 | ||||
-rw-r--r-- | tests/LTP/syscalls/resource/syscalls.skip.append | 6 | ||||
-rw-r--r-- | tests/LTP/syscalls/resource/syscalls.skip.essential | 12 | ||||
-rw-r--r-- | tests/LTP/syscalls/run_tests.py | 58 |
5 files changed, 91 insertions, 1 deletions
diff --git a/tests/LTP/agl_test_ltp_base.py b/tests/LTP/agl_test_ltp_base.py index f8bd708..44d5325 100644 --- a/tests/LTP/agl_test_ltp_base.py +++ b/tests/LTP/agl_test_ltp_base.py @@ -49,10 +49,19 @@ class LTPBase(AGLBaseTest): test_cases.close() return case_list + def get_skip_file_path(self): + path = self.get_log_path() + self.test_name + ".skip" + return path + + def has_skip_file(self): + path = self.get_skip_file_path() + pathObj_skipfile = pathlib.Path(path) + return pathObj_skipfile.is_file() + #Run test by runltp def run_test_fun(self, case_name): tmp_log_dir = self.get_log_path() - run_test_cmd = self.RUNLTP + \ + run_test_cmd_basic = self.RUNLTP + \ " -f " + self.test_name + \ " -s "+ "^" + case_name + "\\\\b" + \ " -p " + \ @@ -63,6 +72,11 @@ class LTPBase(AGLBaseTest): console_log = tmp_log_dir + self.test_name + ".console" + if not self.has_skip_file(): + run_test_cmd = run_test_cmd_basic + else: + run_test_cmd = run_test_cmd_basic + " -S " + self.get_skip_file_path() + with open(console_log, 'a') as consolelog: subprocess.run(run_test_cmd, shell = True, stdout = consolelog, stderr = consolelog) diff --git a/tests/LTP/syscalls/__init__.py b/tests/LTP/syscalls/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/LTP/syscalls/__init__.py diff --git a/tests/LTP/syscalls/resource/syscalls.skip.append b/tests/LTP/syscalls/resource/syscalls.skip.append new file mode 100644 index 0000000..c3ea1f9 --- /dev/null +++ b/tests/LTP/syscalls/resource/syscalls.skip.append @@ -0,0 +1,6 @@ +# these 4 cases depend on kernel config to provide +# trustful reports, otherwise would FAIL automatically +acct02 +ftruncate04 +ftruncate04_64 +shmget02 diff --git a/tests/LTP/syscalls/resource/syscalls.skip.essential b/tests/LTP/syscalls/resource/syscalls.skip.essential new file mode 100644 index 0000000..e87518b --- /dev/null +++ b/tests/LTP/syscalls/resource/syscalls.skip.essential @@ -0,0 +1,12 @@ +# listed 10 suites are not working, they have been removed in the +# latest version of LTP, we are not going to run them in 20220121 +syslog01 +syslog02 +syslog03 +syslog04 +syslog05 +syslog06 +syslog07 +syslog08 +syslog09 +syslog10 diff --git a/tests/LTP/syscalls/run_tests.py b/tests/LTP/syscalls/run_tests.py new file mode 100644 index 0000000..37bd365 --- /dev/null +++ b/tests/LTP/syscalls/run_tests.py @@ -0,0 +1,58 @@ +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() +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") |