summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-03-20 02:58:05 +0000
committerngie <ngie@FreeBSD.org>2017-03-20 02:58:05 +0000
commitde0ea052d3200c13c20c1be542fa25b73c1b22b9 (patch)
tree458598940aeb384d3ca96237a1c0fa5ffc3a9b0d /usr.bin
parent1c8b5bf4b5b8e893dd389d4ac3e6fb55a2ca0858 (diff)
downloadFreeBSD-src-de0ea052d3200c13c20c1be542fa25b73c1b22b9.zip
FreeBSD-src-de0ea052d3200c13c20c1be542fa25b73c1b22b9.tar.gz
MFC r315098,r315106,r315108:
r315098: Clarify src vs dest path mismatch in :symbolic_link_{absolute,relative}_body Unfortunately kyua does not omit the path mismatch on failure, so it must be coded into the error message. Cache the values, run the test(1) call, then print out the values in an atf_fail call to emit the required diagnostics to debug why things are failing. r315106: Add 3 more testcases demonstrating how install -l sr works The additional testcases use absolute paths for sources and targets, as the other testcase which tested `-l sr` used flat relative paths in the same directory. Please note that these testcases do not test `-l a` -- that's already addressed in the battery of tests. r315108: Restore some of the error message text accidentally removed in r315098 "unexpected symlink contents" is more pedantically correct than "unexpected symlink".
Diffstat (limited to 'usr.bin')
-rwxr-xr-xusr.bin/xinstall/tests/install_test.sh78
1 files changed, 76 insertions, 2 deletions
diff --git a/usr.bin/xinstall/tests/install_test.sh b/usr.bin/xinstall/tests/install_test.sh
index 9a9c69f..4332f9b 100755
--- a/usr.bin/xinstall/tests/install_test.sh
+++ b/usr.bin/xinstall/tests/install_test.sh
@@ -283,7 +283,11 @@ symbolic_link_absolute_body() {
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"
+ copyf_path=$(readlink copyf)
+ testf_path="$(pwd -P)/testf"
+ if [ "$copyf_path" != "$testf_path" ]; then
+ atf_fail "unexpected symlink contents ('$copyf_path' != '$testf_path')"
+ fi
}
atf_test_case symbolic_link_relative
@@ -292,7 +296,74 @@ symbolic_link_relative_body() {
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"
+ copyf_path=$(readlink copyf)
+ testf_path="testf"
+ if [ "$copyf_path" != "$testf_path" ]; then
+ atf_fail "unexpected symlink contents ('$copyf_path' != '$testf_path')"
+ fi
+}
+
+atf_test_case symbolic_link_relative_absolute_source_and_dest1
+symbolic_link_relative_absolute_source_and_dest1_head() {
+ atf_set "descr" "Verify -l rs with absolute paths (.../copyf -> .../a/b/c/testf)"
+}
+symbolic_link_relative_absolute_source_and_dest1_body() {
+ src_path=a/b/c/testf
+ src_path_prefixed=$PWD/$src_path
+ dest_path=$PWD/copyf
+
+ atf_check mkdir -p a/b/c
+ atf_check touch $src_path
+ atf_check install -l sr $src_path_prefixed $dest_path
+ [ $src_path_prefixed -ef $dest_path ] || atf_fail "not same file"
+ [ -L $dest_path ] || atf_fail "copy is not symlink"
+ dest_path_relative=$(readlink $dest_path)
+ src_path_relative="$src_path"
+ if [ "$src_path_relative" != "$dest_path_relative" ]; then
+ atf_fail "unexpected symlink contents ('$src_path_relative' != '$dest_path_relative')"
+ fi
+}
+
+atf_test_case symbolic_link_relative_absolute_source_and_dest1_double_slash
+symbolic_link_relative_absolute_source_and_dest1_double_slash_head() {
+ atf_set "descr" "Verify -l rs with absolute paths (.../copyf -> .../a/b/c/testf), using double-slashes"
+}
+symbolic_link_relative_absolute_source_and_dest1_double_slash_body() {
+ src_path=a//b//c//testf
+ src_path_prefixed=$PWD/$src_path
+ dest_path=$PWD/copyf
+
+ atf_check mkdir -p a/b/c
+ atf_check touch $src_path
+ atf_check install -l sr $src_path_prefixed $dest_path
+ [ $src_path_prefixed -ef $dest_path ] || atf_fail "not same file"
+ [ -L $dest_path ] || atf_fail "copy is not symlink"
+ dest_path_relative=$(readlink $dest_path)
+ src_path_relative="$(echo $src_path | sed -e 's,//,/,g')"
+ if [ "$src_path_relative" != "$dest_path_relative" ]; then
+ atf_fail "unexpected symlink contents ('$src_path_relative' != '$dest_path_relative')"
+ fi
+}
+
+atf_test_case symbolic_link_relative_absolute_source_and_dest2
+symbolic_link_relative_absolute_source_and_dest2_head() {
+ atf_set "descr" "Verify -l rs with absolute paths (.../a/b/c/copyf -> .../testf)"
+}
+symbolic_link_relative_absolute_source_and_dest2_body() {
+ src_path=testf
+ src_path_prefixed=$PWD/$src_path
+ dest_path=$PWD/a/b/c/copyf
+
+ atf_check mkdir -p a/b/c
+ atf_check touch $src_path
+ atf_check install -l sr $src_path_prefixed $dest_path
+ [ $src_path_prefixed -ef $dest_path ] || atf_fail "not same file"
+ [ -L $dest_path ] || atf_fail "copy is not symlink"
+ dest_path_relative=$(readlink $dest_path)
+ src_path_relative="../../../$src_path"
+ if [ "$src_path_relative" != "$dest_path_relative" ]; then
+ atf_fail "unexpected symlink contents ('$src_path_relative' != '$dest_path_relative')"
+ fi
}
atf_test_case mkdir_simple
@@ -341,5 +412,8 @@ atf_init_test_cases() {
atf_add_test_case symbolic_link
atf_add_test_case symbolic_link_absolute
atf_add_test_case symbolic_link_relative
+ atf_add_test_case symbolic_link_relative_absolute_source_and_dest1
+ atf_add_test_case symbolic_link_relative_absolute_source_and_dest1_double_slash
+ atf_add_test_case symbolic_link_relative_absolute_source_and_dest2
atf_add_test_case mkdir_simple
}
OpenPOWER on IntegriCloud