Author: ngie
Date: Mon Mar 20 02:58:05 2017
New Revision: 315604
URL: https://svnweb.freebsd.org/changeset/base/315604

Log:
  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".

Modified:
  stable/11/usr.bin/xinstall/tests/install_test.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/xinstall/tests/install_test.sh
==============================================================================
--- stable/11/usr.bin/xinstall/tests/install_test.sh    Mon Mar 20 02:47:28 
2017        (r315603)
+++ stable/11/usr.bin/xinstall/tests/install_test.sh    Mon Mar 20 02:58:05 
2017        (r315604)
@@ -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
 }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to