Index: stable/11/bin/ln/Makefile =================================================================== --- stable/11/bin/ln/Makefile (revision 320679) +++ stable/11/bin/ln/Makefile (revision 320680) @@ -1,11 +1,17 @@ # @(#)Makefile 8.2 (Berkeley) 5/31/93 # $FreeBSD$ +.include + PACKAGE=runtime PROG= ln MAN= ln.1 symlink.7 LINKS= ${BINDIR}/ln ${BINDIR}/link MLINKS= ln.1 link.1 + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include Index: stable/11/bin/ln/tests/ln_test.sh =================================================================== --- stable/11/bin/ln/tests/ln_test.sh (nonexistent) +++ stable/11/bin/ln/tests/ln_test.sh (revision 320680) @@ -0,0 +1,220 @@ +# +# Copyright 2017 Shivansh Rai +# 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$ +# + +set_umask() +{ + if ! umask 022; then + atf_fail "setting umask failed" + fi +} + +atf_test_case L_flag +L_flag_head() +{ + atf_set "descr" "Verify that when creating a hard link to a " \ + "symbolic link, '-L' option creates a hard" \ + "link to the target of the symbolic link" +} + +L_flag_body() +{ + set_umask + atf_check touch A + atf_check ln -s A B + atf_check ln -L B C + stat_A=$(stat -f %i A) + stat_C=$(stat -f %i C) + atf_check_equal "$stat_A" "$stat_C" + atf_check -o inline:'B: symbolic link to A\n' file B +} + +atf_test_case P_flag +P_flag_head() +{ + atf_set "descr" "Verify that when creating a hard link to a " \ + "symbolic link, '-P' option creates a hard " \ + "link to the symbolic link itself" +} + +P_flag_body() +{ + set_umask + atf_check touch A + atf_check ln -s A B + atf_check ln -P B C + stat_B=$(stat -f %i B) + stat_C=$(stat -f %i C) + atf_check_equal "$stat_B" "$stat_C" +} + +atf_test_case f_flag +f_flag_head() +{ + atf_set "descr" "Verify that if the target file already exists, " \ + "'-f' option unlinks it so that link may occur" +} + +f_flag_body() +{ + set_umask + atf_check touch A B + atf_check ln -f A B + stat_A=$(stat -f %i A) + stat_B=$(stat -f %i B) + atf_check_equal "$stat_A" "$stat_B" +} + +atf_test_case target_exists_hard +target_exists_hard_head() +{ + atf_set "descr" "Verify whether creating a hard link fails if the " \ + "target file already exists" +} + +target_exists_hard_body() +{ + set_umask + atf_check touch A B + atf_check -s exit:1 -e inline:'ln: B: File exists\n' \ + ln A B +} + +atf_test_case target_exists_symbolic +target_exists_symbolic_head() +{ + atf_set "descr" "Verify whether creating a symbolic link fails if " \ + "the target file already exists" +} + +target_exists_symbolic_body() +{ + set_umask + atf_check touch A B + atf_check -s exit:1 -e inline:'ln: B: File exists\n' \ + ln -s A B +} + +atf_test_case shf_flag_dir +shf_flag_dir_head() { + atf_set "descr" "Verify that if the target directory is a symbolic " \ + "link, '-shf' option prevents following the link" +} + +shf_flag_dir_body() +{ + atf_check mkdir -m 0777 A B + atf_check ln -s A C + atf_check ln -shf B C + atf_check -o inline:'C: symbolic link to B\n' file C +} + +atf_test_case snf_flag_dir +snf_flag_dir_head() { + atf_set "descr" "Verify that if the target directory is a symbolic " \ + "link, '-snf' option prevents following the link" +} + +snf_flag_dir_body() +{ + atf_check mkdir -m 0777 A B + atf_check ln -s A C + atf_check ln -snf B C + atf_check -o inline:'C: symbolic link to B\n' file C +} + +atf_test_case sf_flag +sf_flag_head() +{ + atf_set "descr" "Verify that if the target file already exists, " \ + "'-sf' option unlinks it and creates a symbolic link " \ + "to the source file" +} + +sf_flag_body() +{ + set_umask + atf_check touch A B + atf_check ln -sf A B + atf_check -o inline:'B: symbolic link to A\n' file B +} + +atf_test_case s_flag +s_flag_head() +{ + atf_set "descr" "Verify that '-s' option creates a symbolic link" +} + +s_flag_body() +{ + set_umask + atf_check touch A + atf_check ln -s A B + atf_check -o inline:'B: symbolic link to A\n' file B +} + +atf_test_case s_flag_broken +s_flag_broken_head() +{ + atf_set "descr" "Verify that if the source file does not exists, '-s' " \ + "option creates a broken symbolic link to the source file" +} + +s_flag_broken_body() +{ + atf_check ln -s A B + atf_check -o inline:'B: broken symbolic link to A\n' file B +} + +atf_test_case sw_flag +sw_flag_head() +{ + atf_set "descr" "Verify that '-sw' option produces a warning if the " \ + "source of a symbolic link does not currently exist" +} + +sw_flag_body() +{ + atf_check -s exit:0 -e inline:'ln: warning: A: No such file or directory\n' \ + ln -sw A B + atf_check -o inline:'B: broken symbolic link to A\n' file B +} + +atf_init_test_cases() +{ + atf_add_test_case L_flag + atf_add_test_case P_flag + atf_add_test_case f_flag + atf_add_test_case target_exists_hard + atf_add_test_case target_exists_symbolic + atf_add_test_case shf_flag_dir + atf_add_test_case snf_flag_dir + atf_add_test_case sf_flag + atf_add_test_case s_flag + atf_add_test_case s_flag_broken + atf_add_test_case sw_flag +} Property changes on: stable/11/bin/ln/tests/ln_test.sh ___________________________________________________________________ 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: stable/11/bin/ln/tests/Makefile =================================================================== --- stable/11/bin/ln/tests/Makefile (nonexistent) +++ stable/11/bin/ln/tests/Makefile (revision 320680) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +ATF_TESTS_SH+= ln_test + +.include Property changes on: stable/11/bin/ln/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: stable/11/etc/mtree/BSD.tests.dist =================================================================== --- stable/11/etc/mtree/BSD.tests.dist (revision 320679) +++ stable/11/etc/mtree/BSD.tests.dist (revision 320680) @@ -1,698 +1,700 @@ # $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 .. + ln + .. ls .. mv .. pax .. pkill .. pwait .. 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 .. .. .. zfsd .. .. .. 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 .. .. iconv .. inet .. locale .. net getaddrinfo data .. .. .. nss .. regex data .. .. resolv .. rpc .. ssp .. setjmp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcam .. libcrypt .. libdevdctl .. libkvm .. 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 .. fs tmpfs .. .. geom class concat .. eli .. gate .. gpt .. mirror .. nop .. raid3 .. shsec .. stripe .. uzip etalon .. .. .. .. kern acct .. execve .. pipe .. .. kqueue libkqueue .. .. 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 .. .. .. bsdcat .. calendar .. cmp .. compress .. cpio .. col .. comm .. cut .. dirname .. file2c .. getconf .. grep .. gzip .. ident .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. pr .. printf .. sdiff .. sed regress.multitest.out .. .. soelim .. tail .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. uniq .. xargs .. xinstall .. xo .. yacc yacc .. .. .. usr.sbin etcupdate .. extattr .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. rpcbind .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: stable/11 =================================================================== --- stable/11 (revision 320679) +++ stable/11 (revision 320680) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r319714,319854