1311572Sasomers# Copyright (c) 2017 Alan Somers
2311572Sasomers# All rights reserved.
3311572Sasomers#
4311572Sasomers# Redistribution and use in source and binary forms, with or without
5311572Sasomers# modification, are permitted provided that the following conditions
6311572Sasomers# are met:
7311572Sasomers# 1. Redistributions of source code must retain the above copyright
8311572Sasomers#    notice, this list of conditions and the following disclaimer.
9311572Sasomers# 2. Redistributions in binary form must reproduce the above copyright
10311572Sasomers#    notice, this list of conditions and the following disclaimer in the
11311572Sasomers#    documentation and/or other materials provided with the distribution.
12311572Sasomers#
13311572Sasomers# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
14311572Sasomers# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
15311572Sasomers# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16311572Sasomers# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
17311572Sasomers# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18311572Sasomers# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19311572Sasomers# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20311572Sasomers# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21311572Sasomers# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22311572Sasomers# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23311572Sasomers# POSSIBILITY OF SUCH DAMAGE.
24311572Sasomers#
25311572Sasomers# $FreeBSD: stable/10/usr.bin/cmp/tests/cmp_test2.sh 314425 2017-02-28 22:18:05Z asomers $
26311572Sasomers
27311572Sasomersatf_test_case special
28311572Sasomersspecial_head() {
29311572Sasomers	atf_set "descr" "Test cmp(1)'s handling of non-regular files"
30311572Sasomers}
31311572Sasomersspecial_body() {
32311572Sasomers	echo 0123456789abcdef > a
33311572Sasomers	echo 0123456789abcdeg > b
34311572Sasomers	cat a | atf_check -s exit:0 cmp a -
35311572Sasomers	cat a | atf_check -s exit:0 cmp - a
36311572Sasomers	cat b | atf_check -s not-exit:0 cmp a -
37311572Sasomers	cat b | atf_check -s not-exit:0 cmp - a
38311572Sasomers	true
39311572Sasomers}
40311572Sasomers
41311572Sasomersatf_test_case symlink
42311572Sasomerssymlink_head() {
43311572Sasomers	atf_set "descr" "Test cmp(1)'s handling of symlinks"
44311572Sasomers}
45311572Sasomerssymlink_body() {
46311572Sasomers	echo 0123456789abcdef > a
47311572Sasomers	echo 0123456789abcdeg > b
48311572Sasomers	ln -s a a.lnk
49311572Sasomers	ln -s b b.lnk
50311572Sasomers	ln -s a a2.lnk
51311572Sasomers	cp a adup
52311572Sasomers	ln -s adup adup.lnk
53311572Sasomers	atf_check -s exit:0 cmp a a.lnk
54311572Sasomers	atf_check -s exit:0 cmp a.lnk a
55311572Sasomers	atf_check -s not-exit:0 -o ignore cmp a b.lnk
56311572Sasomers	atf_check -s not-exit:0 -o ignore cmp b.lnk a
57311572Sasomers	atf_check -s not-exit:0 -o ignore -e ignore cmp -h a a.lnk
58311572Sasomers	atf_check -s not-exit:0 -o ignore -e ignore cmp -h a.lnk a
59311572Sasomers	atf_check -s exit:0 cmp -h a.lnk a2.lnk
60311572Sasomers	atf_check -s not-exit:0 -o ignore -e ignore cmp -h a.lnk adup.lnk
61311572Sasomers}
62311572Sasomers
63311572Sasomersatf_init_test_cases()
64311572Sasomers{
65311572Sasomers	atf_add_test_case special
66311572Sasomers	atf_add_test_case symlink
67311572Sasomers}
68