Files
leleka/scripts/test-static-cuda-elf.py
Pavlo Ratushnyi 4013e0c9bd
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
Import tracked Strata Next source snapshot
2026-10-05 18:15:08 +02:00

44 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""Exercise ELF dependency gates with CPU fixtures, without a CUDA toolchain."""
import importlib.util
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest
spec = importlib.util.spec_from_file_location('audit', Path(__file__).with_name('check-static-cuda-elf.py'))
audit = importlib.util.module_from_spec(spec)
spec.loader.exec_module(audit)
@unittest.skipUnless(sys.platform == 'linux' and shutil.which('cc') and shutil.which('readelf'),
'Linux C compiler and readelf required')
class ElfGateTests(unittest.TestCase):
def test_dependency_closure_and_host_path_rejection(self):
with tempfile.TemporaryDirectory(prefix='strata-elf-gate-') as directory:
root = Path(directory)
source = root / 'fixture.c'
source.write_text('#include <stdio.h>\nint main(void) { puts("fixture"); return 0; }\n')
executable = root / 'fixture'
def compile(*extra):
subprocess.run(['cc', str(source), '-o', str(executable), *extra], check=True, capture_output=True)
compile()
self.assertTrue(audit.inspect(executable)['host_glibc_required'])
compile('-Wl,-rpath,/private/build/toolkit')
with self.assertRaisesRegex(RuntimeError, 'build-host'):
audit.inspect(executable)
library_source = root / 'library.c'
library_source.write_text('void fake_cuda_symbol(void) {}\n')
library = root / 'libfixture.so'
subprocess.run(['cc', '-shared', '-fPIC', str(library_source),
'-Wl,-soname,libcudart.so.13', '-o', str(library)], check=True, capture_output=True)
compile('-Wl,--no-as-needed', str(library))
with self.assertRaisesRegex(RuntimeError, 'libcudart.so.13'):
audit.inspect(executable)
if __name__ == '__main__':
unittest.main()