t_basic.sh revision 272343
1181421Sedwin# $NetBSD: t_basic.sh,v 1.6 2012/10/15 17:49:58 njoly Exp $
2153761Swollman#
364499Swollman# Copyright (c) 2011 The NetBSD Foundation, Inc.
42742Swollman# All rights reserved.
52742Swollman#
62742Swollman# This code is derived from software contributed to The NetBSD Foundation
72742Swollman# by Jukka Ruohonen.
8158421Swollman#
92742Swollman# Redistribution and use in source and binary forms, with or without
10158421Swollman# modification, are permitted provided that the following conditions
11158421Swollman# are met:
122742Swollman# 1. Redistributions of source code must retain the above copyright
1386222Swollman#    notice, this list of conditions and the following disclaimer.
1420094Swollman# 2. Redistributions in binary form must reproduce the above copyright
1520094Swollman#    notice, this list of conditions and the following disclaimer in the
1620094Swollman#    documentation and/or other materials provided with the distribution.
1720094Swollman#
1820094Swollman# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19158421Swollman# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20158421Swollman# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2120094Swollman# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2219878Swollman# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2319878Swollman# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2419878Swollman# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2519878Swollman# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2619878Swollman# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2719878Swollman# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2819878Swollman# POSSIBILITY OF SUCH DAMAGE.
2919878Swollman#
3058787Sru
3158787Sruatf_test_case basic
3258787Srubasic_head() {
3358787Sru	atf_set "descr" "A basic test of unifdef(1) (PR bin/42628)"
3458787Sru	atf_set "require.progs" "unifdef"
3558787Sru}
3658787Sru
3758787Srubasic_body() {
3858787Sru
3958787Sru	atf_check -s ignore -o file:$(atf_get_srcdir)/d_basic.out \
4058787Sru		-x "unifdef -U__FreeBSD__ $(atf_get_srcdir)/d_basic.in"
4158787Sru}
4258787Sru
4358787Sruatf_test_case lastline
4458787Srulastline_head() {
4558787Sru	atf_set "descr" "Checks with directive on last line (PR bin/47068)"
4658787Sru}
4758787Sru
482742Swollmanlastline_body() {
492742Swollman
502742Swollman	# With newline after cpp directive
512742Swollman	printf '#ifdef foo\n#endif\n' >input
522742Swollman	atf_check -o file:input unifdef -Ubar input
532742Swollman
542742Swollman	# Without newline after cpp directive
5519878Swollman	printf '#ifdef foo\n#endif' >input
562742Swollman	atf_check -o file:input unifdef -Ubar input
572742Swollman}
582742Swollman
5919878Swollmanatf_init_test_cases() {
602742Swollman	atf_add_test_case basic
612742Swollman	atf_add_test_case lastline
62149514Swollman}
6321217Swollman