diff options
-rw-r--r-- | plugins/agl_test_base.py | 2 | ||||
-rw-r--r-- | plugins/agl_test_ptest_base.py | 18 | ||||
-rw-r--r-- | tests/aio-stress/run_tests.py | 12 | ||||
-rw-r--r-- | tests/bzip2/run_tests.py | 12 | ||||
-rw-r--r-- | tests/expat/run_tests.py | 6 | ||||
-rw-r--r-- | tests/glib2/run_tests.py | 6 | ||||
-rw-r--r-- | tests/zlib/run_tests.py | 6 |
7 files changed, 60 insertions, 2 deletions
diff --git a/plugins/agl_test_base.py b/plugins/agl_test_base.py index 1a2c602..0e3a153 100644 --- a/plugins/agl_test_base.py +++ b/plugins/agl_test_base.py @@ -107,3 +107,5 @@ class AGLBaseTest: #Write json data to html report.change_json_to_html(self.name) + def precheck(self): + return True; diff --git a/plugins/agl_test_ptest_base.py b/plugins/agl_test_ptest_base.py index f7b5829..2bbe6e0 100644 --- a/plugins/agl_test_ptest_base.py +++ b/plugins/agl_test_ptest_base.py @@ -1,7 +1,9 @@ import subprocess - +import pathlib from plugins.agl_test_base import AGLBaseTest +PTEST_CMD = "/usr/bin/ptest-runner" + class PTESTBase(AGLBaseTest): def __init__(self, test_name: str): @@ -28,3 +30,17 @@ class PTESTBase(AGLBaseTest): self.update_caseinfo_by_name(case_id, case_info) assert case_info[2] == "passed" or case_info[2] == "skipped" + + def precheck(self): + # check for common + check_common = super().precheck() + + # check for ptest-runner + path = pathlib.Path(PTEST_CMD) + check_ptest_cmd = path.is_file() + + # check self test scripts + test_script = pathlib.Path("/usr/lib/" + super().get_name() + "/ptest/run-ptest") + check_test_script = test_script.is_file() + + return check_common and check_ptest_cmd and check_test_script diff --git a/tests/aio-stress/run_tests.py b/tests/aio-stress/run_tests.py index fc966a1..e7e8b5c 100644 --- a/tests/aio-stress/run_tests.py +++ b/tests/aio-stress/run_tests.py @@ -1,5 +1,6 @@ import pytest import subprocess +import pathlib from plugins.agl_test_base import AGLBaseTest @@ -27,6 +28,11 @@ class AIOBase(AGLBaseTest): self.case_info_list = {'test_aiostress': ['test_aiostress', '', 'failed']} + def precheck(self): + run_test = self.get_workdir() + "/aio-stress" + path_script = pathlib.Path(run_test) + return super().precheck() and path_script.is_file() + @pytest.fixture(scope='module') def testbase(): #init instance for test @@ -42,6 +48,12 @@ def testbase(): def setup_module(testbase: AIOBase): print("setup function start") +def precheck(): + instance = AIOBase() + return instance.precheck() +skip_msg = "The current environment does not match the test requirements." +pytestmark = pytest.mark.skipif(precheck() == False, reason = skip_msg) + @pytest.mark.oss_default def test_aiostress(testbase: AIOBase): assert testbase.case_info_list['test_aiostress'][2] == 'passed' diff --git a/tests/bzip2/run_tests.py b/tests/bzip2/run_tests.py index c4ee56d..677ac84 100644 --- a/tests/bzip2/run_tests.py +++ b/tests/bzip2/run_tests.py @@ -1,5 +1,5 @@ import pytest - +import pathlib import tests.bzip2.parser as parser from plugins.agl_test_ptest_base import PTESTBase @@ -13,6 +13,10 @@ class BZIP2Base(PTESTBase): self.case_info_list = parser.log_parse(log_file) self.init_case_status() + def precheck(self): + path_bzip2 = pathlib.Path("/usr/bin/bzip2") + return super().precheck() and path_bzip2.is_file() + @pytest.fixture(scope='module') def testbase(): #init instance for test @@ -29,6 +33,12 @@ def testbase(): def setup_module(testbase: BZIP2Base): print("setup function start") +def precheck(): + instance = BZIP2Base() + return instance.precheck() +skip_msg = "The current environment does not match the test requirements." +pytestmark = pytest.mark.skipif(precheck() == False, reason = skip_msg) + def test_sample1_compress(testbase: BZIP2Base): name = "sample1 compress" testbase.run_case(name) diff --git a/tests/expat/run_tests.py b/tests/expat/run_tests.py index aef92a7..43014d1 100644 --- a/tests/expat/run_tests.py +++ b/tests/expat/run_tests.py @@ -29,6 +29,12 @@ def testbase(): def setup_module(testbase: EXPATBase): print("setup function start") +def precheck(): + instance = EXPATBase() + return instance.precheck() +skip_msg = "The current environment does not match the test requirements." +pytestmark = pytest.mark.skipif(precheck() == False, reason = skip_msg) + def test_runtests_test_accounting_precision(testbase: EXPATBase): name = "runtests_test_accounting_precision" testbase.run_case(name) diff --git a/tests/glib2/run_tests.py b/tests/glib2/run_tests.py index 37c91d5..ce45df9 100644 --- a/tests/glib2/run_tests.py +++ b/tests/glib2/run_tests.py @@ -31,6 +31,12 @@ def testbase(): def setup_module(testbase: GLIB2Base): print("setup function start") +def precheck(): + instance = GLIB2Base() + return instance.precheck() +skip_msg = "The current environment does not match the test requirements." +pytestmark = pytest.mark.skipif(precheck() == False, reason = skip_msg) + @pytest.mark.oss_default def test_timeloop_closure(testbase: GLIB2Base): name = "glib/timeloop-closure.test" diff --git a/tests/zlib/run_tests.py b/tests/zlib/run_tests.py index b9c3826..bf62390 100644 --- a/tests/zlib/run_tests.py +++ b/tests/zlib/run_tests.py @@ -28,6 +28,12 @@ def testbase(): #package log files and make report file instance.log_report() +def precheck(): + instance = ZLIBBase() + return instance.precheck() +skip_msg = "The current environment does not match the test requirements." +pytestmark = pytest.mark.skipif(precheck() == False, reason = skip_msg) + def setup_module(testbase: ZLIBBase): print("setup function start") |