From owner-svn-src-head@freebsd.org Mon Jun 12 16:31:33 2017 Return-Path: Delivered-To: svn-src-head@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 8D83DBFFB1B; Mon, 12 Jun 2017 16:31:33 +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 5EFA975119; Mon, 12 Jun 2017 16:31:33 +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 v5CGVWj6079470; Mon, 12 Jun 2017 16:31:32 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5CGVW0h079469; Mon, 12 Jun 2017 16:31:32 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201706121631.v5CGVW0h079469@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 12 Jun 2017 16:31:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319855 - head/bin/ln/tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jun 2017 16:31:33 -0000 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()