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