t_make.sh revision 1.1 1 1.1 jruoho # $NetBSD: t_make.sh,v 1.1 2012/03/17 16:33:14 jruoho Exp $
2 1.1 jruoho #
3 1.1 jruoho # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
4 1.1 jruoho # All rights reserved.
5 1.1 jruoho #
6 1.1 jruoho # Redistribution and use in source and binary forms, with or without
7 1.1 jruoho # modification, are permitted provided that the following conditions
8 1.1 jruoho # are met:
9 1.1 jruoho # 1. Redistributions of source code must retain the above copyright
10 1.1 jruoho # notice, this list of conditions and the following disclaimer.
11 1.1 jruoho # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 jruoho # notice, this list of conditions and the following disclaimer in the
13 1.1 jruoho # documentation and/or other materials provided with the distribution.
14 1.1 jruoho #
15 1.1 jruoho # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 jruoho # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 jruoho # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 jruoho # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 jruoho # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 jruoho # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 jruoho # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 jruoho # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 jruoho # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 jruoho # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 jruoho # POSSIBILITY OF SUCH DAMAGE.
26 1.1 jruoho #
27 1.1 jruoho
28 1.1 jruoho # Executes make and compares the output to a golden file.
29 1.1 jruoho run_and_check()
30 1.1 jruoho {
31 1.1 jruoho local name="${1}"; shift
32 1.1 jruoho
33 1.1 jruoho local srcdir="$(atf_get_srcdir)"
34 1.1 jruoho atf_check -o file:"${srcdir}/d_${name}.out" -x \
35 1.1 jruoho "make -k -f ${srcdir}/d_${name}.mk 2>&1 | sed -e 's,${srcdir}/d_,,'"
36 1.1 jruoho }
37 1.1 jruoho
38 1.1 jruoho # Defines a test case for make(1), parsing a given file and comparing the
39 1.1 jruoho # output to prerecorded results.
40 1.1 jruoho test_case()
41 1.1 jruoho {
42 1.1 jruoho local name="${1}"; shift
43 1.1 jruoho local descr="${1}"; shift
44 1.1 jruoho
45 1.1 jruoho atf_test_case "${name}"
46 1.1 jruoho eval "${name}_head() { \
47 1.1 jruoho atf_set descr '${descr}'; \
48 1.1 jruoho }"
49 1.1 jruoho eval "${name}_body() { \
50 1.1 jruoho run_and_check '${name}'; \
51 1.1 jruoho }"
52 1.1 jruoho }
53 1.1 jruoho
54 1.1 jruoho test_case comment "Checks comments (PR/17732, PR/30536)"
55 1.1 jruoho test_case cond1 "Checks conditionals (PR/24420)"
56 1.1 jruoho test_case dotwait "Checks .WAIT"
57 1.1 jruoho test_case export "Checks .export of provided variables"
58 1.1 jruoho test_case export_all "Checks .export of all global variables"
59 1.1 jruoho test_case moderrs "Checks correct handling of errors in modifiers usage"
60 1.1 jruoho test_case modmatch "Checks modifier :M"
61 1.1 jruoho test_case modmisc "Checks modifiers specified in variables"
62 1.1 jruoho test_case modorder "Checks modifier :Ox"
63 1.1 jruoho test_case modts "Checks modifier :ts"
64 1.1 jruoho test_case modword "Checks modifier :[]"
65 1.1 jruoho test_case posix "Checks conformance to POSIX"
66 1.1 jruoho test_case qequals "Checks operator ?="
67 1.1 jruoho test_case ternary "Checks ternary modifier"
68 1.1 jruoho test_case varcmd "Checks behavior of command line variable assignments"
69 1.1 jruoho test_case unmatchedvarparen "Checks $ ( ) matches"
70 1.1 jruoho
71 1.1 jruoho atf_init_test_cases()
72 1.1 jruoho {
73 1.1 jruoho atf_add_test_case comment
74 1.1 jruoho atf_add_test_case cond1
75 1.1 jruoho atf_add_test_case dotwait
76 1.1 jruoho atf_add_test_case export
77 1.1 jruoho atf_add_test_case export_all
78 1.1 jruoho atf_add_test_case moderrs
79 1.1 jruoho atf_add_test_case modmatch
80 1.1 jruoho atf_add_test_case modmisc
81 1.1 jruoho atf_add_test_case modorder
82 1.1 jruoho atf_add_test_case modts
83 1.1 jruoho atf_add_test_case modword
84 1.1 jruoho atf_add_test_case posix
85 1.1 jruoho atf_add_test_case qequals
86 1.1 jruoho atf_add_test_case ternary
87 1.1 jruoho atf_add_test_case varcmd
88 1.1 jruoho atf_add_test_case unmatchedvarparen
89 1.1 jruoho }
90