Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/gen/posix_spawn new tests for posix_spawn_chd...



details:   https://anonhg.NetBSD.org/src/rev/4cbcb01f8e68
branches:  trunk
changeset: 1024852:4cbcb01f8e68
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 07 15:46:20 2021 +0000

description:
new tests for posix_spawn_chdir from Piyush Sachdeva

diffstat:

 tests/lib/libc/gen/posix_spawn/Makefile         |    5 +-
 tests/lib/libc/gen/posix_spawn/fa_spawn_utils.c |   62 ++
 tests/lib/libc/gen/posix_spawn/fa_spawn_utils.h |   31 +
 tests/lib/libc/gen/posix_spawn/h_fileactions.c  |    4 +-
 tests/lib/libc/gen/posix_spawn/h_spawn.c        |    4 +-
 tests/lib/libc/gen/posix_spawn/h_spawnattr.c    |    4 +-
 tests/lib/libc/gen/posix_spawn/t_fileactions.c  |   27 +-
 tests/lib/libc/gen/posix_spawn/t_spawn.c        |  520 +++++++++++++++++++++++-
 tests/lib/libc/gen/posix_spawn/t_spawnattr.c    |    8 +-
 9 files changed, 630 insertions(+), 35 deletions(-)

diffs (truncated from 835 to 300 lines):

diff -r 98d3c6bb1d31 -r 4cbcb01f8e68 tests/lib/libc/gen/posix_spawn/Makefile
--- a/tests/lib/libc/gen/posix_spawn/Makefile   Sun Nov 07 15:44:28 2021 +0000
+++ b/tests/lib/libc/gen/posix_spawn/Makefile   Sun Nov 07 15:46:20 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2012/02/14 00:13:54 martin Exp $
+# $NetBSD: Makefile,v 1.3 2021/11/07 15:46:20 christos Exp $
 
 NOMAN=         # defined
 WARNS=4
@@ -11,6 +11,9 @@
 TESTS_C+=      t_fileactions
 TESTS_C+=      t_spawnattr
 
+SRCS.t_spawn += t_spawn fa_spawn_utils
+SRCS.t_fileactions += t_fileactions fa_spawn_utils
+
 BINDIR=                ${TESTSDIR}
 SCRIPTSDIR=    ${TESTSDIR}
 
