1272343Sngie# Copyright 2012 Google Inc.
2272343Sngie# All rights reserved.
3272343Sngie#
4272343Sngie# Redistribution and use in source and binary forms, with or without
5272343Sngie# modification, are permitted provided that the following conditions are
6272343Sngie# met:
7272343Sngie#
8272343Sngie# * Redistributions of source code must retain the above copyright
9272343Sngie#   notice, this list of conditions and the following disclaimer.
10272343Sngie# * Redistributions in binary form must reproduce the above copyright
11272343Sngie#   notice, this list of conditions and the following disclaimer in the
12272343Sngie#   documentation and/or other materials provided with the distribution.
13272343Sngie# * Neither the name of Google Inc. nor the names of its contributors
14272343Sngie#   may be used to endorse or promote products derived from this software
15272343Sngie#   without specific prior written permission.
16272343Sngie#
17272343Sngie# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18272343Sngie# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19272343Sngie# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20272343Sngie# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21272343Sngie# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22272343Sngie# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23272343Sngie# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24272343Sngie# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25272343Sngie# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26272343Sngie# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27272343Sngie# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28272343Sngie
29272343Sngieatf_test_case makeconf__ok
30272343Sngiemakeconf__ok_body() {
31272343Sngie	cat >Makefile <<EOF
32272343SngieA_TEST_CONFIG_VARIABLE = not overriden
33272343Sngie
34272343Sngie.PHONY: show-config-var
35272343Sngieshow-config-var:
36272343Sngie	@echo \${A_TEST_CONFIG_VARIABLE}
37272343Sngie
38272343Sngie.include <bsd.own.mk>
39272343SngieEOF
40272343Sngie
41272343Sngie	echo >empty.conf
42272343Sngie	cat >custom.conf <<EOF
43272343SngieA_TEST_CONFIG_VARIABLE = 'a value'
44272343SngieEOF
45272343Sngie	atf_check -o inline:'not overriden\n' \
46272343Sngie	    make MAKECONF="$(pwd)/empty.conf" show-config-var
47272343Sngie	atf_check -o inline:'a value\n' \
48272343Sngie	    make MAKECONF="$(pwd)/custom.conf" show-config-var
49272343Sngie}
50272343Sngie
51272343Sngieatf_test_case makeconf__missing
52272343Sngiemakeconf__missing_body() {
53272343Sngie	cat >Makefile <<EOF
54272343Sngie.PHONY: hello
55272343Sngiehello:
56272343Sngie	@echo 'Did not error out on a missing file!'
57272343Sngie
58272343Sngie.include <bsd.own.mk>
59272343SngieEOF
60272343Sngie
61272343Sngie	echo >empty.conf
62272343Sngie	cat >custom.conf <<EOF
63272343SngieA_TEST_CONFIG_VARIABLE = 'a value'
64272343SngieEOF
65272343Sngie	atf_check -o inline:'Did not error out on a missing file!\n' \
66272343Sngie	    make MAKECONF="$(pwd)/non-existent.conf" hello
67272343Sngie}
68272343Sngie
69272343Sngieatf_init_test_cases() {
70272343Sngie	atf_add_test_case makeconf__ok
71272343Sngie	atf_add_test_case makeconf__missing
72272343Sngie}
73