[LTP] [PATCH] OpenPOSIX: Add common entry point function for all tests

Petr Vorel pvorel@suse.cz
Thu Apr 16 20:53:29 CEST 2026


Hi all,

> Add a new shared source file implementing the main() function and rename
> the existing main() functions in test case sources to test_main(). This
> allows adding custom debug code to all test cases at once.

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Martin, thanks!

Li, Jan, hopefully you don't mind. We'd prefer not having to keep rebasing.

> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---
>  testcases/open_posix_testsuite/Makefile       | 13 +++---
>  .../conformance/behavior/WIFEXITED/1-1.c      |  2 +-
>  .../conformance/interfaces/nanosleep/3-2.c    |  2 +-
...
>  testcases/open_posix_testsuite/lib/Makefile   | 18 ++++++++
>  testcases/open_posix_testsuite/lib/common.c   | 13 ++++++
>  .../scripts/generate-makefiles.sh             | 10 ++++-
...
>  1695 files changed, 1974 insertions(+), 1920 deletions(-)
>  create mode 100644 testcases/open_posix_testsuite/lib/Makefile
>  create mode 100644 testcases/open_posix_testsuite/lib/common.c

...
> diff --git a/testcases/open_posix_testsuite/conformance/behavior/WIFEXITED/1-1.c b/testcases/open_posix_testsuite/conformance/behavior/WIFEXITED/1-1.c
> index ae021917c..6f7044b4a 100644
> --- a/testcases/open_posix_testsuite/conformance/behavior/WIFEXITED/1-1.c
> +++ b/testcases/open_posix_testsuite/conformance/behavior/WIFEXITED/1-1.c
> @@ -11,7 +11,7 @@
>  #include <unistd.h>
>  #include "posixtest.h"

> -int main()
> +int test_main(int argc PTS_ATTRIBUTE_UNUSED, char **argv PTS_ATTRIBUTE_UNUSED)
>  {
>  	int s;
...
> new file mode 100644
> index 000000000..ad6a9d7e6
> --- /dev/null
> +++ b/testcases/open_posix_testsuite/lib/Makefile
> @@ -0,0 +1,18 @@
> +top_srcdir?=		..
> +subdir=			lib
> +
> +AR?=			ar
> +RANLIB?=		ranlib
> +CFLAGS+=		-I$(top_srcdir)/include
> +
> +
> +vpath %.c $(top_srcdir)/$(subdir)
> +
> +all: libcommon.a
> +
> +clean:
> +	rm -f libcommon.a *.o
> +
> +libcommon.a: common.o
> +	$(AR) -rc "$@" $^
> +	$(RANLIB) "$@"
> diff --git a/testcases/open_posix_testsuite/lib/common.c b/testcases/open_posix_testsuite/lib/common.c
> new file mode 100644
> index 000000000..71e9afb2b
> --- /dev/null
> +++ b/testcases/open_posix_testsuite/lib/common.c
> @@ -0,0 +1,13 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2026 SUSE LLC <mdoucha@suse.cz>
> + *
> + * OpenPOSIX test bootstrap
> + */
> +
> +int test_main(int argc, char **argv);
> +
> +int main(int argc, char **argv)
> +{
> +	return test_main(argc, argv);
> +}


More information about the ltp mailing list