diff -r 98d3c6bb1d31 -r 4cbcb01f8e68 tests/lib/libc/gen/posix_spawn/fa_spawn_utils.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/gen/posix_spawn/fa_spawn_utils.c   Sun Nov 07 15:46:20 2021 +0000
@@ -0,0 +1,62 @@
+/*     $NetBSD: fa_spawn_utils.c,v 1.1 2021/11/07 15:46:20 christos Exp $      */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles Zhang <charles%NetBSD.org@localhost> and
+ * Martin Husemann <martin%NetBSD.org@localhost>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: fa_spawn_utils.c,v 1.1 2021/11/07 15:46:20 christos Exp $");
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include "fa_spawn_utils.h"
+
+off_t
+filesize(const char * restrict fname)
+{
+       struct stat st;
+       int err;
+
+       err = stat(fname, &st);
+       ATF_REQUIRE_MSG(err == 0, "Can't stat %s (%s)", fname, strerror(errno));
+       return st.st_size;
+}
+
+void
+empty_outfile(const char * restrict fname)
+{
+       FILE *f;
+
+       f = fopen(fname, "w");
+       ATF_REQUIRE_MSG(f != NULL, "Can't open %s (%s)", fname, strerror(errno));
+       fclose(f);
+}
diff -r 98d3c6bb1d31 -r 4cbcb01f8e68 tests/lib/libc/gen/posix_spawn/fa_spawn_utils.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/gen/posix_spawn/fa_spawn_utils.h   Sun Nov 07 15:46:20 2021 +0000
@@ -0,0 +1,31 @@
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles Zhang <charles%NetBSD.org@localhost> and
+ * Martin Husemann <martin%NetBSD.org@localhost>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+off_t filesize(const char * restrict);
+void empty_outfile(const char * restrict);
diff -r 98d3c6bb1d31 -r 4cbcb01f8e68 tests/lib/libc/gen/posix_spawn/h_fileactions.c
--- a/tests/lib/libc/gen/posix_spawn/h_fileactions.c    Sun Nov 07 15:44:28 2021 +0000
+++ b/tests/lib/libc/gen/posix_spawn/h_fileactions.c    Sun Nov 07 15:46:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_fileactions.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
+/* $NetBSD: h_fileactions.c,v 1.2 2021/11/07 15:46:20 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,6 +29,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: h_fileactions.c,v 1.2 2021/11/07 15:46:20 christos Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
diff -r 98d3c6bb1d31 -r 4cbcb01f8e68 tests/lib/libc/gen/posix_spawn/h_spawn.c
--- a/tests/lib/libc/gen/posix_spawn/h_spawn.c  Sun Nov 07 15:44:28 2021 +0000
+++ b/tests/lib/libc/gen/posix_spawn/h_spawn.c  Sun Nov 07 15:46:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_spawn.c,v 1.2 2021/05/02 11:18:11 martin Exp $ */
+/* $NetBSD: h_spawn.c,v 1.3 2021/11/07 15:46:20 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,6 +29,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: h_spawn.c,v 1.3 2021/11/07 15:46:20 christos Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
diff -r 98d3c6bb1d31 -r 4cbcb01f8e68 tests/lib/libc/gen/posix_spawn/h_spawnattr.c
--- a/tests/lib/libc/gen/posix_spawn/h_spawnattr.c      Sun Nov 07 15:44:28 2021 +0000
+++ b/tests/lib/libc/gen/posix_spawn/h_spawnattr.c      Sun Nov 07 15:46:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_spawnattr.c,v 1.2 2021/08/21 23:00:32 andvar Exp $ */
+/* $NetBSD: h_spawnattr.c,v 1.3 2021/11/07 15:46:20 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,6 +29,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: h_spawnattr.c,v 1.3 2021/11/07 15:46:20 christos Exp $");
 
 #include <errno.h>
 #include <stdio.h>
diff -r 98d3c6bb1d31 -r 4cbcb01f8e68 tests/lib/libc/gen/posix_spawn/t_fileactions.c
--- a/tests/lib/libc/gen/posix_spawn/t_fileactions.c    Sun Nov 07 15:44:28 2021 +0000
+++ b/tests/lib/libc/gen/posix_spawn/t_fileactions.c    Sun Nov 07 15:46:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fileactions.c,v 1.6 2017/01/10 22:36:29 christos Exp $ */
+/* $NetBSD: t_fileactions.c,v 1.7 2021/11/07 15:46:20 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,6 +29,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_fileactions.c,v 1.7 2021/11/07 15:46:20 christos Exp $");
 
 
 #include <atf-c.h>
@@ -44,6 +46,8 @@
 #include <spawn.h>
 #include <unistd.h>
 
+#include "fa_spawn_utils.h"
+
 
 ATF_TC(t_spawn_openmode);
 
@@ -54,17 +58,6 @@
        atf_tc_set_md_var(tc, "require.progs", "/bin/cat");
 }
 
-static off_t
-filesize(const char * restrict fname)
-{
-       struct stat st;
-       int err;
-
-       err = stat(fname, &st);
-       ATF_REQUIRE(err == 0);
-       return st.st_size;
-}
-
 #define TESTFILE       "./the_input_data"
 #define CHECKFILE      "./the_output_data"
 #define TESTCONTENT    "marry has a little lamb"
@@ -82,16 +75,6 @@
        ATF_REQUIRE(written == strlen(TESTCONTENT));
 }
 
-static void
-empty_outfile(const char *restrict filename)
-{
-       FILE *f;
-
-       f = fopen(filename, "w");
-       ATF_REQUIRE(f != NULL);
-       fclose(f);
-}
-
 ATF_TC_BODY(t_spawn_openmode, tc)
 {
        int status, err;
diff -r 98d3c6bb1d31 -r 4cbcb01f8e68 tests/lib/libc/gen/posix_spawn/t_spawn.c
--- a/tests/lib/libc/gen/posix_spawn/t_spawn.c  Sun Nov 07 15:44:28 2021 +0000
+++ b/tests/lib/libc/gen/posix_spawn/t_spawn.c  Sun Nov 07 15:46:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_spawn.c,v 1.3 2021/09/03 22:33:18 andvar Exp $ */
+/* $NetBSD: t_spawn.c,v 1.4 2021/11/07 15:46:20 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,15 +29,29 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_spawn.c,v 1.4 2021/11/07 15:46:20 christos Exp $");
 
 #include <atf-c.h>
+
+#include <sys/fcntl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+
 #include <spawn.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
-#include <sys/wait.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "fa_spawn_utils.h"
+
+
+static void check_success(const char *, int, ...);
 
 ATF_TC(t_spawn_ls);
 
@@ -97,7 +111,7 @@
 ATF_TC_HEAD(t_spawn_missing, tc)
 {
        atf_tc_set_md_var(tc, "descr",
-           "posix_spawn a non-existent binary");
+           "posix_spawn a non existant binary");
 }
 
 ATF_TC_BODY(t_spawn_missing, tc)
@@ -117,7 +131,7 @@
 ATF_TC_HEAD(t_spawn_nonexec, tc)
 {
        atf_tc_set_md_var(tc, "descr",
-           "posix_spawn a script with non-existent interpreter");
+           "posix_spawn a script with non existing interpreter");
 }
 
 ATF_TC_BODY(t_spawn_nonexec, tc)
@@ -171,6 +185,493 @@
        ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 7);
 }
 
+#define CHDIRPATH "/tmp"



Home | Main Index | Thread Index | Old Index