diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 35e1c062b1e9..1ec53d5d0028 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -1,568 +1,570 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin cat .. chown .. date .. expr .. mv .. pax .. pkill .. sh builtins .. errors .. execution .. expansion .. parameters .. parser .. set-e .. .. sleep .. test .. .. cddl lib .. sbin .. usr.bin .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. lexer .. llquantize .. mdb .. mib .. misc .. multiaggs .. offsetof .. operators .. pid .. plockstat .. pointers .. pragma .. predicates .. preprocessor .. print .. printa .. printf .. privs .. probes .. proc .. profile-n .. providers .. raise .. rates .. safety .. scalars .. sched .. scripting .. sdt .. sizeof .. speculation .. stability .. stack .. stackdepth .. stop .. strlen .. strtoll .. struct .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. .. .. .. etc rc.d .. .. games .. gnu lib .. usr.bin diff .. .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. inet .. locale .. net getaddrinfo data .. .. .. regex data .. .. ssp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcrypt .. libmp .. libnv .. libpam .. libproc .. librt .. libthr dlopen .. .. libutil .. msun .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. .. sbin dhclient .. devd .. growfs .. ifconfig .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. .. .. .. sys kern + execve + .. .. netinet .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. .. .. usr.bin apply .. basename .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. calendar .. cmp .. comm .. cut .. dirname .. file2c .. grep .. gzip .. join .. jot .. lastcomm .. m4 .. mkimg .. ncal .. opensm .. printf .. sed regress.multitest.out .. .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. xargs .. yacc yacc .. .. .. usr.sbin etcupdate .. newsyslog .. nmtree .. pw .. sa .. .. .. # vim: set expandtab ts=4 sw=4: diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index 4a1e67147953..d366aa1d61ff 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -1,13 +1,15 @@ # $FreeBSD$ TESTSDIR= ${TESTSBASE}/sys/kern ATF_TESTS_C+= kern_descrip_test ATF_TESTS_C+= unix_seqpacket_test TEST_METADATA.unix_seqpacket_test+= timeout="15" LDADD.unix_seqpacket_test+= -lpthread WARNS?= 5 +TESTS_SUBDIRS+= execve + .include diff --git a/tests/sys/kern/execve/Makefile b/tests/sys/kern/execve/Makefile new file mode 100644 index 000000000000..82c5d4b85b10 --- /dev/null +++ b/tests/sys/kern/execve/Makefile @@ -0,0 +1,39 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/sys/kern/execve + +BINDIR= ${TESTSDIR} + +MAN= + +ATF_TESTS_SH+= execve_test + +PROGS+= good_aout +PROGS+= execve_helper + +LDFLAGS.goodaout+= -static + +CLEANFILES+= empty +CLEANFILES+= sparse_aout +CLEANFILES+= trunc_aout + +SCRIPTS+= bad_interp_len +SCRIPTS+= dev_null_script +SCRIPTS+= empty +SCRIPTS+= good_script +SCRIPTS+= non_exist_shell +SCRIPTS+= script_arg +SCRIPTS+= script_arg_nospace +SCRIPTS+= sparse_aout +SCRIPTS+= trunc_aout + +empty: + @touch $@ + +sparse_aout: + @truncate -s 20480 $@ + +trunc_aout: + @truncate -s 16 $@ + +.include diff --git a/tools/regression/execve/tests/badinterplen b/tests/sys/kern/execve/bad_interp_len similarity index 100% rename from tools/regression/execve/tests/badinterplen rename to tests/sys/kern/execve/bad_interp_len diff --git a/tools/regression/execve/tests/devnullscript b/tests/sys/kern/execve/dev_null_script similarity index 100% rename from tools/regression/execve/tests/devnullscript rename to tests/sys/kern/execve/dev_null_script diff --git a/tools/regression/execve/doexec.c b/tests/sys/kern/execve/execve_helper.c similarity index 90% rename from tools/regression/execve/doexec.c rename to tests/sys/kern/execve/execve_helper.c index 0aa82ec87959..164a8f3fc61e 100644 --- a/tools/regression/execve/doexec.c +++ b/tests/sys/kern/execve/execve_helper.c @@ -1,58 +1,54 @@ /* $NetBSD: doexec.c,v 1.8 2003/07/26 19:38:48 salo Exp $ */ /* * Copyright (c) 1993 Christopher G. Demetriou * 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the * NetBSD Project. See http://www.NetBSD.org/ for * information about NetBSD. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. * * $FreeBSD$ */ +#include #include #include #include -#include #include int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char **argv) { + if (argc != 2) { fprintf(stderr, "usage: %s \n", argv[0]); exit(2); } - unsetenv("LANG"); /* we compare C error strings */ - if (execve(argv[1], &argv[1], NULL) == -1) { - printf("%s\n", strerror(errno)); - exit(1); - } + execve(argv[1], &argv[1], NULL); + err(1, ""); } diff --git a/tests/sys/kern/execve/execve_test.sh b/tests/sys/kern/execve/execve_test.sh new file mode 100644 index 000000000000..ef803a18d442 --- /dev/null +++ b/tests/sys/kern/execve/execve_test.sh @@ -0,0 +1,115 @@ + +bad_interp_len_head() +{ + atf_set "descr" "Bad interpreter length" +} +bad_interp_len_body() +{ + atf_check -s exit:1 -e 'match:No such file or directory' -o empty \ + -x "cd $(atf_get_srcdir) && ./execve_helper bad_interp_len" +} + +empty_head() +{ + atf_set "descr" "Empty file" +} +empty_body() +{ + atf_check -s exit:1 -e 'match:Exec format error' -o empty \ + -x "cd $(atf_get_srcdir) && ./execve_helper empty" +} + +good_aout_head() +{ + atf_set "descr" "Good a.out" +} +good_aout_body() +{ + atf_check -s exit:0 -e empty -o 'match:succeeded' \ + -x "cd $(atf_get_srcdir) && ./execve_helper ./good_aout" +} + +good_script_head() +{ + atf_set "descr" "Good script" +} +good_script_body() +{ + atf_check -s exit:0 -e empty -o 'match:succeeded' \ + -x "cd $(atf_get_srcdir) && ./execve_helper good_script" +} + +non_exist_head() +{ + atf_set "descr" "Non-existent file" +} +non_exist_body() +{ + atf_check -s exit:1 -e 'match:No such file or directory' -o empty \ + -x "cd $(atf_get_srcdir) && ./execve_helper non_exist" +} + +non_exist_shell_head() +{ + atf_set "descr" "Non-existent shell" +} +non_exist_shell_body() +{ + atf_check -s exit:1 -e 'match:No such file or directory' -o empty \ + -x "cd $(atf_get_srcdir) && ./execve_helper non_exist_shell" +} + +script_arg_head() +{ + atf_set "descr" "-x in the shebang" +} +script_arg_body() +{ + atf_check -s exit:0 -e 'match:\+ echo succeeded' -o 'match:succeeded' \ + -x "cd $(atf_get_srcdir) && ./execve_helper script_arg" +} + +script_arg_nospace_head() +{ + atf_set "descr" '-x in the shebang; no space between #! and /bin/sh' +} +script_arg_nospace_body() +{ + atf_check -s exit:0 -e 'match:\+ echo succeeded' -o 'match:succeeded' \ + -x "cd $(atf_get_srcdir) && ./execve_helper script_arg_nospace" +} + +sparse_aout_head() +{ + atf_set "descr" 'Sparse file' +} +sparse_aout_body() +{ + atf_check -s exit:1 -e 'match:Exec format error' -o empty \ + -x "cd $(atf_get_srcdir) && ./execve_helper sparse_aout" +} + +trunc_aout_head() +{ + atf_set "descr" 'Truncated file' +} +trunc_aout_body() +{ + atf_check -s exit:1 -e 'match:Exec format error' -o empty \ + -x "cd $(atf_get_srcdir) && ./execve_helper trunc_aout" +} + +atf_init_test_cases() +{ + atf_add_test_case bad_interp_len + atf_add_test_case empty + atf_add_test_case good_aout + atf_add_test_case good_script + atf_add_test_case non_exist + atf_add_test_case non_exist_shell + atf_add_test_case script_arg + atf_add_test_case script_arg_nospace + atf_add_test_case sparse_aout + atf_add_test_case trunc_aout + +} diff --git a/tools/regression/execve/tests/goodaout.c b/tests/sys/kern/execve/good_aout.c similarity index 97% rename from tools/regression/execve/tests/goodaout.c rename to tests/sys/kern/execve/good_aout.c index ebf476b2cf7f..39e986770c5d 100644 --- a/tools/regression/execve/tests/goodaout.c +++ b/tests/sys/kern/execve/good_aout.c @@ -1,47 +1,45 @@ /* $NetBSD: goodaout.c,v 1.8 2003/07/26 19:38:49 salo Exp $ */ /*- * Copyright (c) 1993 Christopher G. Demetriou * 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the * NetBSD Project. See http://www.NetBSD.org/ for * information about NetBSD. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. * * $FreeBSD$ */ #include #include int -main(argc, argv) - int argc; - char *argv[]; +main(void) { printf("succeeded\n"); exit(0); } diff --git a/tools/regression/execve/tests/goodscript b/tests/sys/kern/execve/good_script similarity index 70% rename from tools/regression/execve/tests/goodscript rename to tests/sys/kern/execve/good_script index 51270dc38da1..11c76898ca2e 100644 --- a/tools/regression/execve/tests/goodscript +++ b/tests/sys/kern/execve/good_script @@ -1,4 +1,4 @@ -#! /bin/csh +#!/bin/sh # $FreeBSD$ echo succeeded diff --git a/tools/regression/execve/tests/nonexistshell b/tests/sys/kern/execve/non_exist_shell similarity index 100% rename from tools/regression/execve/tests/nonexistshell rename to tests/sys/kern/execve/non_exist_shell diff --git a/tools/regression/execve/tests/scriptarg b/tests/sys/kern/execve/script_arg similarity index 100% rename from tools/regression/execve/tests/scriptarg rename to tests/sys/kern/execve/script_arg diff --git a/tools/regression/execve/tests/scriptarg-nospace b/tests/sys/kern/execve/script_arg_nospace similarity index 100% rename from tools/regression/execve/tests/scriptarg-nospace rename to tests/sys/kern/execve/script_arg_nospace diff --git a/tools/regression/execve/Makefile b/tools/regression/execve/Makefile deleted file mode 100644 index 018678cde02c..000000000000 --- a/tools/regression/execve/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -# $FreeBSD$ - -PROG= doexec -MAN= - -RP= ./${PROG} -TD= ${.CURDIR}/tests - -TESTSCRIPTS= nonexistshell devnullscript badinterplen goodscript \ - scriptarg scriptarg-nospace -CLEANFILES= goodaout truncaout sparseaout empty ${TESTSCRIPTS} - -all: ${PROG} goodaout ${TESTSCRIPTS} - -.for x in ${TESTSCRIPTS} -${x}: ${TD}/${x} - ${CP} ${TD}/${x} . - chmod +x ${x} -.endfor - -regress: test-empty test-nonexist test-nonexistshell \ - test-devnullscript test-badinterplen test-goodscript \ - test-scriptarg test-scriptarg-nospace test-goodaout \ - test-truncaout test-sparseaout - -test-empty: ${PROG} - rm -f empty - touch empty - chmod +x empty - ${RP} empty | grep 'Exec format error' - -test-nonexist: ${PROG} - ${RP} ${TD}/nonexistent | grep 'No such file or directory' - -test-nonexistshell: ${PROG} nonexistshell - ${RP} nonexistshell | grep 'No such file or directory' - -test-devnullscript: ${PROG} devnullscript - ${RP} devnullscript | grep 'Permission denied' - -test-badinterplen: ${PROG} badinterplen - ${RP} badinterplen | grep 'No such file or directory' - -test-goodscript: ${PROG} goodscript - ${RP} goodscript | grep 'succeeded' - -test-scriptarg: ${PROG} scriptarg - ${RP} scriptarg 2>&1 | grep '+ echo succeeded' - -test-scriptarg-nospace: ${PROG} scriptarg-nospace - ${RP} scriptarg-nospace 2>&1 | grep '+ echo succeeded' - -goodaout: ${TD}/goodaout.c - ${CC} -static -o ${.TARGET} ${TD}/goodaout.c - -test-goodaout: ${PROG} goodaout - ${RP} goodaout | grep 'succeeded' - -test-truncaout: ${PROG} goodaout - truncate -s 16 truncaout - chmod a+x truncaout - ${RP} truncaout | grep 'Exec format error' - -test-sparseaout: ${PROG} - /bin/rm -rf sparseaout - truncate -s 20480 sparseaout - chmod a+x sparseaout - ${RP} sparseaout | grep 'Exec format error' - -.include diff --git a/tools/regression/execve/execve.t b/tools/regression/execve/execve.t deleted file mode 100644 index dd2be9a9d0ea..000000000000 --- a/tools/regression/execve/execve.t +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` -cmd="./`basename $0 .t`" - -make >/dev/null 2>&1 - -tests="test-empty test-nonexist test-nonexistshell \ - test-devnullscript test-badinterplen test-goodscript \ - test-scriptarg test-scriptarg-nospace test-goodaout \ - test-truncaout test-sparseaout" - -n=0 - -echo "1..11" - -for atest in ${tests} -do - n=`expr ${n} + 1` - if make ${atest} - then - echo "ok ${n} - ${atest}" - else - echo "not ok ${n} - ${atest}" - fi -done