diff options
Diffstat (limited to 'tools/regression')
-rw-r--r-- | tools/regression/bin/sh/builtins/case10.0 | 16 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/case9.0 | 39 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/export1.0 | 3 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/set2.0 | 3 | ||||
-rw-r--r-- | tools/regression/bin/sh/execution/bg4.0 | 6 | ||||
-rw-r--r-- | tools/regression/bin/sh/expansion/cmdsubst11.0 | 5 | ||||
-rw-r--r-- | tools/regression/bin/sh/parser/alias6.0 | 6 | ||||
-rw-r--r-- | tools/regression/kqueue/config.h | 6 | ||||
-rw-r--r-- | tools/regression/kqueue/main.c | 3 | ||||
-rw-r--r-- | tools/regression/kqueue/proc.c | 16 | ||||
-rw-r--r-- | tools/regression/lib/libc/gen/Makefile | 2 | ||||
-rw-r--r-- | tools/regression/lib/libc/gen/test-posix_spawn.c | 90 |
12 files changed, 189 insertions, 6 deletions
diff --git a/tools/regression/bin/sh/builtins/case10.0 b/tools/regression/bin/sh/builtins/case10.0 new file mode 100644 index 0000000..a627b5c --- /dev/null +++ b/tools/regression/bin/sh/builtins/case10.0 @@ -0,0 +1,16 @@ +# $FreeBSD$ + +case ! in +[\!!]) ;; +*) echo Failed at $LINENO ;; +esac + +case ! in +['!'!]) ;; +*) echo Failed at $LINENO ;; +esac + +case ! in +["!"!]) ;; +*) echo Failed at $LINENO ;; +esac diff --git a/tools/regression/bin/sh/builtins/case9.0 b/tools/regression/bin/sh/builtins/case9.0 new file mode 100644 index 0000000..476caec --- /dev/null +++ b/tools/regression/bin/sh/builtins/case9.0 @@ -0,0 +1,39 @@ +# $FreeBSD$ + +errors=0 + +f() { + result= + case $1 in + a) result=${result}a ;; + b) result=${result}b ;& + c) result=${result}c ;& + d) result=${result}d ;; + e) result=${result}e ;& + esac +} + +check() { + f "$1" + if [ "$result" != "$2" ]; then + printf "For %s, expected %s got %s\n" "$1" "$2" "$result" + errors=$((errors + 1)) + fi +} + +check '' '' +check a a +check b bcd +check c cd +check d d +check e e + +if ! (case 1 in + 1) false ;& + 2) true ;; +esac) then + echo "Subshell bad" + errors=$((errors + 1)) +fi + +exit $((errors != 0)) diff --git a/tools/regression/bin/sh/builtins/export1.0 b/tools/regression/bin/sh/builtins/export1.0 new file mode 100644 index 0000000..7b08c9d --- /dev/null +++ b/tools/regression/bin/sh/builtins/export1.0 @@ -0,0 +1,3 @@ +# $FreeBSD$ + +env @badness=1 ${SH} -c 'v=`export -p`; eval "$v"' diff --git a/tools/regression/bin/sh/builtins/set2.0 b/tools/regression/bin/sh/builtins/set2.0 new file mode 100644 index 0000000..ad13eab --- /dev/null +++ b/tools/regression/bin/sh/builtins/set2.0 @@ -0,0 +1,3 @@ +# $FreeBSD$ + +! env @badness=1 ${SH} -c 'v=`set`; eval "$v"' 2>&1 | grep @badness diff --git a/tools/regression/bin/sh/execution/bg4.0 b/tools/regression/bin/sh/execution/bg4.0 new file mode 100644 index 0000000..25e4f4e --- /dev/null +++ b/tools/regression/bin/sh/execution/bg4.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +x='' +: ${x:=1} & +wait +exit ${x:-0} diff --git a/tools/regression/bin/sh/expansion/cmdsubst11.0 b/tools/regression/bin/sh/expansion/cmdsubst11.0 new file mode 100644 index 0000000..f1af547 --- /dev/null +++ b/tools/regression/bin/sh/expansion/cmdsubst11.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +# Not required by POSIX but useful for efficiency. + +[ $$ = $(eval '${SH} -c echo\ \$PPID') ] diff --git a/tools/regression/bin/sh/parser/alias6.0 b/tools/regression/bin/sh/parser/alias6.0 new file mode 100644 index 0000000..c723d08 --- /dev/null +++ b/tools/regression/bin/sh/parser/alias6.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +alias alias0='| cat >/dev/null' + +eval '{ echo bad; } alias0' +eval '(echo bad)alias0' diff --git a/tools/regression/kqueue/config.h b/tools/regression/kqueue/config.h index 2a377db..a204092 100644 --- a/tools/regression/kqueue/config.h +++ b/tools/regression/kqueue/config.h @@ -1,7 +1,7 @@ -/* AUTOMATICALLY GENERATED -- DO NOT EDIT */ /* $FreeBSD$ */ -#define HAVE_ERR_H -#define HAVE_SYS_EVENT_H + +#define HAVE_ERR_H 1 +#define HAVE_SYS_EVENT_H 1 #define HAVE_EV_DISPATCH 1 #define HAVE_EV_RECEIPT 1 #undef HAVE_NOTE_TRUNCATE diff --git a/tools/regression/kqueue/main.c b/tools/regression/kqueue/main.c index 182003c..f76c4e2 100644 --- a/tools/regression/kqueue/main.c +++ b/tools/regression/kqueue/main.c @@ -18,6 +18,7 @@ #include <sys/types.h> +#include "config.h" #include "common.h" int testnum = 1; @@ -230,7 +231,7 @@ test_kqueue_close(void) int main(int argc, char **argv) { - int test_proc = 0; /* XXX-FIXME */ + int test_proc = 1; int test_socket = 1; int test_signal = 1; int test_vnode = 1; diff --git a/tools/regression/kqueue/proc.c b/tools/regression/kqueue/proc.c index d4e863e..6288ee6 100644 --- a/tools/regression/kqueue/proc.c +++ b/tools/regression/kqueue/proc.c @@ -16,6 +16,11 @@ * $FreeBSD$ */ +#include <sys/stat.h> + +#include <err.h> + +#include "config.h" #include "common.h" static int sigusr1_caught = 0; @@ -37,6 +42,11 @@ add_and_delete(void) /* Create a child that waits to be killed and then exits */ pid = fork(); if (pid == 0) { + struct stat s; + if (fstat(kqfd, &s) != -1) + errx(1, "kqueue inherited across fork! (%s() at %s:%d)", + __func__, __FILE__, __LINE__); + pause(); exit(2); } @@ -52,6 +62,7 @@ add_and_delete(void) test_begin("kevent(EVFILT_PROC, EV_DELETE)"); + sleep(1); test_no_kevents(); kevent_add(kqfd, &kev, pid, EVFILT_PROC, EV_DELETE, 0, 0, NULL); if (kill(pid, SIGKILL) < 0) @@ -63,6 +74,7 @@ add_and_delete(void) } +#ifdef TODO static void event_trigger(void) { @@ -93,7 +105,6 @@ event_trigger(void) success(); } -#ifdef TODO void test_kevent_signal_disable(void) { @@ -225,7 +236,10 @@ test_evfilt_proc() signal(SIGUSR1, sig_handler); add_and_delete(); + +#if TODO event_trigger(); +#endif signal(SIGUSR1, SIG_DFL); diff --git a/tools/regression/lib/libc/gen/Makefile b/tools/regression/lib/libc/gen/Makefile index a79dc2f..72a0750 100644 --- a/tools/regression/lib/libc/gen/Makefile +++ b/tools/regression/lib/libc/gen/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= test-fmtcheck test-fnmatch test-fpclassify test-wordexp +TESTS= test-fmtcheck test-fnmatch test-fpclassify test-posix_spawn test-wordexp .PHONY: tests tests: ${TESTS} diff --git a/tools/regression/lib/libc/gen/test-posix_spawn.c b/tools/regression/lib/libc/gen/test-posix_spawn.c new file mode 100644 index 0000000..f1b8d43 --- /dev/null +++ b/tools/regression/lib/libc/gen/test-posix_spawn.c @@ -0,0 +1,90 @@ +/*- + * Copyright (c) 2011 Jilles Tjoelker + * All rights reserved. + * + * 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 AUTHOR 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 AUTHOR 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. + */ + +/* + * Test program for posix_spawn() and posix_spawnp() as specified by + * IEEE Std. 1003.1-2008. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/wait.h> + +#include <assert.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <spawn.h> + +int +main(int argc, char *argv[]) +{ + int error, status; + pid_t pid, waitres; + char *myargs[4]; + char *myenv[2] = { "answer=42", NULL }; + + /* Make sure we have no child processes. */ + while (waitpid(-1, NULL, 0) != -1) + ; + assert(errno == ECHILD); + + /* Simple test. */ + myargs[0] = "sh"; + myargs[1] = "-c"; + myargs[2] = "exit $answer"; + myargs[3] = NULL; + error = posix_spawnp(&pid, myargs[0], NULL, NULL, myargs, myenv); + assert(error == 0); + waitres = waitpid(pid, &status, 0); + assert(waitres == pid); + assert(WIFEXITED(status) && WEXITSTATUS(status) == 42); + + /* + * If the executable does not exist, the function shall either fail + * and not create a child process or succeed and create a child + * process that exits with status 127. + */ + myargs[0] = "/var/empty/nonexistent"; + myargs[1] = NULL; + error = posix_spawn(&pid, myargs[0], NULL, NULL, myargs, myenv); + if (error == 0) { + waitres = waitpid(pid, &status, 0); + assert(waitres == pid); + assert(WIFEXITED(status) && WEXITSTATUS(status) == 127); + } else { + assert(error == ENOENT); + waitres = waitpid(-1, NULL, 0); + assert(waitres == -1 && errno == ECHILD); + } + + printf("PASS posix_spawn()\n"); + printf("PASS posix_spawnp()\n"); + + return (0); +} |