xref: /netbsd/tests/usr.bin/diff/t_diff.sh (revision 7d193f58)
1*7d193f58Sjruoho# $NetBSD: t_diff.sh,v 1.3 2012/03/13 05:40:00 jruoho Exp $
20a129f7eSjruoho#
30a129f7eSjruoho# Copyright (c) 2011 The NetBSD Foundation, Inc.
40a129f7eSjruoho# All rights reserved.
50a129f7eSjruoho#
60a129f7eSjruoho# This code is derived from software contributed to The NetBSD Foundation
70a129f7eSjruoho# by Jukka Ruohonen.
80a129f7eSjruoho#
90a129f7eSjruoho# Redistribution and use in source and binary forms, with or without
100a129f7eSjruoho# modification, are permitted provided that the following conditions
110a129f7eSjruoho# are met:
120a129f7eSjruoho# 1. Redistributions of source code must retain the above copyright
130a129f7eSjruoho#    notice, this list of conditions and the following disclaimer.
140a129f7eSjruoho# 2. Redistributions in binary form must reproduce the above copyright
150a129f7eSjruoho#    notice, this list of conditions and the following disclaimer in the
160a129f7eSjruoho#    documentation and/or other materials provided with the distribution.
170a129f7eSjruoho#
180a129f7eSjruoho# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
190a129f7eSjruoho# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
200a129f7eSjruoho# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
210a129f7eSjruoho# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
220a129f7eSjruoho# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
230a129f7eSjruoho# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
240a129f7eSjruoho# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
250a129f7eSjruoho# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
260a129f7eSjruoho# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
270a129f7eSjruoho# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
280a129f7eSjruoho# POSSIBILITY OF SUCH DAMAGE.
290a129f7eSjruoho#
300a129f7eSjruoho
310a129f7eSjruohoatf_test_case mallocv
320a129f7eSjruohomallocv_head() {
33*7d193f58Sjruoho	atf_set "descr" "Test diff(1) with MALLOC_OPTIONS=V (cf. PR bin/26453)"
340a129f7eSjruoho}
350a129f7eSjruoho
360a129f7eSjruohomallocv_body() {
370a129f7eSjruoho
380a129f7eSjruoho	atf_check -s ignore \
390a129f7eSjruoho		-e not-inline:"diff: memory exhausted\n" \
400a129f7eSjruoho		-x "env MALLOC_OPTIONS=V diff " \
410a129f7eSjruoho		   "$(atf_get_srcdir)/d_mallocv1.in" \
420a129f7eSjruoho		   "$(atf_get_srcdir)/d_mallocv2.in"
430a129f7eSjruoho}
440a129f7eSjruoho
450a129f7eSjruohoatf_test_case nomallocv
460a129f7eSjruohonomallocv_head() {
470a129f7eSjruoho	atf_set "descr" "Test diff(1) with no MALLOC_OPTIONS=V"
480a129f7eSjruoho}
490a129f7eSjruoho
500a129f7eSjruohonomallocv_body() {
510a129f7eSjruoho
520a129f7eSjruoho	atf_check -s exit:0 \
530a129f7eSjruoho		-e inline:"" \
540a129f7eSjruoho		-x "diff " \
550a129f7eSjruoho		   "$(atf_get_srcdir)/d_mallocv1.in" \
560a129f7eSjruoho		   "$(atf_get_srcdir)/d_mallocv2.in"
570a129f7eSjruoho}
580a129f7eSjruoho
590a129f7eSjruohoatf_test_case same
600a129f7eSjruohosame_head() {
610a129f7eSjruoho	atf_set "descr" "Test diff(1) with identical files"
620a129f7eSjruoho}
630a129f7eSjruoho
640a129f7eSjruohosame_body() {
650a129f7eSjruoho
660a129f7eSjruoho	atf_check -s exit:0 \
670a129f7eSjruoho		-e inline:"" \
680a129f7eSjruoho		-x "diff $(atf_get_srcdir)/t_diff $(atf_get_srcdir)/t_diff"
690a129f7eSjruoho}
700a129f7eSjruoho
710a129f7eSjruohoatf_init_test_cases() {
720a129f7eSjruoho	atf_add_test_case mallocv
730a129f7eSjruoho	atf_add_test_case nomallocv
740a129f7eSjruoho	atf_add_test_case same
750a129f7eSjruoho}
76