Skip to content

Fix api_base_test failures with shared only builds and on modern glibc#41

Open
ssam18 wants to merge 1 commit into
snort3:masterfrom
ssam18:fix/unit-test-static-wrap
Open

Fix api_base_test failures with shared only builds and on modern glibc#41
ssam18 wants to merge 1 commit into
snort3:masterfrom
ssam18:fix/unit-test-static-wrap

Conversation

@ssam18

@ssam18 ssam18 commented Jun 11, 2026

Copy link
Copy Markdown

api_base_test mocks several libc functions through the linker wrap option, which only takes effect for symbols that are resolved at static link time. When the library is configured with --disable-static, libtool quietly falls back to linking the test against libdaq.so, so the mocks never fire and three of the four tests fail as reported in #23. This change adds a check only convenience library built from the api sources and links api_base_test against it, so the suite passes no matter how the installable library is configured. On glibc 2.33 and later the test also fails to link with an undefined reference to __wrap_stat because stat is no longer an extern inline that calls __xstat, which is what #30 reports. The guard around the stat mock now takes the glibc version into account. Verified make check on Ubuntu with glibc 2.39 in both the default and the --disable-static configurations.

The test mocks libc functions with the linker wrap option, which only works when the DAQ library is linked statically into the test binary. Link against a check only convenience library so make check passes when configured with --disable-static. Also pick the stat wrapper based on the glibc version since glibc 2.33 removed the extern inline that redirected stat to __xstat. Fix for the issue snort3#23 and snort3#30.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant