Index: head/etc/mtree/BSD.tests.dist =================================================================== --- head/etc/mtree/BSD.tests.dist (revision 299243) +++ head/etc/mtree/BSD.tests.dist (revision 299244) @@ -1,666 +1,668 @@ # $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 .. dd .. expr .. ls .. 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 .. .. libarchive .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. inet .. locale .. net getaddrinfo data .. .. .. nss .. regex data .. .. resolv .. rpc .. ssp .. setjmp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcrypt .. libmp .. libnv .. libpam .. libproc .. librt .. libthr dlopen .. .. libutil .. libxo .. 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 acl .. aio .. fifo .. file .. geom class concat .. eli .. gate .. gpt .. mirror .. nop .. raid3 .. shsec .. stripe .. uzip etalon .. .. .. .. kern acct .. execve .. pipe .. .. kqueue .. mac bsdextended .. portacl .. .. mqueue .. netinet .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. .. posixshm .. sys .. vfs .. vm .. .. 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 .. cpio .. col .. comm .. cut .. dirname .. file2c .. grep .. gzip .. ident .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. printf .. sdiff .. sed regress.multitest.out .. .. soelim .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. xargs .. + xinstall + .. xo .. yacc yacc .. .. .. usr.sbin etcupdate .. extattr .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. rpcbind .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: head/usr.bin/xinstall/Makefile =================================================================== --- head/usr.bin/xinstall/Makefile (revision 299243) +++ head/usr.bin/xinstall/Makefile (revision 299244) @@ -1,15 +1,21 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.include + PROG= xinstall PROGNAME= install SRCS= xinstall.c getid.c MAN= install.1 .PATH: ${.CURDIR}/../../contrib/mtree CFLAGS+= -I${.CURDIR}/../../contrib/mtree CFLAGS+= -I${.CURDIR}/../../lib/libnetbsd LIBADD= md + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include Index: head/usr.bin/xinstall/tests/Makefile =================================================================== --- head/usr.bin/xinstall/tests/Makefile (nonexistent) +++ head/usr.bin/xinstall/tests/Makefile (revision 299244) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +ATF_TESTS_SH+= install_test + +.include Property changes on: head/usr.bin/xinstall/tests/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/usr.bin/xinstall/tests/install_test.sh =================================================================== --- head/usr.bin/xinstall/tests/install_test.sh (nonexistent) +++ head/usr.bin/xinstall/tests/install_test.sh (revision 299244) @@ -0,0 +1,338 @@ +# +# Copyright (c) 2016 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. +# +# $FreeBSD$ +# + +copy_to_nonexistent_with_opts() { + printf 'test\n123\r456\r\n789\0z' >testf + atf_check install "$@" testf copyf + cmp testf copyf || atf_fail "bad copy" + [ ! testf -nt copyf ] || atf_fail "bad timestamp" + [ ! -e copyf.bak ] || atf_fail "no backup expected" +} + +atf_test_case copy_to_nonexistent +copy_to_nonexistent_body() { + copy_to_nonexistent_with_opts +} + +atf_test_case copy_to_nonexistent_safe +copy_to_nonexistent_safe_body() { + copy_to_nonexistent_with_opts -S +} + +atf_test_case copy_to_nonexistent_comparing +copy_to_nonexistent_comparing_body() { + copy_to_nonexistent_with_opts -C +} + +atf_test_case copy_to_nonexistent_safe_comparing +copy_to_nonexistent_safe_comparing_body() { + copy_to_nonexistent_with_opts -S -C +} + +atf_test_case copy_to_nonexistent_backup +copy_to_nonexistent_backup_body() { + copy_to_nonexistent_with_opts -b -B.bak +} + +atf_test_case copy_to_nonexistent_backup_safe +copy_to_nonexistent_backup_safe_body() { + copy_to_nonexistent_with_opts -b -B.bak -S +} + +copy_self_with_opts() { + printf 'test\n123\r456\r\n789\0z' >testf + printf 'test\n123\r456\r\n789\0z' >testf2 + atf_check -s not-exit:0 -o empty -e match:. install "$@" testf testf + cmp testf testf2 || atf_fail "file changed after self-copy attempt" +} + +atf_test_case copy_self +copy_self_body() { + copy_self_with_opts +} + +atf_test_case copy_self_safe +copy_self_safe_body() { + copy_self_with_opts -S +} + +atf_test_case copy_self_comparing +copy_self_comparing_body() { + copy_self_with_opts -C +} + +atf_test_case copy_self_safe_comparing +copy_self_safe_comparing_body() { + copy_self_with_opts -S -C +} + +overwrite_with_opts() { + printf 'test\n123\r456\r\n789\0z' >testf + printf 'test\n123\r456\r\n789\0w' >otherf + atf_check install "$@" testf otherf + cmp testf otherf || atf_fail "bad overwrite" + [ ! testf -nt otherf ] || atf_fail "bad timestamp" +} + +atf_test_case overwrite +overwrite_body() { + overwrite_with_opts +} + +atf_test_case overwrite_safe +overwrite_safe_body() { + overwrite_with_opts -S +} + +atf_test_case overwrite_comparing +overwrite_comparing_body() { + overwrite_with_opts -C +} + +atf_test_case overwrite_safe_comparing +overwrite_safe_comparing_body() { + overwrite_with_opts -S -C +} + +overwrite_eq_with_opts() { + printf 'test\n123\r456\r\n789\0z' >testf + printf 'test\n123\r456\r\n789\0z' >otherf + atf_check install "$@" testf otherf + cmp testf otherf || atf_fail "bad overwrite" + [ ! testf -nt otherf ] || atf_fail "bad timestamp" +} + +atf_test_case overwrite_eq +overwrite_eq_body() { + overwrite_eq_with_opts +} + +atf_test_case overwrite_eq_safe +overwrite_eq_safe_body() { + overwrite_eq_with_opts -S +} + +atf_test_case overwrite_eq_comparing +overwrite_eq_comparing_body() { + overwrite_eq_with_opts -C +} + +atf_test_case overwrite_eq_safe_comparing +overwrite_eq_safe_comparing_body() { + overwrite_eq_with_opts -S -C +} + +overwrite_backup_with_opts() { + printf 'test\n123\r456\r\n789\0z' >testf + printf 'test\n123\r456\r\n789\0w' >otherf + printf 'test\n123\r456\r\n789\0w' >otherf2 + atf_check install -b -B.bak "$@" testf otherf + cmp testf otherf || atf_fail "bad overwrite" + [ ! testf -nt otherf ] || atf_fail "bad timestamp" + cmp otherf.bak otherf2 || atf_fail "bad backup" +} + +atf_test_case overwrite_backup +overwrite_backup_body() { + overwrite_backup_with_opts +} + +atf_test_case overwrite_backup_safe +overwrite_backup_safe_body() { + overwrite_backup_with_opts -S +} + +atf_test_case overwrite_backup_comparing +overwrite_backup_comparing_body() { + overwrite_backup_with_opts -C +} + +atf_test_case overwrite_backup_safe_comparing +overwrite_backup_safe_comparing_body() { + overwrite_backup_with_opts -S -C +} + +setup_stripbin() { + cat <<\STRIPBIN >stripbin +#!/bin/sh +tr z @ <"$1" >"$1.new" && mv -- "$1.new" "$1" +STRIPBIN + chmod 755 stripbin + export STRIPBIN="$PWD/stripbin" +} + +strip_changing_with_opts() { + setup_stripbin + printf 'test\n123\r456\r\n789\0z' >testf + atf_check install -s "$@" testf copyf + [ ! testf -nt copyf ] || atf_fail "bad timestamp" + printf 'test\n123\r456\r\n789\0@' >otherf + cmp otherf copyf || atf_fail "bad stripped copy" +} + +atf_test_case strip_changing +strip_changing_body() { + strip_changing_with_opts +} + +atf_test_case strip_changing_comparing +strip_changing_comparing_body() { + strip_changing_with_opts -C +} + +strip_changing_overwrite_with_opts() { + setup_stripbin + printf 'test\n123\r456\r\n789\0z' >testf + printf 'test\n123\r456\r\n789\0w' >copyf + atf_check install -s "$@" testf copyf + [ ! testf -nt copyf ] || atf_fail "bad timestamp" + printf 'test\n123\r456\r\n789\0@' >otherf + cmp otherf copyf || atf_fail "bad stripped copy" +} + +atf_test_case strip_changing_overwrite +strip_changing_overwrite_body() { + strip_changing_overwrite_with_opts +} + +atf_test_case strip_changing_overwrite_comparing +strip_changing_overwrite_comparing_body() { + strip_changing_overwrite_with_opts -C +} + +strip_changing_overwrite_eq_with_opts() { + setup_stripbin + printf 'test\n123\r456\r\n789\0z' >testf + printf 'test\n123\r456\r\n789\0@' >copyf + atf_check install -s "$@" testf copyf + [ ! testf -nt copyf ] || atf_fail "bad timestamp" + printf 'test\n123\r456\r\n789\0@' >otherf + cmp otherf copyf || atf_fail "bad stripped copy" +} + +atf_test_case strip_changing_overwrite_eq +strip_changing_overwrite_eq_body() { + strip_changing_overwrite_eq_with_opts +} + +atf_test_case strip_changing_overwrite_eq_comparing +strip_changing_overwrite_eq_comparing_body() { + strip_changing_overwrite_eq_with_opts -C +} + +atf_test_case strip_noop +strip_noop_body() { + export STRIPBIN=true + printf 'test\n123\r456\r\n789\0z' >testf + atf_check install -s testf copyf + [ ! testf -nt copyf ] || atf_fail "bad timestamp" + printf 'test\n123\r456\r\n789\0z' >otherf + cmp otherf copyf || atf_fail "bad stripped copy" +} + +atf_test_case hard_link +hard_link_body() { + printf 'test\n123\r456\r\n789\0z' >testf + atf_check install -l h testf copyf + [ testf -ef copyf ] || atf_fail "not same file" + [ ! -L copyf ] || atf_fail "copy is symlink" +} + +atf_test_case symbolic_link +symbolic_link_body() { + printf 'test\n123\r456\r\n789\0z' >testf + atf_check install -l s testf copyf + [ testf -ef copyf ] || atf_fail "not same file" + [ -L copyf ] || atf_fail "copy is not symlink" +} + +atf_test_case symbolic_link_absolute +symbolic_link_absolute_body() { + printf 'test\n123\r456\r\n789\0z' >testf + atf_check install -l sa testf copyf + [ testf -ef copyf ] || atf_fail "not same file" + [ -L copyf ] || atf_fail "copy is not symlink" + [ "$(readlink copyf)" = "$(pwd -P)/testf" ] || atf_fail "unexpected symlink contents" +} + +atf_test_case symbolic_link_relative +symbolic_link_relative_body() { + printf 'test\n123\r456\r\n789\0z' >testf + atf_check install -l sr testf copyf + [ testf -ef copyf ] || atf_fail "not same file" + [ -L copyf ] || atf_fail "copy is not symlink" + [ "$(readlink copyf)" = "testf" ] || atf_fail "unexpected symlink contents" +} + +atf_test_case mkdir_simple +mkdir_simple_body() { + atf_check install -d dir1/dir2 + [ -d dir1 ] || atf_fail "dir1 missing" + [ -d dir1/dir2 ] || atf_fail "dir2 missing" + atf_check install -d dir1/dir2/dir3 + [ -d dir1/dir2/dir3 ] || atf_fail "dir3 missing" + atf_check install -d dir1 + atf_check install -d dir1/dir2/dir3 +} + +atf_init_test_cases() { + atf_add_test_case copy_to_nonexistent + atf_add_test_case copy_to_nonexistent_safe + atf_add_test_case copy_to_nonexistent_comparing + atf_add_test_case copy_to_nonexistent_safe_comparing + atf_add_test_case copy_to_nonexistent_backup + atf_add_test_case copy_to_nonexistent_backup_safe + atf_add_test_case copy_self + atf_add_test_case copy_self_safe + atf_add_test_case copy_self_comparing + atf_add_test_case copy_self_safe_comparing + atf_add_test_case overwrite + atf_add_test_case overwrite_safe + atf_add_test_case overwrite_comparing + atf_add_test_case overwrite_safe_comparing + atf_add_test_case overwrite_eq + atf_add_test_case overwrite_eq_safe + atf_add_test_case overwrite_eq_comparing + atf_add_test_case overwrite_eq_safe_comparing + atf_add_test_case overwrite_backup + atf_add_test_case overwrite_backup_safe + atf_add_test_case overwrite_backup_comparing + atf_add_test_case overwrite_backup_safe_comparing + atf_add_test_case strip_changing + atf_add_test_case strip_changing_comparing + atf_add_test_case strip_changing_overwrite + atf_add_test_case strip_changing_overwrite_comparing + atf_add_test_case strip_changing_overwrite_eq + atf_add_test_case strip_changing_overwrite_eq_comparing + atf_add_test_case strip_noop + atf_add_test_case hard_link + atf_add_test_case symbolic_link + atf_add_test_case symbolic_link_absolute + atf_add_test_case symbolic_link_relative + atf_add_test_case mkdir_simple +} Property changes on: head/usr.bin/xinstall/tests/install_test.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property