1*57718be8SEnji Cooper# $NetBSD: t_mkdep.sh,v 1.4 2012/08/26 22:37:19 jmmv Exp $ 2*57718be8SEnji Cooper# 3*57718be8SEnji Cooper# Copyright (c) 2011 The NetBSD Foundation, Inc. 4*57718be8SEnji Cooper# All rights reserved. 5*57718be8SEnji Cooper# 6*57718be8SEnji Cooper# This code is derived from software contributed to The NetBSD Foundation 7*57718be8SEnji Cooper# by Nicolas Joly. 8*57718be8SEnji Cooper# 9*57718be8SEnji Cooper# Redistribution and use in source and binary forms, with or without 10*57718be8SEnji Cooper# modification, are permitted provided that the following conditions 11*57718be8SEnji Cooper# are met: 12*57718be8SEnji Cooper# 1. Redistributions of source code must retain the above copyright 13*57718be8SEnji Cooper# notice, this list of conditions and the following disclaimer. 14*57718be8SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright 15*57718be8SEnji Cooper# notice, this list of conditions and the following disclaimer in the 16*57718be8SEnji Cooper# documentation and/or other materials provided with the distribution. 17*57718be8SEnji Cooper# 18*57718be8SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19*57718be8SEnji Cooper# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20*57718be8SEnji Cooper# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*57718be8SEnji Cooper# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22*57718be8SEnji Cooper# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*57718be8SEnji Cooper# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*57718be8SEnji Cooper# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*57718be8SEnji Cooper# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*57718be8SEnji Cooper# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*57718be8SEnji Cooper# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*57718be8SEnji Cooper# POSSIBILITY OF SUCH DAMAGE. 29*57718be8SEnji Cooper# 30*57718be8SEnji Cooper 31*57718be8SEnji Cooperatf_test_case prefix 32*57718be8SEnji Cooperprefix_head() { 33*57718be8SEnji Cooper atf_set "descr" "Test adding a prefix to a single target" 34*57718be8SEnji Cooper atf_set "require.progs" "mkdep cc" 35*57718be8SEnji Cooper} 36*57718be8SEnji Cooperprefix_body() { 37*57718be8SEnji Cooper 38*57718be8SEnji Cooper atf_check touch sample.c 39*57718be8SEnji Cooper 40*57718be8SEnji Cooper atf_check mkdep -f sample.d -P some/path/ sample.c 41*57718be8SEnji Cooper atf_check -o ignore grep '^some/path/sample.o:' sample.d 42*57718be8SEnji Cooper} 43*57718be8SEnji Cooper 44*57718be8SEnji Cooperatf_test_case suffixes 45*57718be8SEnji Coopersuffixes_head() { 46*57718be8SEnji Cooper atf_set "descr" "Test suffixes list" 47*57718be8SEnji Cooper atf_set "require.progs" "mkdep cc" 48*57718be8SEnji Cooper} 49*57718be8SEnji Coopersuffixes_body() { 50*57718be8SEnji Cooper 51*57718be8SEnji Cooper atf_check touch sample.c 52*57718be8SEnji Cooper 53*57718be8SEnji Cooper # No list 54*57718be8SEnji Cooper atf_check mkdep -f sample.d sample.c 55*57718be8SEnji Cooper atf_check -o ignore grep '^sample.o:' sample.d 56*57718be8SEnji Cooper 57*57718be8SEnji Cooper # Suffix list 58*57718be8SEnji Cooper atf_check mkdep -f sample.d -s '.a .b' sample.c 59*57718be8SEnji Cooper atf_check -o ignore grep '^sample.b sample.a:' sample.d 60*57718be8SEnji Cooper 61*57718be8SEnji Cooper # Empty list 62*57718be8SEnji Cooper atf_check mkdep -f sample.d -s '' sample.c 63*57718be8SEnji Cooper atf_check -o ignore grep '^sample:' sample.d 64*57718be8SEnji Cooper} 65*57718be8SEnji Cooper 66*57718be8SEnji Cooperatf_test_case prefix_and_suffixes 67*57718be8SEnji Cooperprefix_and_suffixes_head() { 68*57718be8SEnji Cooper atf_set "descr" "Test the combination of a prefix and suffixes" 69*57718be8SEnji Cooper atf_set "require.progs" "mkdep cc" 70*57718be8SEnji Cooper} 71*57718be8SEnji Cooperprefix_and_suffixes_body() { 72*57718be8SEnji Cooper 73*57718be8SEnji Cooper atf_check touch sample.c 74*57718be8SEnji Cooper 75*57718be8SEnji Cooper atf_check mkdep -f sample.d -s '.a .b' -P c/d sample.c 76*57718be8SEnji Cooper atf_check -o ignore grep '^c/dsample.b c/dsample.a:' sample.d 77*57718be8SEnji Cooper} 78*57718be8SEnji Cooper 79*57718be8SEnji Cooperatf_init_test_cases() { 80*57718be8SEnji Cooper atf_add_test_case prefix 81*57718be8SEnji Cooper atf_add_test_case suffixes 82*57718be8SEnji Cooper atf_add_test_case prefix_and_suffixes 83*57718be8SEnji Cooper} 84