diff --git a/setup.py b/setup.py index 0b8e3e96..082ca61c 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,14 @@ lib_dirs: list[str] = ['.', '/usr/lib64', '/usr/lib', '/usr/local/lib'] include_dirs: list[str] = [] -userspace_src = os.getenv("USERSPACE_SRC", "") -if userspace_src: +test_toolchain: str | None = os.getenv("TEST_TOOLCHAIN") +userspace_src: str | None = os.getenv("USERSPACE_SRC") +if test_toolchain: + toolchain_path = Path(test_toolchain) + include_dirs.insert(0, str(toolchain_path / "usr/include")) + lib_dirs.insert(0, str(toolchain_path / "lib")) + lib_dirs.insert(1, str(toolchain_path / "usr/lib")) +elif userspace_src: userspace_path = Path(userspace_src) include_dirs.insert(0, str(userspace_path / "libsepol/include")) include_dirs.insert(1, str(userspace_path / "libselinux/include")) diff --git a/tests/conftest.py b/tests/conftest.py index ce123dc9..da0e81c9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -194,13 +194,16 @@ def _do_compile(source_file: str, output_file: str, /, *, mls: bool = True, Return: A SELinuxPolicy object. """ + test_toolchain = os.getenv("TEST_TOOLCHAIN") user_src = os.getenv("USERSPACE_SRC") checkpol = os.getenv("CHECKPOLICY") - if user_src: - command = [user_src + "/checkpolicy/checkpolicy"] - elif checkpol: + if checkpol: command = [checkpol] + elif test_toolchain: + command = [test_toolchain + "/usr/bin/checkpolicy"] + elif user_src: + command = [user_src + "/checkpolicy/checkpolicy"] else: command = ["/usr/bin/checkpolicy"]