aboutsummaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to 'support')
-rw-r--r--support/Depend1
-rw-r--r--support/Makefile6
-rw-r--r--support/support_test_main.c12
-rw-r--r--support/test-driver.c4
-rw-r--r--support/test-driver.h1
-rw-r--r--support/test-run-command.c22
6 files changed, 45 insertions, 1 deletions
diff --git a/support/Depend b/support/Depend
new file mode 100644
index 0000000..7e7d5dc
--- /dev/null
+++ b/support/Depend
@@ -0,0 +1 @@
+elf
diff --git a/support/Makefile b/support/Makefile
index 7f03950..984ec02 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -257,10 +257,16 @@ others-noinstall += shell-container echo-container true-container
others += $(LINKS_DSO_PROGRAM)
others-noinstall += $(LINKS_DSO_PROGRAM)
+others += test-run-command
+others-static += test-run-command
+others-noinstall += test-run-command
+LDLIBS-test-run-command = $(libsupport)
+
$(objpfx)test-container : $(libsupport)
$(objpfx)shell-container : $(libsupport)
$(objpfx)echo-container : $(libsupport)
$(objpfx)true-container : $(libsupport)
+$(objpfx)test-run-command : $(libsupport) $(common-objpfx)elf/static-stubs.o
tests = \
README-testing \
diff --git a/support/support_test_main.c b/support/support_test_main.c
index 07e3cdd..66a754b 100644
--- a/support/support_test_main.c
+++ b/support/support_test_main.c
@@ -228,6 +228,18 @@ run_test_function (int argc, char **argv, const struct test_config *config)
while (wait_for_debugger)
usleep (1000);
+ if (config->run_command_mode)
+ {
+ /* In run-command-mode, the child process executes the command line
+ arguments as a new program. */
+ char **argv_ = xmalloc (sizeof (char *) * argc);
+ memcpy (argv_, &argv[1], sizeof (char *) * (argc - 1));
+ argv_[argc - 1] = NULL;
+ execv (argv_[0], argv_);
+ printf ("error: should not return here\n");
+ exit (1);
+ }
+
if (config->test_function != NULL)
return config->test_function ();
else if (config->test_function_argv != NULL)
diff --git a/support/test-driver.c b/support/test-driver.c
index b0bea46..1552f62 100644
--- a/support/test-driver.c
+++ b/support/test-driver.c
@@ -116,7 +116,9 @@ main (int argc, char **argv)
#if defined (TEST_FUNCTION) && defined (TEST_FUNCTON_ARGV)
# error TEST_FUNCTION and TEST_FUNCTION_ARGV cannot be defined at the same time
#endif
-#if defined (TEST_FUNCTION)
+#ifdef RUN_COMMAND_MODE
+ test_config.run_command_mode = 1;
+#elif defined (TEST_FUNCTION)
test_config.test_function = TEST_FUNCTION;
#elif defined (TEST_FUNCTION_ARGV)
test_config.test_function_argv = TEST_FUNCTION_ARGV;
diff --git a/support/test-driver.h b/support/test-driver.h
index 8d4f382..b44c0ff 100644
--- a/support/test-driver.h
+++ b/support/test-driver.h
@@ -36,6 +36,7 @@ struct test_config
int expected_signal; /* If non-zero, expect termination by signal. */
char no_mallopt; /* Boolean flag to disable mallopt. */
char no_setvbuf; /* Boolean flag to disable setvbuf. */
+ char run_command_mode; /* Boolean flag to indicate run-command-mode. */
const char *optstring; /* Short command line options. */
};
diff --git a/support/test-run-command.c b/support/test-run-command.c
new file mode 100644
index 0000000..61560d7
--- /dev/null
+++ b/support/test-run-command.c
@@ -0,0 +1,22 @@
+/* Main program for test-run-command support utility.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* This is basically a configuration of test-driver.c into a general
+ command-line program runner. */
+#define RUN_COMMAND_MODE
+#include <test-driver.c>