Skip to content

tests: add the includes the C testers rely on implicitly - #4831

Draft
ThalesBarretto wants to merge 1 commit into
gluster:develfrom
ThalesBarretto:fix/tests-c-testers-missing-includes
Draft

ThalesBarretto wants to merge 1 commit into
gluster:develfrom
ThalesBarretto:fix/tests-c-testers-missing-includes

Conversation

@ThalesBarretto

Copy link
Copy Markdown
Contributor

tests: add the includes the C testers rely on implicitly

Eight test programs built by build_tester call libc functions they never declare (close, read, write,
lseek, fork, getppid, sleep without <unistd.h>; system without <stdlib.h>; inet_pton and
inet_net_pton without <arpa/inet.h>; major/minor/makedev without <sys/sysmacros.h>). GCC 14 made
an implicit declaration a hard error, so on a current toolchain build_tester fails and eight tests never
run. Details in #4830.

The change (8 files, +14/-12, tests/ only)

Add the missing includes. The two bug-808400 testers also called the LFS64 name fstat64() on a plain
struct stat, which compiled only because the call was undeclared; they now call fstat(), and the
non-Linux macro that mapped one onto the other is gone.

Test

Before: 8 of the 99 .c files under tests/ fail gcc -fsyntax-only -Werror=implicit-function-declaration
(the GCC 14 default); after: 0. On GCC 14.2 the affected .t files fail at build_tester before and build
after. No behaviour change in any tester.

Fixes: #4830

Eight test programs built by build_tester call functions they never
declare: close(), read(), write(), lseek(), fork(), getppid() and
sleep() without <unistd.h>, system() without <stdlib.h>, inet_pton()
and inet_net_pton() without <arpa/inet.h>, and major()/minor()/makedev()
without <sys/sysmacros.h>. GCC 14 made an implicit function declaration
a hard error (it was a warning before), so on any toolchain from 2024 on
build_tester fails and the tests that depend on it fail before running:
tests/bugs/cidr-bug-4108.t, bugs/distribute/bug-1193636.t,
bugs/fuse/bug-1126048.t, bugs/protocol/bug-808400{,-dist,-repl}.t,
bugs/write-behind/bug-1058663.t and bug-1279730.t.

Add the missing includes. The two bug-808400 testers also called the
LFS64 name fstat64() on a plain struct stat, which only compiled because
the call was undeclared; call fstat() and drop the non-Linux macro that
already mapped one onto the other. logchecks.c is not built by any test
but gets its include too.

Fixes: gluster#4830
Signed-off-by: Thales Antunes de Oliveira Barretto <thales.barretto.git@gmail.com>
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.

tests: eight C testers call functions they never declare; with GCC 14 build_tester fails and eight regression tests never run

1 participant