2 # Copyright 2017, Conrad Meyer <cem@FreeBSD.org>.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
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.
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.
29 atf_test_case find_newer_link
30 find_newer_link_head()
32 atf_set "descr" "Verifies that -newer correctly uses a symlink, " \
33 "rather than its target, for comparison"
35 find_newer_link_body()
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 touch -d 2017-12-31T10:00:00Z -h test/link
40 atf_check -s exit:0 touch -d 2017-12-31T11:00:00Z test/file2
41 atf_check -s exit:0 touch -d 2017-12-31T12:00:00Z test/file1
43 # find(1) should evaluate 'link' as a symlink rather than its target
44 # (with -P / without -L flags). Since link was created first, the
45 # other two files should be newer.
46 echo -e "test\ntest/file1\ntest/file2" > expout
47 atf_check -s exit:0 -o save:output find test -newer test/link
48 atf_check -s exit:0 -o file:expout sort < output
51 atf_test_case find_samefile_link
52 find_samefile_link_head()
54 atf_set "descr" "Verifies that -samefile correctly uses a symlink, " \
55 "rather than its target, for comparison"
57 find_samefile_link_body()
59 atf_check -s exit:0 mkdir test
60 atf_check -s exit:0 touch test/file3
61 atf_check -s exit:0 ln -s file3 test/link2
63 # find(1) should evaluate 'link' as a symlink rather than its target
64 # (with -P / without -L flags).
65 atf_check -s exit:0 -o "inline:test/link2\n" find test -samefile test/link2
70 atf_add_test_case find_newer_link
71 atf_add_test_case find_samefile_link