Add test to compile with opencv

This commit is contained in:
Cosmin Ștefan Ciocan
2024-01-26 11:30:32 +00:00
parent b49062e9e2
commit c1fbc06604
3 changed files with 43 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
#include <opencv2/core.hpp>
#include <iostream>
int main(int argc, char** argv)
{
std::cout << cv::getBuildInformation() << std::endl;
return 0;
}
+5
View File
@@ -37,6 +37,11 @@ def compiler_cpp_17_fpath(fixtures_path: str):
return os.path.join(fixtures_path, "compiler", "cpp_17.cu") 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") @pytest.fixture(scope="session")
def sample_magic_cu_line(): def sample_magic_cu_line():
# fmt: off # fmt: off
+30
View File
@@ -120,6 +120,36 @@ def test_compile_args(
assert "errors detected in the compilation of" in output 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( def test_run(
plugin: NVCCPlugin, plugin: NVCCPlugin,
sample_cuda_fpath: str, sample_cuda_fpath: str,