diff --git a/hwbench/bench/test_benchmarks.py b/hwbench/bench/test_benchmarks.py index f1eb9ea..aaa0b10 100644 --- a/hwbench/bench/test_benchmarks.py +++ b/hwbench/bench/test_benchmarks.py @@ -12,17 +12,18 @@ def __init__(self, *args, **kwargs): with patch( "hwbench.engines.stressng.EngineModuleCpu.list_module_parameters" ) as p: + print(pathlib.Path(".")) p.return_value = ( - pathlib.Path("./tests/parsing/stressngmethods/v17/stdout") + pathlib.Path("hwbench/tests/parsing/stressngmethods/v17/stdout") .read_bytes() .split(b":", 1) ) self.load_mocked_hardware( - cpucores="./tests/parsing/cpu_cores/v2321", - cpuinfo="./tests/parsing/cpu_info/v2321", - numa="./tests/parsing/numa/8domainsllc", + cpucores="hwbench/tests/parsing/cpu_cores/v2321", + cpuinfo="hwbench/tests/parsing/cpu_info/v2321", + numa="hwbench/tests/parsing/numa/8domainsllc", ) - self.load_benches("./config/sample.ini") + self.load_benches("./hwbench/config/sample.ini") self.parse_jobs_config() def test_parsing(self): @@ -100,11 +101,11 @@ def test_stream_short(self): "hwbench.engines.stressng.EngineModuleCpu.list_module_parameters" ) as p: p.return_value = ( - pathlib.Path("./tests/parsing/stressngmethods/v17/stdout") + pathlib.Path("./hwbench/tests/parsing/stressngmethods/v17/stdout") .read_bytes() .split(b":", 1) ) - self.load_benches("./config/stream.ini") + self.load_benches("./hwbench/config/stream.ini") assert self.get_jobs_config().get_config().getint("global", "runtime") == 5 self.get_jobs_config().get_config().set("global", "runtime", "2") with self.assertRaises(SystemExit): diff --git a/hwbench/bench/test_benchmarks_common.py b/hwbench/bench/test_benchmarks_common.py index 14cadd6..beda82b 100644 --- a/hwbench/bench/test_benchmarks_common.py +++ b/hwbench/bench/test_benchmarks_common.py @@ -65,7 +65,7 @@ def parse_jobs_config(self, validate_parameters=True): with patch("hwbench.environment.turbostat.Turbostat.check_version") as cv: cv.return_value = True with patch("hwbench.environment.turbostat.Turbostat.run") as ts: - with open("tests/parsing/turbostat/run", "r") as f: + with open("hwbench/tests/parsing/turbostat/run", "r") as f: ts.return_value = ast.literal_eval(f.read()) return self.benches.parse_jobs_config(validate_parameters) diff --git a/hwbench/bench/test_cores.py b/hwbench/bench/test_cores.py index 5b69b12..130c9cc 100644 --- a/hwbench/bench/test_cores.py +++ b/hwbench/bench/test_cores.py @@ -5,11 +5,11 @@ class TestCores(tbc.TestCommon): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.load_mocked_hardware( - cpucores="./tests/parsing/cpu_cores/v2321", - cpuinfo="./tests/parsing/cpu_info/v2321", - numa="./tests/parsing/numa/8domainsllc", + cpucores="./hwbench/tests/parsing/cpu_cores/v2321", + cpuinfo="./hwbench/tests/parsing/cpu_info/v2321", + numa="./hwbench/tests/parsing/numa/8domainsllc", ) - self.load_benches("./config/cores.conf") + self.load_benches("./hwbench/config/cores.conf") self.parse_jobs_config() def test_cores(self): @@ -30,7 +30,7 @@ def test_cores(self): assert self.get_bench_parameters(3).get_pinned_cpu() == CPU0_1 # Testing broken syntax that must fail - self.load_benches("./config/sample_weirds.conf") + self.load_benches("./hwbench/config/sample_weirds.conf") for test_name in [ "invalid_cpu_core", "alpha_cpu_core", diff --git a/hwbench/bench/test_helpers.py b/hwbench/bench/test_helpers.py index 0812bc9..85500bb 100644 --- a/hwbench/bench/test_helpers.py +++ b/hwbench/bench/test_helpers.py @@ -5,11 +5,11 @@ class TestHelpers(tbc.TestCommon): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.load_mocked_hardware( - cpucores="./tests/parsing/cpu_cores/v2321", - cpuinfo="./tests/parsing/cpu_info/v2321", - numa="./tests/parsing/numa/8domainsllc", + cpucores="./hwbench/tests/parsing/cpu_cores/v2321", + cpuinfo="./hwbench/tests/parsing/cpu_info/v2321", + numa="./hwbench/tests/parsing/numa/8domainsllc", ) - self.load_benches("./config/helpers.conf") + self.load_benches("./hwbench/config/helpers.conf") self.parse_jobs_config() def test_helpers(self): @@ -32,11 +32,11 @@ class TestHelpers_CPUSTORAGE(tbc.TestCommon): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.load_mocked_hardware( - cpucores="./tests/parsing/cpu_cores/cpustorage", - cpuinfo="./tests/parsing/cpu_info/cpustorage", - numa="./tests/parsing/numa/2domains", + cpucores="./hwbench/tests/parsing/cpu_cores/cpustorage", + cpuinfo="./hwbench/tests/parsing/cpu_info/cpustorage", + numa="./hwbench/tests/parsing/numa/2domains", ) - self.load_benches("./config/helpers.conf") + self.load_benches("./hwbench/config/helpers.conf") self.parse_jobs_config() def test_helpers(self): @@ -59,11 +59,11 @@ class TestHelpersImpossible(tbc.TestCommon): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.load_mocked_hardware( - cpucores="./tests/parsing/cpu_cores/v2321", - cpuinfo="./tests/parsing/cpu_info/v2321", - numa="./tests/parsing/numa/8domainsllc", + cpucores="./hwbench/tests/parsing/cpu_cores/v2321", + cpuinfo="./hwbench/tests/parsing/cpu_info/v2321", + numa="./hwbench/tests/parsing/numa/8domainsllc", ) - self.load_benches("./config/helpers_fail.conf") + self.load_benches("./hwbench/config/helpers_fail.conf") def test_helpers_impossible(self): """Testing impossible helper usecase.""" diff --git a/hwbench/bench/test_numa.py b/hwbench/bench/test_numa.py index 8bab5eb..136c4f8 100644 --- a/hwbench/bench/test_numa.py +++ b/hwbench/bench/test_numa.py @@ -5,16 +5,16 @@ class TestNuma(tbc.TestCommon): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.load_mocked_hardware( - cpucores="./tests/parsing/cpu_cores/v2321", - cpuinfo="./tests/parsing/cpu_info/v2321", - numa="./tests/parsing/numa/8domainsllc", + cpucores="./hwbench/tests/parsing/cpu_cores/v2321", + cpuinfo="./hwbench/tests/parsing/cpu_info/v2321", + numa="./hwbench/tests/parsing/numa/8domainsllc", ) self.NUMA0 = list(range(0, 8)) + list(range(64, 72)) self.NUMA1 = list(range(8, 16)) + list(range(72, 80)) self.NUMA0_1 = sorted(self.NUMA0 + self.NUMA1) self.NUMA7 = list(range(56, 64)) + list(range(120, 128)) self.NUMA07 = list(range(0, self.hw.get_cpu().get_logical_cores_count())) - self.load_benches("./config/numa.conf") + self.load_benches("./hwbench/config/numa.conf") self.parse_jobs_config() def test_quadrant(self): @@ -28,7 +28,7 @@ def test_quadrant(self): # Testing broken syntax that must fail # Testing quadrants - self.load_benches("./config/sample_weirds.conf") + self.load_benches("./hwbench/config/sample_weirds.conf") for test_name in [ "invalid_quadrant", "alpha_quadrant", @@ -59,7 +59,7 @@ def test_numa(self): # Testing broken syntax that must fail # Testing quadrants - self.load_benches("./config/sample_weirds.conf") + self.load_benches("./hwbench/config/sample_weirds.conf") for test_name in [ "invalid_numa_nodes", "alpha_numa_nodes", diff --git a/hwbench/bench/test_spike.py b/hwbench/bench/test_spike.py index 7cf9f70..5a9ad57 100644 --- a/hwbench/bench/test_spike.py +++ b/hwbench/bench/test_spike.py @@ -5,11 +5,11 @@ class TestSpike(tbc.TestCommon): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.load_mocked_hardware( - cpucores="./tests/parsing/cpu_cores/v2321", - cpuinfo="./tests/parsing/cpu_info/v2321", - numa="./tests/parsing/numa/8domainsllc", + cpucores="./hwbench/tests/parsing/cpu_cores/v2321", + cpuinfo="./hwbench/tests/parsing/cpu_info/v2321", + numa="./hwbench/tests/parsing/numa/8domainsllc", ) - self.load_benches("./config/spike.conf") + self.load_benches("./hwbench/config/spike.conf") self.parse_jobs_config() self.QUADRANT0 = list(range(0, 16)) + list(range(64, 80)) self.QUADRANT1 = list(range(16, 32)) + list(range(80, 96)) @@ -33,7 +33,7 @@ def test_spike(self): def test_spike_wrong_syntax(self): # Testing broken syntax that must fail # Testing quadrants - self.load_benches("./config/spike_weirds.conf") + self.load_benches("./hwbench/config/spike_weirds.conf") self.parse_jobs_config(validate_parameters=False) self.should_be_fatal(self.benches.benchs[0].validate_parameters) diff --git a/hwbench/config/test_parse.py b/hwbench/config/test_parse.py index 7690e5c..7ed4d12 100644 --- a/hwbench/config/test_parse.py +++ b/hwbench/config/test_parse.py @@ -11,12 +11,12 @@ def __init__(self, *args, **kwargs): "hwbench.engines.stressng.EngineModuleCpu.list_module_parameters" ) as p: p.return_value = ( - pathlib.Path("./tests/parsing/stressngmethods/v17/stdout") + pathlib.Path("./hwbench/tests/parsing/stressngmethods/v17/stdout") .read_bytes() .split(b":", 1) ) self.hw = MockHardware() - self.load_benches("./config/sample.ini") + self.load_benches("./hwbench/config/sample.ini") def test_sections_name(self): """Check if sections names are properly detected.""" @@ -43,7 +43,7 @@ def test_keywords(self): "hwbench.engines.stressng.EngineModuleCpu.list_module_parameters" ) as p: p.return_value = ( - pathlib.Path("./tests/parsing/stressngmethods/v17/stdout") + pathlib.Path("./hwbench/tests/parsing/stressngmethods/v17/stdout") .read_bytes() .split(b":", 1) ) @@ -59,11 +59,11 @@ def test_defaults(self): "hwbench.engines.stressng.EngineModuleCpu.list_module_parameters" ) as p: p.return_value = ( - pathlib.Path("./tests/parsing/stressngmethods/v17/stdout") + pathlib.Path("./hwbench/tests/parsing/stressngmethods/v17/stdout") .read_bytes() .split(b":", 1) ) - self.load_benches("./config/sample_weirds.conf") + self.load_benches("./hwbench/config/sample_weirds.conf") assert ( self.get_jobs_config().get_config().getint("noglobalruntime", "runtime") == 60 diff --git a/hwbench/engines/test_parse.py b/hwbench/engines/test_parse.py index ce7d315..656df8f 100644 --- a/hwbench/engines/test_parse.py +++ b/hwbench/engines/test_parse.py @@ -28,7 +28,9 @@ def mock_engine(version: str) -> StressNG: "hwbench.engines.stressng.EngineModuleCpu.list_module_parameters" ) as p: p.return_value = ( - pathlib.Path(f"./tests/parsing/stressngmethods/{version}/stdout") + pathlib.Path( + f"./hwbench/tests/parsing/stressngmethods/{version}/stdout" + ) .read_bytes() .split(b":", 1) ) @@ -37,7 +39,7 @@ def mock_engine(version: str) -> StressNG: class TestParse(unittest.TestCase): def test_engine_parsing_version(self): - test_dir = pathlib.Path("./tests/parsing/stressng") + test_dir = pathlib.Path("./hwbench/tests/parsing/stressng") for d in test_dir.iterdir(): test_target = mock_engine("v17") if not d.is_dir(): @@ -54,7 +56,7 @@ def test_module_parsing_output(self): (StressNGStream, EngineModuleStream, "stressng-stream", 0, engine_v17), (StressNGMemrate, EngineModuleMemrate, "stressng-memrate", 128, engine_v17), ]: - test_dir = pathlib.Path(f"./tests/parsing/{prefix}") + test_dir = pathlib.Path(f"./hwbench/tests/parsing/{prefix}") for d in test_dir.iterdir(): if not d.is_dir(): continue @@ -95,7 +97,7 @@ def test_module_parsing_output(self): assert output == json.loads((d / "output").read_bytes()) def test_stressng_methods(self): - test_dir = pathlib.Path("./tests/parsing/stressngmethods") + test_dir = pathlib.Path("./hwbench/tests/parsing/stressngmethods") for d in test_dir.iterdir(): if not d.is_dir(): continue diff --git a/hwbench/environment/test_hpe.py b/hwbench/environment/test_hpe.py index 7587b7b..41add91 100644 --- a/hwbench/environment/test_hpe.py +++ b/hwbench/environment/test_hpe.py @@ -16,7 +16,9 @@ class TestGenericHpe(TestVendors): def __init__(self, path: str, *args, **kwargs): - super().__init__(Hpe("", None, "tests/mocked_monitoring.cfg"), *args, **kwargs) + super().__init__( + Hpe("", None, "hwbench/tests/mocked_monitoring.cfg"), *args, **kwargs + ) self.path = path def setUp(self): diff --git a/hwbench/environment/test_parse.py b/hwbench/environment/test_parse.py index 469e613..d7befc9 100644 --- a/hwbench/environment/test_parse.py +++ b/hwbench/environment/test_parse.py @@ -12,7 +12,7 @@ class TestParseCPU(object): def test_ami_aptio(self): - d = pathlib.Path("./tests/parsing/ami_aptio/v5") + d = pathlib.Path("./hwbench/tests/parsing/ami_aptio/v5") print(f"parsing test {d.name}") test_target = amd.Ami_Aptio(path) ver_stdout = (d / "version-stdout").read_bytes() @@ -22,8 +22,8 @@ def test_ami_aptio(self): def test_parsing_cpuinfo(self): for d in [ - pathlib.Path("./tests/parsing/cpu_info/v2321"), - pathlib.Path("./tests/parsing/cpu_info/cpustorage"), + pathlib.Path("./hwbench/tests/parsing/cpu_info/v2321"), + pathlib.Path("./hwbench/tests/parsing/cpu_info/cpustorage"), ]: print(f"parsing test {d.name}") test_target = cpu_info.CPU_INFO(path) @@ -49,7 +49,7 @@ def test_parsing_cpuinfo(self): assert test_target.get_vendor() == output["Vendor ID"] def test_parsing_cpu_cores(self): - d = pathlib.Path("./tests/parsing/cpu_cores/v2321") + d = pathlib.Path("./hwbench/tests/parsing/cpu_cores/v2321") print(f"parsing test {d.name}") test_target = cpu_cores.CPU_CORES(path) @@ -202,7 +202,7 @@ def test_parsing_cpu_cores(self): assert test_target.get_peer_sibling(64) == 0 def test_parsing_numa_1_domain(self): - d = pathlib.Path("./tests/parsing/numa/1domain") + d = pathlib.Path("./hwbench/tests/parsing/numa/1domain") print(f"parsing test {d.name}") test_target = numa.NUMA(path) @@ -214,7 +214,7 @@ def test_parsing_numa_1_domain(self): assert len(test_target.get_cores(0)) == 128 def test_parsing_numa_2_domains(self): - d = pathlib.Path("./tests/parsing/numa/2domains") + d = pathlib.Path("./hwbench/tests/parsing/numa/2domains") print(f"parsing test {d.name}") test_target = numa.NUMA(path) @@ -227,7 +227,7 @@ def test_parsing_numa_2_domains(self): assert len(test_target.get_cores(1)) == 36 def test_parsing_numa_4_domains(self): - d = pathlib.Path("./tests/parsing/numa/4domains") + d = pathlib.Path("./hwbench/tests/parsing/numa/4domains") print(f"parsing test {d.name}") test_target = numa.NUMA(path) @@ -240,7 +240,7 @@ def test_parsing_numa_4_domains(self): assert len(test_target.get_cores(domain)) == 16 def test_parsing_numa_8_domains_with_llc(self): - d = pathlib.Path("./tests/parsing/numa/8domainsllc") + d = pathlib.Path("./hwbench/tests/parsing/numa/8domainsllc") print(f"parsing test {d.name}") test_target = numa.NUMA(path) @@ -253,7 +253,7 @@ def test_parsing_numa_8_domains_with_llc(self): assert len(test_target.get_cores(domain)) == 16 def test_ipmitool_parsing(self): - d = pathlib.Path("./tests/parsing/ipmitool/1818") + d = pathlib.Path("./hwbench/tests/parsing/ipmitool/1818") print(f"parsing test {d.name}") test_target = BMC(path, None) stdout = (d / "stdout").read_bytes() diff --git a/hwbench/environment/vendors/mock.py b/hwbench/environment/vendors/mock.py index b97a316..b41860f 100644 --- a/hwbench/environment/vendors/mock.py +++ b/hwbench/environment/vendors/mock.py @@ -83,7 +83,10 @@ def connect_redfish(self): class MockVendor(Vendor): def __init__( - self, out_dir, dmi, monitoring_config_filename="tests/mocked_monitoring.cfg" + self, + out_dir, + dmi, + monitoring_config_filename="hwbench/tests/mocked_monitoring.cfg", ): super().__init__(out_dir, dmi, monitoring_config_filename) self.bmc = MockedBMC(self.out_dir, self) diff --git a/tox.ini b/tox.ini index 6e96bba..f9e5a4b 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,6 @@ ignore_base_python_conflict=true basepython = {env:PYTHON:python3.9} setenv = LANG = en_US.UTF-8 deps = -r requirements/test.txt -changedir = ./hwbench commands = coverage erase coverage run -m pytest -vvv --junitxml=junit-{envname}.xml --ignore={toxworkdir}