1# 2# Copyright 2017, Conrad Meyer <cem@FreeBSD.org>. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: 7# 8# * Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# * Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25# 26# $FreeBSD$ 27# 28 29atf_test_case find_newer_link 30find_newer_link_head() 31{ 32 atf_set "descr" "Verifies that -newer correctly uses a symlink, " \ 33 "rather than its target, for comparison" 34} 35find_newer_link_body() 36{ 37 atf_check -s exit:0 mkdir test 38 atf_check -s exit:0 ln -s file1 test/link 39 atf_check -s exit:0 sleep 1.1 40 atf_check -s exit:0 touch test/file2 41 atf_check -s exit:0 sleep 1.1 42 atf_check -s exit:0 touch test/file1 43 44 # find(1) should evaluate 'link' as a symlink rather than its target 45 # (with -P / without -L flags). Since link was created first, the 46 # other two files should be newer. 47 echo -e "test\ntest/file1\ntest/file2" > expout 48 atf_check -s exit:0 -o save:output find test -newer test/link 49 atf_check -s exit:0 -o file:expout sort < output 50} 51 52atf_test_case find_samefile_link 53find_samefile_link_head() 54{ 55 atf_set "descr" "Verifies that -samefile correctly uses a symlink, " \ 56 "rather than its target, for comparison" 57} 58find_samefile_link_body() 59{ 60 atf_check -s exit:0 mkdir test 61 atf_check -s exit:0 touch test/file3 62 atf_check -s exit:0 ln -s file3 test/link2 63 64 # find(1) should evaluate 'link' as a symlink rather than its target 65 # (with -P / without -L flags). 66 atf_check -s exit:0 -o "inline:test/link2\n" find test -samefile test/link2 67} 68 69atf_init_test_cases() 70{ 71 atf_add_test_case find_newer_link 72 atf_add_test_case find_samefile_link 73} 74