Date: Tue, 18 Jul 2017 16:27:10 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r321130 - in stable/10: . bin/chmod bin/chmod/tests etc/mtree tools/build/mk usr.sbin/chown usr.sbin/chown/tests Message-ID: <201707181627.v6IGRAm4028058@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Tue Jul 18 16:27:10 2017 New Revision: 321130 URL: https://svnweb.freebsd.org/changeset/base/321130 Log: MFC r268030,r268793,r303212,r319642,r319830: r268030 (by eadler): chown: add a test Add a test for the chown utility. This sets up chown(8) to be capable of being tested. As such, only add one test for now as an example. r268793 (by eadler): chown: Fix chown test number r303212 (by bdrewery): Move chown tests to proper path r319642: Add some basic tests for chmod(1) r319830: Add more simple positive tests for chown(1) The tests are largely symmetric with the tests for chmod(1)--added in r319642. Remove chown-f_test (added in r268030) since the test coverage is now being provided by `chown_test`. Added: stable/10/bin/chmod/tests/ - copied from r319642, head/bin/chmod/tests/ stable/10/usr.sbin/chown/tests/ - copied from r268030, head/usr.sbin/chown/tests/ stable/10/usr.sbin/chown/tests/chown_test.sh - copied unchanged from r319830, head/usr.sbin/chown/tests/chown_test.sh Deleted: stable/10/usr.sbin/chown/tests/chown-f_test.sh Modified: stable/10/ObsoleteFiles.inc stable/10/bin/chmod/Makefile stable/10/etc/mtree/BSD.tests.dist stable/10/tools/build/mk/OptionalObsoleteFiles.inc stable/10/usr.sbin/chown/Makefile stable/10/usr.sbin/chown/tests/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/ObsoleteFiles.inc ============================================================================== --- stable/10/ObsoleteFiles.inc Tue Jul 18 16:03:39 2017 (r321129) +++ stable/10/ObsoleteFiles.inc Tue Jul 18 16:27:10 2017 (r321130) @@ -40,6 +40,8 @@ # 20170620: remove stale manpage OLD_FILES+=usr/share/man/man2/cap_rights_get.2.gz +# 20170610: chown-f_test replaced by chown_test +OLD_FILES+=usr/tests/usr.sbin/chown/chown-f_test # 20170322: rename <x> to <x>_test to match the FreeBSD test suite name scheme OLD_FILES+=usr/tests/usr.bin/col/col OLD_FILES+=usr/tests/usr.sbin/pw/pw_config Modified: stable/10/bin/chmod/Makefile ============================================================================== --- stable/10/bin/chmod/Makefile Tue Jul 18 16:03:39 2017 (r321129) +++ stable/10/bin/chmod/Makefile Tue Jul 18 16:27:10 2017 (r321130) @@ -1,6 +1,12 @@ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # $FreeBSD$ +.include <bsd.own.mk> + PROG= chmod + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include <bsd.prog.mk> Modified: stable/10/etc/mtree/BSD.tests.dist ============================================================================== --- stable/10/etc/mtree/BSD.tests.dist Tue Jul 18 16:03:39 2017 (r321129) +++ stable/10/etc/mtree/BSD.tests.dist Tue Jul 18 16:27:10 2017 (r321130) @@ -8,7 +8,7 @@ bin cat .. - chown + chmod .. date .. @@ -652,6 +652,8 @@ .. .. usr.sbin + chown + .. etcupdate .. extattr Modified: stable/10/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- stable/10/tools/build/mk/OptionalObsoleteFiles.inc Tue Jul 18 16:03:39 2017 (r321129) +++ stable/10/tools/build/mk/OptionalObsoleteFiles.inc Tue Jul 18 16:27:10 2017 (r321130) @@ -4820,6 +4820,9 @@ OLD_FILES+=usr/share/aclocal/atf-c.m4 OLD_FILES+=usr/share/aclocal/atf-common.m4 OLD_FILES+=usr/share/aclocal/atf-sh.m4 OLD_DIRS+=usr/share/aclocal +OLD_DIRS+=usr/tests/bin/chown +OLD_FILES+=usr/tests/bin/chown/Kyuafile +OLD_FILES+=usr/tests/bin/chown/chown-f_test OLD_FILES+=usr/tests/bin/date/legacy_test OLD_FILES+=usr/tests/bin/sh/legacy_test OLD_FILES+=usr/tests/lib/atf/libatf-c/test_helpers_test Modified: stable/10/usr.sbin/chown/Makefile ============================================================================== --- stable/10/usr.sbin/chown/Makefile Tue Jul 18 16:03:39 2017 (r321129) +++ stable/10/usr.sbin/chown/Makefile Tue Jul 18 16:27:10 2017 (r321130) @@ -1,8 +1,14 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.include <bsd.own.mk> + PROG= chown LINKS= ${BINDIR}/chown /usr/bin/chgrp MAN= chgrp.1 chown.8 + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include <bsd.prog.mk> Modified: stable/10/usr.sbin/chown/tests/Makefile ============================================================================== --- head/usr.sbin/chown/tests/Makefile Mon Jun 30 05:33:52 2014 (r268030) +++ stable/10/usr.sbin/chown/tests/Makefile Tue Jul 18 16:27:10 2017 (r321130) @@ -1,9 +1,5 @@ # $FreeBSD$ -.include <bsd.own.mk> - -TESTSDIR= ${TESTSBASE}/bin/chown - -TAP_TESTS_SH= chown-f_test +ATF_TESTS_SH+= chown_test .include <bsd.test.mk> Copied: stable/10/usr.sbin/chown/tests/chown_test.sh (from r319830, head/usr.sbin/chown/tests/chown_test.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/usr.sbin/chown/tests/chown_test.sh Tue Jul 18 16:27:10 2017 (r321130, copy of r319830, head/usr.sbin/chown/tests/chown_test.sh) @@ -0,0 +1,206 @@ +# +# Copyright (c) 2017 Dell EMC +# 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$ + +atf_test_case RH_flag +RH_flag_head() +{ + atf_set "descr" "Verify that setting ownership recursively via -R doesn't " \ + "affect symlinks specified via the arguments when -H " \ + "is specified" + atf_set "require.user" "root" +} +RH_flag_body() +{ + atf_check mkdir -p A/B + atf_check ln -s B A/C + atf_check chown -h 42:42 A/C + atf_check -o inline:'0:0\n0:0\n42:42\n' stat -f '%u:%g' A A/B A/C + atf_check chown -RH 84:84 A + atf_check -o inline:'84:84\n84:84\n84:84\n' stat -f '%u:%g' A A/B A/C + atf_check chown -RH 126:126 A/C + atf_check -o inline:'84:84\n126:126\n84:84\n' stat -f '%u:%g' A A/B A/C +} + +atf_test_case RL_flag +RL_flag_head() +{ + atf_set "descr" "Verify that setting ownership recursively via -R doesn't " \ + "affect symlinks specified via the arguments when -L " \ + "is specified" + atf_set "require.user" "root" +} +RL_flag_body() +{ + atf_check mkdir -p A/B + atf_check ln -s B A/C + atf_check chown -h 42:42 A/C + atf_check -o inline:'0:0\n0:0\n42:42\n' stat -f '%u:%g' A A/B A/C + atf_check chown -RL 84:84 A + atf_check -o inline:'84:84\n84:84\n42:42\n' stat -f '%u:%g' A A/B A/C + atf_check chown -RL 126:126 A/C + atf_check -o inline:'84:84\n126:126\n42:42\n' stat -f '%u:%g' A A/B A/C +} + +atf_test_case RP_flag +RP_flag_head() +{ + atf_set "descr" "Verify that setting ownership recursively via -R " \ + "doesn't affect symlinks specified via the arguments " \ + "when -P is specified" + atf_set "require.user" "root" +} +RP_flag_body() +{ + atf_check mkdir -p A/B + atf_check ln -s B A/C + atf_check chown -h 42:42 A/C + atf_check -o inline:'0:0\n0:0\n42:42\n' stat -f '%u:%g' A A/B A/C + atf_check chown -RP 84:84 A + atf_check -o inline:'84:84\n84:84\n84:84\n' stat -f '%u:%g' A A/B A/C + atf_check chown -RP 126:126 A/C + atf_check -o inline:'84:84\n84:84\n126:126\n' stat -f '%u:%g' A A/B A/C +} + +atf_test_case f_flag cleanup +f_flag_head() +{ + atf_set "descr" "Verify that setting a mode for a file with -f " \ + "doesn't emit an error message/exit with a non-zero " \ + "code" + atf_set "require.user" "root" +} + +f_flag_body() +{ + atf_check truncate -s 0 foo bar + atf_check chown 0:0 foo bar + atf_check chflags uchg foo + atf_check -e not-empty -s not-exit:0 chown 42:42 foo bar + atf_check -o inline:'0:0\n42:42\n' stat -f '%u:%g' foo bar + atf_check -s exit:0 chown -f 84:84 foo bar + atf_check -o inline:'0:0\n84:84\n' stat -f '%u:%g' foo bar +} + +f_flag_cleanup() +{ + atf_check chflags 0 foo +} + +atf_test_case h_flag +h_flag_head() +{ + atf_set "descr" "Verify that setting a mode for a file with -f " \ + "doesn't emit an error message/exit with a non-zero " \ + "code" + atf_set "require.user" "root" +} + +h_flag_body() +{ + atf_check truncate -s 0 foo + atf_check -o inline:'0:0\n' stat -f '%u:%g' foo + atf_check ln -s foo bar + atf_check -o inline:'0:0\n0:0\n' stat -f '%u:%g' foo bar + atf_check chown -h 42:42 bar + atf_check -o inline:'0:0\n42:42\n' stat -f '%u:%g' foo bar + atf_check chown 84:84 bar + atf_check -o inline:'84:84\n42:42\n' stat -f '%u:%g' foo bar +} + +atf_test_case v_flag +v_flag_head() +{ + atf_set "descr" "Verify that setting ownership with -v emits the " \ + "file doesn't emit an error message/exit with a " \ + "non-zero code" + atf_set "require.user" "root" +} +v_flag_body() +{ + atf_check truncate -s 0 foo bar + atf_check chown 0:0 foo + atf_check chown 42:42 bar + atf_check -o 'inline:bar\n' chown -v 0:0 foo bar + atf_check chown -v 0:0 foo bar + for f in foo bar; do + echo "$f: 0:0 -> 84:84"; + done > output.txt + atf_check -o file:output.txt chown -vv 84:84 foo bar + atf_check chown -vv 84:84 foo bar +} + +md_file="md.out" +atf_test_case x_flag cleanup +x_flag_head() +{ + atf_set "descr" "Verify that setting a mode with -x doesn't set " \ + "ownership across mountpoints" + atf_set "require.user" "root" +} +x_flag_body() +{ + atf_check -o save:$md_file mdconfig -a -t malloc -s 20m + if ! md_device=$(cat $md_file); then + atf_fail "cat $md_file failed" + fi + atf_check -o not-empty newfs /dev/$md_device + atf_check mkdir mnt + atf_check mount /dev/$md_device mnt + atf_check truncate -s 0 foo bar mnt/bazbaz + atf_check ln -s bar mnt/barbaz + atf_check ln -s ../foo mnt/foobaz + cd mnt + test_files="../foo ../bar barbaz bazbaz foobaz" + atf_check -o inline:'0:0\n0:0\n0:0\n0:0\n0:0\n' \ + stat -f '%u:%g' $test_files + atf_check chown -Rx 42:42 . + atf_check -o inline:'0:0\n0:0\n42:42\n42:42\n42:42\n' \ + stat -f '%u:%g' $test_files + atf_check chown -R 84:84 . + atf_check -o inline:'0:0\n0:0\n84:84\n84:84\n84:84\n' \ + stat -f '%u:%g' $test_files +} +x_flag_cleanup() +{ + if ! md_device=$(cat $md_file) || [ -z "$md_device" ]; then + echo "Couldn't get device from $md_file" + exit 0 + fi + umount mnt + mdconfig -d -u $md_device +} + +atf_init_test_cases() +{ + atf_add_test_case RH_flag + atf_add_test_case RL_flag + atf_add_test_case RP_flag + atf_add_test_case f_flag + atf_add_test_case h_flag + atf_add_test_case v_flag + atf_add_test_case x_flag +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707181627.v6IGRAm4028058>