From fb969436af3ebbdc81c15b23ad8b1ef37a8c2694 Mon Sep 17 00:00:00 2001 From: duerpei Date: Wed, 12 Jul 2023 04:58:50 +0800 Subject: 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 Change-Id: Id8028dfbda618a9b7858602d3832bf2eb7f7ef5e --- tests/aio-stress/__init__.py | 0 tests/aio-stress/run_tests.py | 62 ------------------------------------------- tests/aio_stress/__init__.py | 0 tests/aio_stress/run_tests.py | 62 +++++++++++++++++++++++++++++++++++++++++++ tests/gdk-pixbuf/__init__.py | 0 tests/gdk-pixbuf/run_tests.py | 29 -------------------- tests/gdk_pixbuf/__init__.py | 0 tests/gdk_pixbuf/run_tests.py | 29 ++++++++++++++++++++ tests/stress-ng/__init__.py | 0 tests/stress-ng/run_tests.py | 55 -------------------------------------- tests/stress_ng/__init__.py | 0 tests/stress_ng/run_tests.py | 55 ++++++++++++++++++++++++++++++++++++++ 12 files changed, 146 insertions(+), 146 deletions(-) delete mode 100644 tests/aio-stress/__init__.py delete mode 100644 tests/aio-stress/run_tests.py create mode 100644 tests/aio_stress/__init__.py create mode 100644 tests/aio_stress/run_tests.py delete mode 100644 tests/gdk-pixbuf/__init__.py delete mode 100644 tests/gdk-pixbuf/run_tests.py create mode 100644 tests/gdk_pixbuf/__init__.py create mode 100644 tests/gdk_pixbuf/run_tests.py delete mode 100644 tests/stress-ng/__init__.py delete mode 100644 tests/stress-ng/run_tests.py create mode 100644 tests/stress_ng/__init__.py create mode 100644 tests/stress_ng/run_tests.py (limited to 'tests') diff --git a/tests/aio-stress/__init__.py b/tests/aio-stress/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/aio-stress/run_tests.py b/tests/aio-stress/run_tests.py deleted file mode 100644 index e7e8b5c..0000000 --- a/tests/aio-stress/run_tests.py +++ /dev/null @@ -1,62 +0,0 @@ -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") diff --git a/tests/aio_stress/__init__.py b/tests/aio_stress/__init__.py new file mode 100644 index 0000000..e69de29 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") diff --git a/tests/gdk-pixbuf/__init__.py b/tests/gdk-pixbuf/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/gdk-pixbuf/run_tests.py b/tests/gdk-pixbuf/run_tests.py deleted file mode 100644 index 56bda29..0000000 --- a/tests/gdk-pixbuf/run_tests.py +++ /dev/null @@ -1,29 +0,0 @@ -import pytest - -import plugins.agl_test_log as log - -from plugins.agl_test_ptest_base import PTESTBase - -class GdkPixbufBase(PTESTBase): - def __init__(self): - super().__init__(test_name="gdk-pixbuf") - - def log_process(self): - log_file = self.get_logfile() - self.case_info_list = log.log_process_gnome_desktop_testing(log_file) - -instance = GdkPixbufBase() -instance.run_ptest() - -@pytest.fixture(scope='module') -def testbase(): - yield instance - #package log files and make report file - instance.log_report() - -@pytest.mark.parametrize('case_name', instance.case_info_list.keys()) -def test_gdk_pixbuf(testbase: GdkPixbufBase, case_name): - testbase.run_case(case_name) - -if __name__ == '__main__': - pytest.main("-s run_tests") diff --git a/tests/gdk_pixbuf/__init__.py b/tests/gdk_pixbuf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/gdk_pixbuf/run_tests.py b/tests/gdk_pixbuf/run_tests.py new file mode 100644 index 0000000..56bda29 --- /dev/null +++ b/tests/gdk_pixbuf/run_tests.py @@ -0,0 +1,29 @@ +import pytest + +import plugins.agl_test_log as log + +from plugins.agl_test_ptest_base import PTESTBase + +class GdkPixbufBase(PTESTBase): + def __init__(self): + super().__init__(test_name="gdk-pixbuf") + + def log_process(self): + log_file = self.get_logfile() + self.case_info_list = log.log_process_gnome_desktop_testing(log_file) + +instance = GdkPixbufBase() +instance.run_ptest() + +@pytest.fixture(scope='module') +def testbase(): + yield instance + #package log files and make report file + instance.log_report() + +@pytest.mark.parametrize('case_name', instance.case_info_list.keys()) +def test_gdk_pixbuf(testbase: GdkPixbufBase, case_name): + testbase.run_case(case_name) + +if __name__ == '__main__': + pytest.main("-s run_tests") diff --git a/tests/stress-ng/__init__.py b/tests/stress-ng/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/stress-ng/run_tests.py b/tests/stress-ng/run_tests.py deleted file mode 100644 index ec6822b..0000000 --- a/tests/stress-ng/run_tests.py +++ /dev/null @@ -1,55 +0,0 @@ -import pytest -import subprocess -import pathlib - -from plugins.agl_test_base import AGLBaseTest - -class StressngBase(AGLBaseTest): - def __init__(self): - super().__init__(name="stress-ng") - - def run_test_fun(self): - log_file = self.get_logfile() - run_test = 'stress-ng ' +\ - '-i 2 -c 2 --hdd 2 --hdd-bytes 100M --vm 2 --vm-bytes 128M -t 60' - - with open(log_file, 'w') as log_f: - output = subprocess.run(run_test, shell=True, - stdout=log_f, stderr=log_f) - log_f.close() - - if (output.returncode == 0): - self.case_info_list = {'test_stress-ng': ['test_stress-ng', - str(output.returncode), 'passed']} - else: - self.case_info_list = {'test_stress-ng': ['test_stress-ng', - str(output.returncode), 'failed']} - - def precheck(self): - path_stress_ng = pathlib.Path("/usr/bin/stress-ng") - return super().precheck() and path_stress_ng.is_file() - -@pytest.fixture(scope='module') -def testbase(): - #init instance for test - instance = StressngBase() - #run test scripts - instance.run_test_fun() - - yield instance - - #package log files and make report file - instance.log_report() - -def precheck(): - instance = StressngBase() - 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_stress_ng(testbase: StressngBase): - assert testbase.case_info_list['test_stress-ng'][1] == '0' - -if __name__ == '__main__': - pytest.main("-s run_tests") diff --git a/tests/stress_ng/__init__.py b/tests/stress_ng/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/stress_ng/run_tests.py b/tests/stress_ng/run_tests.py new file mode 100644 index 0000000..ec6822b --- /dev/null +++ b/tests/stress_ng/run_tests.py @@ -0,0 +1,55 @@ +import pytest +import subprocess +import pathlib + +from plugins.agl_test_base import AGLBaseTest + +class StressngBase(AGLBaseTest): + def __init__(self): + super().__init__(name="stress-ng") + + def run_test_fun(self): + log_file = self.get_logfile() + run_test = 'stress-ng ' +\ + '-i 2 -c 2 --hdd 2 --hdd-bytes 100M --vm 2 --vm-bytes 128M -t 60' + + with open(log_file, 'w') as log_f: + output = subprocess.run(run_test, shell=True, + stdout=log_f, stderr=log_f) + log_f.close() + + if (output.returncode == 0): + self.case_info_list = {'test_stress-ng': ['test_stress-ng', + str(output.returncode), 'passed']} + else: + self.case_info_list = {'test_stress-ng': ['test_stress-ng', + str(output.returncode), 'failed']} + + def precheck(self): + path_stress_ng = pathlib.Path("/usr/bin/stress-ng") + return super().precheck() and path_stress_ng.is_file() + +@pytest.fixture(scope='module') +def testbase(): + #init instance for test + instance = StressngBase() + #run test scripts + instance.run_test_fun() + + yield instance + + #package log files and make report file + instance.log_report() + +def precheck(): + instance = StressngBase() + 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_stress_ng(testbase: StressngBase): + assert testbase.case_info_list['test_stress-ng'][1] == '0' + +if __name__ == '__main__': + pytest.main("-s run_tests") -- cgit 1.2.3-korg