diff --git a/tests/conditional_compilation/conftest.py b/tests/conditional_compilation/conftest.py index 5ca94774a5b2e3..e74f46ba3b9661 100644 --- a/tests/conditional_compilation/conftest.py +++ b/tests/conditional_compilation/conftest.py @@ -5,16 +5,7 @@ # pylint: disable=line-too-long -""" Pytest configuration for compilation tests. - -Sample usage: -python3 -m pytest test_cc.py \ - --sea_runtool=./thirdparty/itt_collector/runtool/sea_runtool.py \ - --collector_dir=./bin/intel64/Release \ - --artifacts= \ - --openvino_ref= \ - --openvino_root_dir= -""" +"""Pytest configuration for compilation tests.""" import logging import sys @@ -28,7 +19,6 @@ import pytest from path_utils import expand_env_vars # pylint: disable=import-error -from proc_utils import cmd_exec # pylint: disable=import-error from test_utils import make_build, write_session_info, SESSION_INFO_FILE # pylint: disable=import-error @@ -117,7 +107,7 @@ def openvino_ref(request, openvino_root_dir, artifacts): """Fixture function for command-line option. Return path to root directory with installed OpenVINO. If --openvino_ref command-line option is not specified firstly build and install - instrumented binaries with OpenVINO repository specified in --openvino_root_dir option. + instrumented package with OpenVINO repository specified in --openvino_root_dir option. """ openvino_ref_path = request.config.getoption("openvino_ref") if openvino_ref_path: diff --git a/tests/conditional_compilation/test_cc.py b/tests/conditional_compilation/test_cc.py index 7d2cfe7f972186..e8c2731ff05cfc 100644 --- a/tests/conditional_compilation/test_cc.py +++ b/tests/conditional_compilation/test_cc.py @@ -61,8 +61,8 @@ def test_cc_collect(test_id, model, openvino_ref, test_info, @pytest.mark.dependency(depends=["cc_collect"]) -def test_minimized_build(test_id, model, openvino_root_dir, artifacts): # pylint: disable=unused-argument - """Install OpenVINO with collected conditional compilation statistics.""" +def test_minimized_pkg(test_id, model, openvino_root_dir, artifacts): # pylint: disable=unused-argument + """Build and install OpenVINO package with collected conditional compilation statistics.""" install_prefix = artifacts / test_id / "install_pkg" build_dir = openvino_root_dir / "build_minimized" @@ -78,25 +78,25 @@ def test_minimized_build(test_id, model, openvino_root_dir, artifacts): # pylin assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" -@pytest.mark.dependency(depends=["cc_collect", "minimized_build"]) +@pytest.mark.dependency(depends=["cc_collect", "minimized_pkg"]) def test_infer(test_id, model, artifacts): """Test inference with conditional compiled binaries.""" out = artifacts / test_id - minimized_build = out / "install_pkg" - return_code, output = run_infer(model, f"{out}_cc.npz", minimized_build) + minimized_pkg = out / "install_pkg" + return_code, output = run_infer(model, f"{out}_cc.npz", minimized_pkg) assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" -@pytest.mark.dependency(depends=["cc_collect", "minimized_build"]) +@pytest.mark.dependency(depends=["cc_collect", "minimized_pkg"]) def test_verify(test_id, model, openvino_ref, artifacts, tolerance=1e-6): # pylint: disable=too-many-arguments """Test verifying that inference results are equal.""" out = artifacts / test_id - minimized_build = out / "install_pkg" + minimized_pkg = out / "install_pkg" out_file = f"{out}.npz" out_file_cc = f"{out}_cc.npz" return_code, output = run_infer(model, out_file, openvino_ref) assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" - return_code, output = run_infer(model, out_file_cc, minimized_build) + return_code, output = run_infer(model, out_file_cc, minimized_pkg) assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" reference_results = dict(np.load(out_file)) inference_results = dict(np.load(out_file_cc)) @@ -109,13 +109,13 @@ def test_verify(test_id, model, openvino_ref, artifacts, tolerance=1e-6): # pyl ), "Reference and inference results differ" -@pytest.mark.dependency(depends=["cc_collect", "minimized_build"]) +@pytest.mark.dependency(depends=["cc_collect", "minimized_pkg"]) def test_libs_size(test_id, model, openvino_ref, artifacts): # pylint: disable=unused-argument """Test if libraries haven't increased in size after conditional compilation.""" libraries = ["inference_engine_transformations", "MKLDNNPlugin", "ngraph"] - minimized_build = artifacts / test_id / "install_pkg" + minimized_pkg = artifacts / test_id / "install_pkg" ref_libs_size = get_lib_sizes(openvino_ref, libraries) - lib_sizes = get_lib_sizes(minimized_build, libraries) + lib_sizes = get_lib_sizes(minimized_pkg, libraries) for lib in libraries: lib_size_diff = ref_libs_size[lib] - lib_sizes[lib] diff --git a/tests/conditional_compilation/test_utils.py b/tests/conditional_compilation/test_utils.py index 6c3ffdf5a27f05..fa9cc2d2d381d4 100644 --- a/tests/conditional_compilation/test_utils.py +++ b/tests/conditional_compilation/test_utils.py @@ -6,6 +6,8 @@ """ import os import json +import multiprocessing +import shutil import sys from inspect import getsourcefile from pathlib import Path @@ -63,18 +65,15 @@ def run_infer(model, out_file, install_dir): def make_build(openvino_root_dir, build_dir, install_dir, cmake_additional_args=None, log=None): - """Build and install OpenVINO with parameters.""" - if sys.platform == "win32": - python_executable="" - params = " ".join(cmake_additional_args) + " " if cmake_additional_args else "" + """Parametrized build and install OpenVINO package.""" + python_executable = shutil.which("python3") + additional_args_line = " ".join(cmake_additional_args) + " " if cmake_additional_args else "" + nproc = multiprocessing.cpu_count() cmd = ( - f"mkdir -p {build_dir} && " f"cmake -DENABLE_PROFILING_ITT=ON -DCMAKE_BUILD_TYPE=Release " - f"-DPYTHON_EXECUTABLE=`which python3` {params}" + f"-DPYTHON_EXECUTABLE={python_executable} {additional_args_line}" f"-S {openvino_root_dir} -B {build_dir} &&" - f"make -C {build_dir} --jobs=$(nproc --all) && " - f"mkdir -p {install_dir} && " + f"cmake --build {build_dir} -j{nproc} && " f"cmake --install {build_dir} --prefix {install_dir}" ) return cmd_exec([cmd], shell=True, log=log) -