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 27atf_test_case special 28special_head() { 29 atf_set "descr" "Test cmp(1)'s handling of non-regular files" 30} 31special_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 40atf_test_case symlink 41symlink_head() { 42 atf_set "descr" "Test cmp(1)'s handling of symlinks" 43} 44symlink_body() { 45 echo 0123456789abcdef > a 46 echo 0123456789abcdeg > b 47 ln -s a a.lnk 48 ln -s b b.lnk 49 ln -s a a2.lnk 50 cp a adup 51 ln -s adup adup.lnk 52 atf_check -s exit:0 cmp a a.lnk 53 atf_check -s exit:0 cmp a.lnk a 54 atf_check -s not-exit:0 -o ignore cmp a b.lnk 55 atf_check -s not-exit:0 -o ignore cmp b.lnk a 56 atf_check -s not-exit:0 -o ignore -e ignore cmp -h a a.lnk 57 atf_check -s not-exit:0 -o ignore -e ignore cmp -h a.lnk a 58 atf_check -s exit:0 cmp -h a.lnk a2.lnk 59 atf_check -s not-exit:0 -o ignore -e ignore cmp -h a.lnk adup.lnk 60} 61 62atf_init_test_cases() 63{ 64 atf_add_test_case special 65 atf_add_test_case symlink 66} 67