Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jun 2017 16:31:32 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319855 - head/bin/ln/tests
Message-ID:  <201706121631.v5CGVW0h079469@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Mon Jun 12 16:31:32 2017
New Revision: 319855
URL: https://svnweb.freebsd.org/changeset/base/319855

Log:
  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 after:	1 month
  MFC with:	r319714, r319854
  Reported by:	ngie
  Submitted by:	shivansh
  Differential Revision:	D11159 (part of a larger diff)
  Sponsored by:	Google, Inc (GSoC 2017)

Modified:
  head/bin/ln/tests/ln_test.sh

Modified: head/bin/ln/tests/ln_test.sh
==============================================================================
--- head/bin/ln/tests/ln_test.sh	Mon Jun 12 14:54:59 2017	(r319854)
+++ head/bin/ln/tests/ln_test.sh	Mon Jun 12 16:31:32 2017	(r319855)
@@ -50,7 +50,8 @@ L_flag_body()
         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_check -o inline:'Symbolic Link\n' stat -f %SHT B
+        atf_check -o inline:'A\n' readlink B
 }
 
 atf_test_case P_flag
@@ -130,7 +131,8 @@ 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 -o inline:'Symbolic Link\n' stat -f %SHT C
+        atf_check -o inline:'B\n' readlink C
 }
 
 atf_test_case snf_flag_dir
@@ -144,7 +146,8 @@ 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 -o inline:'Symbolic Link\n' stat -f %SHT C
+        atf_check -o inline:'B\n' readlink C
 }
 
 atf_test_case sf_flag
@@ -160,7 +163,8 @@ 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_check -o inline:'Symbolic Link\n' stat -f %SHT B
+        atf_check -o inline:'A\n' readlink B
 }
 
 atf_test_case s_flag
@@ -174,7 +178,8 @@ 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_check -o inline:'Symbolic Link\n' stat -f %SHT B
+        atf_check -o inline:'A\n' readlink B
 }
 
 atf_test_case s_flag_broken
@@ -187,7 +192,8 @@ s_flag_broken_head()
 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 -o inline:'Symbolic Link\n' stat -f %SHT B
+        atf_check -o inline:'A\n' readlink B
 }
 
 atf_test_case sw_flag
@@ -201,7 +207,8 @@ 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 -o inline:'Symbolic Link\n' stat -f %SHT B
+        atf_check -o inline:'A\n' readlink B
 }
 
 atf_init_test_cases()



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706121631.v5CGVW0h079469>