1*21860bf9SEnji Cooper# 2*21860bf9SEnji Cooper# Copyright (c) 2017 Dell EMC 3*21860bf9SEnji Cooper# All rights reserved. 4*21860bf9SEnji Cooper# 5*21860bf9SEnji Cooper# Redistribution and use in source and binary forms, with or without 6*21860bf9SEnji Cooper# modification, are permitted provided that the following conditions 7*21860bf9SEnji Cooper# are met: 8*21860bf9SEnji Cooper# 1. Redistributions of source code must retain the above copyright 9*21860bf9SEnji Cooper# notice, this list of conditions and the following disclaimer. 10*21860bf9SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright 11*21860bf9SEnji Cooper# notice, this list of conditions and the following disclaimer in the 12*21860bf9SEnji Cooper# documentation and/or other materials provided with the distribution. 13*21860bf9SEnji Cooper# 14*21860bf9SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*21860bf9SEnji Cooper# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*21860bf9SEnji Cooper# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*21860bf9SEnji Cooper# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*21860bf9SEnji Cooper# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*21860bf9SEnji Cooper# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*21860bf9SEnji Cooper# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*21860bf9SEnji Cooper# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*21860bf9SEnji Cooper# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*21860bf9SEnji Cooper# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*21860bf9SEnji Cooper# SUCH DAMAGE. 25*21860bf9SEnji Cooper# 26*21860bf9SEnji Cooper# $FreeBSD$ 27*21860bf9SEnji Cooper 28*21860bf9SEnji Cooperatf_test_case f_flag 29*21860bf9SEnji Cooperbasic_head() 30*21860bf9SEnji Cooper{ 31*21860bf9SEnji Cooper atf_set "descr" "Verify that calling readlink without any flags " \ 32*21860bf9SEnji Cooper "prints out the symlink target for a file" 33*21860bf9SEnji Cooper} 34*21860bf9SEnji Cooperbasic_body() 35*21860bf9SEnji Cooper{ 36*21860bf9SEnji Cooper atf_check ln -s foo bar 37*21860bf9SEnji Cooper atf_check -o inline:'foo\n' readlink bar 38*21860bf9SEnji Cooper} 39*21860bf9SEnji Cooper 40*21860bf9SEnji Cooperatf_test_case f_flag 41*21860bf9SEnji Cooperf_flag_head() 42*21860bf9SEnji Cooper{ 43*21860bf9SEnji Cooper atf_set "descr" "Verify that calling readlink with -f will not emit " \ 44*21860bf9SEnji Cooper "an error message/exit with a non-zero code" 45*21860bf9SEnji Cooper} 46*21860bf9SEnji Cooperf_flag_body() 47*21860bf9SEnji Cooper{ 48*21860bf9SEnji Cooper atf_check touch A.file 49*21860bf9SEnji Cooper atf_check ln -s nonexistent A.link 50*21860bf9SEnji Cooper atf_check -o inline:"nonexistent\n" \ 51*21860bf9SEnji Cooper -s exit:1 readlink A.file A.link 52*21860bf9SEnji Cooper atf_check -o inline:"$(realpath A.file)\n$PWD/nonexistent\n" \ 53*21860bf9SEnji Cooper -s exit:1 readlink -f A.file A.link 54*21860bf9SEnji Cooper} 55*21860bf9SEnji Cooper 56*21860bf9SEnji Cooperatf_test_case n_flag 57*21860bf9SEnji Coopern_flag_head() 58*21860bf9SEnji Cooper{ 59*21860bf9SEnji Cooper} 60*21860bf9SEnji Coopern_flag_body() 61*21860bf9SEnji Cooper{ 62*21860bf9SEnji Cooper atf_check ln -s nonexistent.A A 63*21860bf9SEnji Cooper atf_check ln -s nonexistent.B B 64*21860bf9SEnji Cooper atf_check -o 'inline:nonexistent.A\nnonexistent.B\n' readlink A B 65*21860bf9SEnji Cooper atf_check -o 'inline:nonexistent.Anonexistent.B' readlink -n A B 66*21860bf9SEnji Cooper} 67*21860bf9SEnji Cooper 68*21860bf9SEnji Cooperatf_init_test_cases() 69*21860bf9SEnji Cooper{ 70*21860bf9SEnji Cooper atf_add_test_case basic 71*21860bf9SEnji Cooper atf_add_test_case f_flag 72*21860bf9SEnji Cooper atf_add_test_case n_flag 73*21860bf9SEnji Cooper} 74