Given the limited binaries available (sh, ls, sleep), use sh -c true
Signed-off-by: Jeremy Drake <[email protected]>
---
winsup/testsuite/Makefile.am | 1 +
.../testsuite/winsup.api/posix_spawn/spawnp.c | 25 +++++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 winsup/testsuite/winsup.api/posix_spawn/spawnp.c
diff --git a/winsup/testsuite/Makefile.am b/winsup/testsuite/Makefile.am
index 0b265261cd..1cda72905e 100644
--- a/winsup/testsuite/Makefile.am
+++ b/winsup/testsuite/Makefile.am
@@ -312,6 +312,7 @@ check_PROGRAMS = \
winsup.api/pthread/threadidafterfork \
winsup.api/pthread/tsd1 \
winsup.api/posix_spawn/errors \
+ winsup.api/posix_spawn/spawnp \
winsup.api/samples/sample-fail \
winsup.api/samples/sample-pass
# winsup.api/ltp/ulimit01 is omitted as we don't have <ulimit.h>
diff --git a/winsup/testsuite/winsup.api/posix_spawn/spawnp.c
b/winsup/testsuite/winsup.api/posix_spawn/spawnp.c
new file mode 100644
index 0000000000..c7bee878f8
--- /dev/null
+++ b/winsup/testsuite/winsup.api/posix_spawn/spawnp.c
@@ -0,0 +1,25 @@
+#include "test.h"
+#include <spawn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main (void)
+{
+ pid_t pid;
+ int status;
+ /* the test installation has very limited binaries on the PATH, but sh is one
+ of them and 'true' should be a builtin */
+ char *childargv[] = {"sh", "-c", "true", NULL};
+ char *childenv[] = {NULL};
+
+ /* unbuffer stdout */
+ setvbuf(stdout, NULL, _IONBF, 0);
+
+ /* can posix_spawnp find a program even with an empty environment? */
+ errCode (posix_spawnp (&pid, childargv[0], NULL, NULL, childargv, childenv));
+ negError (waitpid (pid, &status, 0));
+ exitStatus (status, 0);
+
+ return 0;
+}
--
2.49.0.windows.1