1319834Sngie# 2319834Sngie# Copyright (c) 2017 Dell EMC 3319834Sngie# All rights reserved. 4319834Sngie# 5319834Sngie# Redistribution and use in source and binary forms, with or without 6319834Sngie# modification, are permitted provided that the following conditions 7319834Sngie# are met: 8319834Sngie# 1. Redistributions of source code must retain the above copyright 9319834Sngie# notice, this list of conditions and the following disclaimer. 10319834Sngie# 2. Redistributions in binary form must reproduce the above copyright 11319834Sngie# notice, this list of conditions and the following disclaimer in the 12319834Sngie# documentation and/or other materials provided with the distribution. 13319834Sngie# 14319834Sngie# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15319834Sngie# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16319834Sngie# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17319834Sngie# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18319834Sngie# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19319834Sngie# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20319834Sngie# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21319834Sngie# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22319834Sngie# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23319834Sngie# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24319834Sngie# SUCH DAMAGE. 25319834Sngie# 26319834Sngie# $FreeBSD: stable/10/usr.bin/stat/tests/readlink_test.sh 319834 2017-06-11 21:13:12Z ngie $ 27319834Sngie 28319834Sngieatf_test_case f_flag 29319834Sngiebasic_head() 30319834Sngie{ 31319834Sngie atf_set "descr" "Verify that calling readlink without any flags " \ 32319834Sngie "prints out the symlink target for a file" 33319834Sngie} 34319834Sngiebasic_body() 35319834Sngie{ 36319834Sngie atf_check ln -s foo bar 37319834Sngie atf_check -o inline:'foo\n' readlink bar 38319834Sngie} 39319834Sngie 40319834Sngieatf_test_case f_flag 41319834Sngief_flag_head() 42319834Sngie{ 43319834Sngie atf_set "descr" "Verify that calling readlink with -f will not emit " \ 44319834Sngie "an error message/exit with a non-zero code" 45319834Sngie} 46319834Sngief_flag_body() 47319834Sngie{ 48319834Sngie atf_check touch A.file 49319834Sngie atf_check ln -s nonexistent A.link 50319834Sngie atf_check -o inline:"nonexistent\n" \ 51319834Sngie -s exit:1 readlink A.file A.link 52319834Sngie atf_check -o inline:"$(realpath A.file)\n$PWD/nonexistent\n" \ 53319834Sngie -s exit:1 readlink -f A.file A.link 54319834Sngie} 55319834Sngie 56319834Sngieatf_test_case n_flag 57319834Sngien_flag_head() 58319834Sngie{ 59319834Sngie} 60319834Sngien_flag_body() 61319834Sngie{ 62319834Sngie atf_check ln -s nonexistent.A A 63319834Sngie atf_check ln -s nonexistent.B B 64319834Sngie atf_check -o 'inline:nonexistent.A\nnonexistent.B\n' readlink A B 65319834Sngie atf_check -o 'inline:nonexistent.Anonexistent.B' readlink -n A B 66319834Sngie} 67319834Sngie 68319834Sngieatf_init_test_cases() 69319834Sngie{ 70319834Sngie atf_add_test_case basic 71319834Sngie atf_add_test_case f_flag 72319834Sngie atf_add_test_case n_flag 73319834Sngie} 74