Implement C interop regression test for dynamic loading and runtime symbol invocation (dlopen/dlsym)
- Type: test
- Status: in-progress
- Track: C (C frontend interop testing)
- Owner: Antigravity
- Opened: 2026-06-28
Motivation
To test dynamic loading of libraries "at will" at runtime and calling resolved functions through function pointers, we need a regression test for the POSIX dynamic linking loader interface (dlfcn.h).
This test will exercise:
- Importing
<dlfcn.h>and linking againstlibdl.so.2automatically. - Loading
libm.so.6,libz.so.1, andlibcrypt.so.1at runtime usingdlopen. - Resolving symbol addresses (
cos,zlibVersion,crypt) usingdlsym. - Defining custom procedural types (e.g.
cdeclfunction signatures) in Pascal. - Casting resolved symbol pointers (
Pointer) to procedural types. - Invoking the runtime-resolved function pointers (passing floats and strings back and forth).
- Releasing the library handles using
dlclose.
Scope
- Test implementation:
- Create
test/test_c_dlopen.pas. - Verify dynamic invocation of
cos(0.0) = 1.0. - Verify dynamic invocation of
zlibVersion(). - Verify dynamic invocation of
crypt(...).
- Create
- Integration:
- Wire the test into the
testtarget of theMakefile.
- Wire the test into the
Acceptance
test/test_c_dlopen.pascompiles successfully.- Executing the binary dynamically loads the target libraries, invokes the functions, asserts correct values, and exits with 0.
Log
- 2026-06-28 — ticket opened and taken.