https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127425
Bug ID: 127425
Summary: estsuite: __gnu_test::semaphore exits 0 when SysV
semaphores are unavailable, so 10 tests report PASS
without executing
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: gokbeykeskin at gmail dot com
Target Milestone: ---
libstdc++-v3/testsuite/util/testsuite_hooks.cc defines __gnu_test::semaphore
only when <sys/types.h>, <sys/ipc.h> and <sys/sem.h> are all present:
#if defined(_GLIBCXX_HAVE_SYS_TYPES_H) \
&& defined(_GLIBCXX_HAVE_SYS_IPC_H) \
&& defined(_GLIBCXX_HAVE_SYS_SEM_H)
#define _GLIBCXX_SYSV_SEM
#endif
When that is not satisfied, the constructor does this (testsuite_hooks.cc:267):
#else
// There are no semaphores on this system. We have no way to mark
// a test as "unsupported" at runtime, so we just exit, pretending
// that the test passed.
exit(0);
#endif
So on a target without SysV IPC, every test that constructs a semaphore
terminates with status 0 and DejaGnu records a PASS. The test is compiled,
linked and started, and then exits before executing a single assertion.
A PASS that did not run anything is invisible, and it
is indistinguishable in the .sum file from a test that genuinely passed. A
port can look green on these tests while the functionality they cover is
entirely untested, or broken.
I think POSIX shared/named semaphore support should be added, and it should
report untested if neither semaphore implementation exists. Not PASS.
Ten tests are affected. In each, the semaphore is constructed before any
assertion, so nothing in the test body ever executes:
27_io/basic_filebuf/close/char/4879.cc:46
27_io/basic_filebuf/close/char/9964.cc:42
27_io/basic_filebuf/imbue/char/13171-2.cc:47
27_io/basic_filebuf/imbue/wchar_t/14975-2.cc:50
27_io/basic_filebuf/seekoff/char/26777.cc:47
27_io/basic_filebuf/underflow/char/10097.cc:65
27_io/objects/char/7.cc:48
27_io/objects/char/9661-1.cc:49
27_io/objects/wchar_t/7.cc:49
27_io/objects/wchar_t/9661-1.cc:49