]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/cmp/tests/cmp_test2.sh
Fix handling of rights on stdio streams, take two.
[FreeBSD/FreeBSD.git] / usr.bin / cmp / tests / cmp_test2.sh
1 # Copyright (c) 2017 Alan Somers
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7 # 1. Redistributions of source code must retain the above copyright
8 #    notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 #    notice, this list of conditions and the following disclaimer in the
11 #    documentation and/or other materials provided with the distribution.
12 #
13 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
14 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
15 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
17 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 # POSSIBILITY OF SUCH DAMAGE.
24 #
25 # $FreeBSD$
26
27 atf_test_case special
28 special_head() {
29         atf_set "descr" "Test cmp(1)'s handling of non-regular files"
30 }
31 special_body() {
32         echo 0123456789abcdef > a
33         echo 0123456789abcdeg > b
34         atf_check -s exit:0 -o empty -e empty -x "cat a | cmp a -"
35         atf_check -s exit:0 -o empty -e empty -x "cat a | cmp - a"
36         atf_check -s exit:1 -o not-empty -e empty -x "cat b | cmp a -"
37         atf_check -s exit:1 -o not-empty -e empty -x "cat b | cmp - a"
38
39         atf_check -s exit:0 -o empty -e empty -x "cmp a a <&-"
40 }
41
42 atf_test_case symlink
43 symlink_head() {
44         atf_set "descr" "Test cmp(1)'s handling of symlinks"
45 }
46 symlink_body() {
47         echo 0123456789abcdef > a
48         echo 0123456789abcdeg > b
49         ln -s a a.lnk
50         ln -s b b.lnk
51         ln -s a a2.lnk
52         cp a adup
53         ln -s adup adup.lnk
54         atf_check -s exit:0 cmp a a.lnk
55         atf_check -s exit:0 cmp a.lnk a
56         atf_check -s not-exit:0 -o ignore cmp a b.lnk
57         atf_check -s not-exit:0 -o ignore cmp b.lnk a
58         atf_check -s not-exit:0 -o ignore -e ignore cmp -h a a.lnk
59         atf_check -s not-exit:0 -o ignore -e ignore cmp -h a.lnk a
60         atf_check -s exit:0 cmp -h a.lnk a2.lnk
61         atf_check -s not-exit:0 -o ignore -e ignore cmp -h a.lnk adup.lnk
62 }
63
64 atf_init_test_cases()
65 {
66         atf_add_test_case special
67         atf_add_test_case symlink
68 }