aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQiu Tingting <qiutt@fujitsu.com>2022-07-24 16:17:13 +0800
committerQiu Tingting <qiutt@fujitsu.com>2022-07-24 16:32:14 +0800
commit96f6fed2eba4ddaa6912a5cdba41e80a91e47115 (patch)
treeac5d504888d0e40460d9519777b023a15cf45169 /tests
parent3c200f4ea6721f07de8d728056e4381ddd2eec6b (diff)
Add precheck() fun
Checking env before run testsuite is necessary. 1. Add common check in agl_test_base.py. It is currently an empty function. If necessary, common check sould be added. 2. Add ptest common check in agl_test_ptest_base.py. For ptest testsuite, check whether ptest-runner and run-ptest script exist. 3. Add special check in run_tests.py. For aio-stress testsuite, check whether compiled aio-stress script exists For bzip2 testsuite, check whether bzip2 cmd exists. Bug-AGL: SPEC-4345 Signed-off-by: Qiu Tingting <qiutt@fujitsu.com> Change-Id: Id7841c0337465266dd607403ecb3e1c4377c6198
Diffstat (limited to 'tests')
-rw-r--r--tests/aio-stress/run_tests.py12
-rw-r--r--tests/bzip2/run_tests.py12
-rw-r--r--tests/expat/run_tests.py6
-rw-r--r--tests/glib2/run_tests.py6
-rw-r--r--tests/zlib/run_tests.py6
5 files changed, 41 insertions, 1 deletions
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")