diff options
author | duerpei <duep.fnst@fujitsu.com> | 2023-07-12 04:58:50 +0800 |
---|---|---|
committer | duerpei <duep.fnst@fujitsu.com> | 2023-07-12 04:58:50 +0800 |
commit | fb969436af3ebbdc81c15b23ad8b1ef37a8c2694 (patch) | |
tree | 6d831d66c6e4d799e837a443a548a4ffae2a98a2 /tests/aio_stress/run_tests.py | |
parent | 581b83641ff0ecd114d87a8b7eab04f81fd2e7f5 (diff) |
agl-test-framework: replace "-" with "_"
Replace "-" with "_" in the name of the directory to
solve the following errors when running agl-test:
import file mismatch:
imported module 'run_tests' has this __file__ attribute:
/usr/AGL/agl-test/tests/aio-stress/run_tests.py
which is not the same as the test file we want to collect:
/usr/AGL/agl-test/tests/gdk-pixbuf/run_tests.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename
for your test file modules
Bug-AGL: SPEC-4345
Signed-off-by: duerpei <duep.fnst@fujitsu.com>
Change-Id: Id8028dfbda618a9b7858602d3832bf2eb7f7ef5e
Diffstat (limited to 'tests/aio_stress/run_tests.py')
-rw-r--r-- | tests/aio_stress/run_tests.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/aio_stress/run_tests.py b/tests/aio_stress/run_tests.py new file mode 100644 index 0000000..e7e8b5c --- /dev/null +++ b/tests/aio_stress/run_tests.py @@ -0,0 +1,62 @@ +import pytest +import subprocess +import pathlib + +from plugins.agl_test_base import AGLBaseTest + +class AIOBase(AGLBaseTest): + def __init__(self): + super().__init__(name="aio-stress") + + def run_test_fun(self): + log_file = self.get_logfile() + cwd = self.get_temp_logdir() + workdir = self.get_workdir() + run_test = workdir + '/aio-stress -s ' + \ + '$TEST_FILE_SIZE ' + './testfile' + + with open(log_file, 'w') as log_f: + output = subprocess.run(run_test, shell=True, + cwd=cwd, stdout=log_f, stderr=log_f, + env={'TEST_FILE_SIZE': '20M'}) + log_f.close() + + if (output.returncode == 0): + self.case_info_list = {'test_aiostress': ['test_aiostress', + '', 'passed']} + else: + 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 + instance = AIOBase() + #run test scripts + instance.run_test_fun() + + yield instance + + #package log files and make report file + instance.log_report() + +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' + +if __name__ == '__main__': + pytest.main("-s run_tests") |