From c1fbc0660454330b1d7663bb1f57e43b5de2eb67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosmin=20=C8=98tefan=20Ciocan?= <57830279+cosminc98@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:30:32 +0000 Subject: [PATCH] Add test to compile with opencv --- tests/fixtures/compiler/opencv.cu | 8 ++++++++ tests/fixtures/fixtures.py | 5 +++++ tests/test_plugin.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/fixtures/compiler/opencv.cu diff --git a/tests/fixtures/compiler/opencv.cu b/tests/fixtures/compiler/opencv.cu new file mode 100644 index 0000000..75380ee --- /dev/null +++ b/tests/fixtures/compiler/opencv.cu @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char** argv) +{ + std::cout << cv::getBuildInformation() << std::endl; + return 0; +} diff --git a/tests/fixtures/fixtures.py b/tests/fixtures/fixtures.py index 6e50541..ca8248d 100644 --- a/tests/fixtures/fixtures.py +++ b/tests/fixtures/fixtures.py @@ -37,6 +37,11 @@ def compiler_cpp_17_fpath(fixtures_path: str): return os.path.join(fixtures_path, "compiler", "cpp_17.cu") +@pytest.fixture(scope="session") +def compiler_opencv_fpath(fixtures_path: str): + return os.path.join(fixtures_path, "compiler", "opencv.cu") + + @pytest.fixture(scope="session") def sample_magic_cu_line(): # fmt: off diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 7448adc..e290f91 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -120,6 +120,36 @@ def test_compile_args( assert "errors detected in the compilation of" in output +def test_compile_opencv( + plugin: NVCCPlugin, + compiler_opencv_fpath: str, +): + gname = "test_compile_opencv" + copy_source_to_group(compiler_opencv_fpath, gname, plugin.workdir) + + # check that "pkg-config" exists + assert subprocess.check_call(["which", "pkg-config"]) == 0 + + opencv_compile_options = ( + subprocess.check_output( + args=["pkg-config", "--cflags", "--libs", "opencv4"] + ) + .decode() + .strip() + ) + + output = plugin._compile_and_run( + group_name=gname, + args=argparse.Namespace( + timeit=False, + profile=True, + profiler_args="", + compiler_args=opencv_compile_options, + ), + ) + assert "General configuration for OpenCV" in output + + def test_run( plugin: NVCCPlugin, sample_cuda_fpath: str,