Warning, file /eic-opticks/optiphy/test/test_optix_version_support.py was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 import subprocess
0002 from pathlib import Path
0003
0004 import pytest
0005
0006
0007 REPOSITORY_ROOT = Path(__file__).resolve().parents[2]
0008 UNSUPPORTED_VERSION_WARNING = "Simphony supports OptiX 8.0.0 and newer"
0009
0010
0011 def configure_with_optix(tmp_path: Path, encoded_version: int) -> subprocess.CompletedProcess[str]:
0012 source_dir = tmp_path / "source"
0013 build_dir = tmp_path / "build"
0014 optix_dir = tmp_path / "optix"
0015 module_dir = tmp_path / "modules"
0016
0017 source_dir.mkdir()
0018 (optix_dir / "include").mkdir(parents=True)
0019 module_dir.mkdir()
0020
0021 (optix_dir / "include" / "optix.h").write_text(
0022 f"#define OPTIX_VERSION {encoded_version}\n"
0023 )
0024 (module_dir / "FindCUDAToolkit.cmake").write_text(
0025 "set(CUDAToolkit_FOUND TRUE)\n"
0026 "set(CUDAToolkit_INCLUDE_DIRS \"\")\n"
0027 )
0028 (source_dir / "CMakeLists.txt").write_text(
0029 "cmake_minimum_required(VERSION 3.22)\n"
0030 "project(optix_version_probe LANGUAGES NONE)\n"
0031 f'list(APPEND CMAKE_MODULE_PATH "{module_dir}" "{REPOSITORY_ROOT / "cmake"}")\n'
0032 "find_package(OptiX REQUIRED)\n"
0033 )
0034
0035 return subprocess.run(
0036 [
0037 "cmake",
0038 "-S",
0039 str(source_dir),
0040 "-B",
0041 str(build_dir),
0042 f"-DOptiX_INSTALL_DIR={optix_dir}",
0043 ],
0044 check=False,
0045 capture_output=True,
0046 text=True,
0047 )
0048
0049
0050 @pytest.mark.parametrize(
0051 ("encoded_version", "expects_warning"),
0052 [(70700, True), (80000, False)],
0053 )
0054 def test_optix_support_floor_is_advisory(tmp_path, encoded_version, expects_warning):
0055 result = configure_with_optix(tmp_path, encoded_version)
0056 output = result.stdout + result.stderr
0057
0058 assert result.returncode == 0, output
0059 assert (UNSUPPORTED_VERSION_WARNING in output) is expects_warning