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