From owner-svn-src-all@freebsd.org Mon Jul 17 21:08:25 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5D2B5DA0D60; Mon, 17 Jul 2017 21:08:25 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EF5C71D77; Mon, 17 Jul 2017 21:08:25 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6HL8OKR054365; Mon, 17 Jul 2017 21:08:24 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6HL8OPP054364; Mon, 17 Jul 2017 21:08:24 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201707172108.v6HL8OPP054364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 17 Jul 2017 21:08:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r321088 - stable/11/bin/ln/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/bin/ln/tests X-SVN-Commit-Revision: 321088 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jul 2017 21:08:25 -0000 Author: ngie Date: Mon Jul 17 21:08:24 2017 New Revision: 321088 URL: https://svnweb.freebsd.org/changeset/base/321088 Log: MFC r319855,r319856,r319858: r319855: Use readlink(1)/stat(1) to query symlinks instead of file(1) file(1) can be compiled out of the system via MK_FILE == no, and the output isn't guaranteed to be stable. It's better to use stat(1)/readlink(1) instead to query symlink/file paths. MFC with: r319714, r319854 r319856: Add a testcase for `ln -sF` The testcase fails today, so mark it with atf_expect_fail: in particular, the target (B) isn't being unlinked and the documentation doesn't suggest special handling for directories. Thus, there's either a doc or an implementation bug in ln(1) that needs to be resolved. MFC with: r319714, r319854, r319855 PR: 219943 r319858: Style fixes: clean up leading whitespace (8 single column spaces -> \t) MFC with: r319714, r319854, r319855, r319856 Modified: stable/11/bin/ln/tests/ln_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/ln/tests/ln_test.sh ============================================================================== --- stable/11/bin/ln/tests/ln_test.sh Mon Jul 17 21:05:15 2017 (r321087) +++ stable/11/bin/ln/tests/ln_test.sh Mon Jul 17 21:08:24 2017 (r321088) @@ -28,193 +28,217 @@ set_umask() { - if ! umask 022; then - atf_fail "setting umask failed" - fi + 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" + 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 + 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:'Symbolic Link\n' stat -f %SHT B + atf_check -o inline:'A\n' readlink 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" + 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" + 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" + 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" + 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" + 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 + 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" + 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 + 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" + 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_check mkdir -m 0777 A B + atf_check ln -s A C + atf_check ln -shf B C + atf_check -o inline:'Symbolic Link\n' stat -f %SHT C + atf_check -o inline:'B\n' readlink 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" + 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_check mkdir -m 0777 A B + atf_check ln -s A C + atf_check ln -snf B C + atf_check -o inline:'Symbolic Link\n' stat -f %SHT C + atf_check -o inline:'B\n' readlink C } +atf_test_case sF_flag +sF_flag_head() +{ + atf_set "descr" "Verify that if the target file already exists " \ + "and is a directory, then '-sF' option removes " \ + "it so that the link may occur" +} + +sF_flag_body() +{ + atf_expect_fail "B isn't being unlinked (bug 219943)" + atf_check mkdir A B + atf_check ln -sF A B + atf_check -o inline:'Symbolic Link\n' stat -f %SHT B +} + 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" + 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 + set_umask + atf_check touch A B + atf_check ln -sf A B + atf_check -o inline:'Symbolic Link\n' stat -f %SHT B + atf_check -o inline:'A\n' readlink B } atf_test_case s_flag s_flag_head() { - atf_set "descr" "Verify that '-s' option creates a symbolic link" + 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 + set_umask + atf_check touch A + atf_check ln -s A B + atf_check -o inline:'Symbolic Link\n' stat -f %SHT B + atf_check -o inline:'A\n' readlink 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" + 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_check ln -s A B + atf_check -o inline:'Symbolic Link\n' stat -f %SHT B + atf_check -o inline:'A\n' readlink 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" + 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_check -s exit:0 -e inline:'ln: warning: A: No such file or directory\n' \ + ln -sw A B + atf_check -o inline:'Symbolic Link\n' stat -f %SHT B + atf_check -o inline:'A\n' readlink 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 + 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 sf_flag + atf_add_test_case s_flag + atf_add_test_case s_flag_broken + atf_add_test_case sw_flag }