https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0139b7ae692e39475c72c89113290bb1b4b06131

commit 0139b7ae692e39475c72c89113290bb1b4b06131
Author: Jeremy Drake <cyg...@jdrake.com>
Date:   Wed Jun 18 12:20:49 2025 -0700

    Cygwin: testsuite: test posix_spawnp
    
    Given the limited binaries available (sh, ls, sleep), use sh -c true
    
    Signed-off-by: Jeremy Drake <cyg...@jdrake.com>

Diff:
---
 winsup/testsuite/Makefile.am                     |  1 +
 winsup/testsuite/winsup.api/posix_spawn/spawnp.c | 25 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/winsup/testsuite/Makefile.am b/winsup/testsuite/Makefile.am
index 0b265261c..1cda72905 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 000000000..c7bee878f
--- /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;
+}

Reply via email to