1*0a6a1f1dSLionel Sambuc //
2*0a6a1f1dSLionel Sambuc // Automated Testing Framework (atf)
3*0a6a1f1dSLionel Sambuc //
4*0a6a1f1dSLionel Sambuc // Copyright (c) 2010 The NetBSD Foundation, Inc.
5*0a6a1f1dSLionel Sambuc // All rights reserved.
6*0a6a1f1dSLionel Sambuc //
7*0a6a1f1dSLionel Sambuc // Redistribution and use in source and binary forms, with or without
8*0a6a1f1dSLionel Sambuc // modification, are permitted provided that the following conditions
9*0a6a1f1dSLionel Sambuc // are met:
10*0a6a1f1dSLionel Sambuc // 1. Redistributions of source code must retain the above copyright
11*0a6a1f1dSLionel Sambuc // notice, this list of conditions and the following disclaimer.
12*0a6a1f1dSLionel Sambuc // 2. Redistributions in binary form must reproduce the above copyright
13*0a6a1f1dSLionel Sambuc // notice, this list of conditions and the following disclaimer in the
14*0a6a1f1dSLionel Sambuc // documentation and/or other materials provided with the distribution.
15*0a6a1f1dSLionel Sambuc //
16*0a6a1f1dSLionel Sambuc // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17*0a6a1f1dSLionel Sambuc // CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18*0a6a1f1dSLionel Sambuc // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19*0a6a1f1dSLionel Sambuc // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20*0a6a1f1dSLionel Sambuc // IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21*0a6a1f1dSLionel Sambuc // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*0a6a1f1dSLionel Sambuc // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23*0a6a1f1dSLionel Sambuc // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24*0a6a1f1dSLionel Sambuc // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25*0a6a1f1dSLionel Sambuc // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26*0a6a1f1dSLionel Sambuc // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27*0a6a1f1dSLionel Sambuc // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*0a6a1f1dSLionel Sambuc //
29*0a6a1f1dSLionel Sambuc
30*0a6a1f1dSLionel Sambuc #include <atf-c++.hpp>
31*0a6a1f1dSLionel Sambuc
32*0a6a1f1dSLionel Sambuc #include "config.hpp"
33*0a6a1f1dSLionel Sambuc #include "config_file.hpp"
34*0a6a1f1dSLionel Sambuc #include "env.hpp"
35*0a6a1f1dSLionel Sambuc #include "test_helpers.hpp"
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel Sambuc namespace impl = tools::config_file;
38*0a6a1f1dSLionel Sambuc namespace detail = tools::config_file::detail;
39*0a6a1f1dSLionel Sambuc
40*0a6a1f1dSLionel Sambuc namespace {
41*0a6a1f1dSLionel Sambuc
42*0a6a1f1dSLionel Sambuc typedef std::map< std::string, std::string > vars_map;
43*0a6a1f1dSLionel Sambuc
44*0a6a1f1dSLionel Sambuc } // anonymous namespace
45*0a6a1f1dSLionel Sambuc
46*0a6a1f1dSLionel Sambuc namespace atf {
47*0a6a1f1dSLionel Sambuc namespace config {
48*0a6a1f1dSLionel Sambuc
49*0a6a1f1dSLionel Sambuc void __reinit(void);
50*0a6a1f1dSLionel Sambuc
51*0a6a1f1dSLionel Sambuc } // namespace config
52*0a6a1f1dSLionel Sambuc } // namespace atf
53*0a6a1f1dSLionel Sambuc
54*0a6a1f1dSLionel Sambuc // -------------------------------------------------------------------------
55*0a6a1f1dSLionel Sambuc // Tests for the "config" parser.
56*0a6a1f1dSLionel Sambuc // -------------------------------------------------------------------------
57*0a6a1f1dSLionel Sambuc
58*0a6a1f1dSLionel Sambuc class config_reader : protected detail::atf_config_reader {
59*0a6a1f1dSLionel Sambuc void
got_var(const std::string & name,const std::string & val)60*0a6a1f1dSLionel Sambuc got_var(const std::string& name, const std::string& val)
61*0a6a1f1dSLionel Sambuc {
62*0a6a1f1dSLionel Sambuc m_calls.push_back("got_var(" + name + ", " + val + ")");
63*0a6a1f1dSLionel Sambuc }
64*0a6a1f1dSLionel Sambuc
65*0a6a1f1dSLionel Sambuc void
got_eof(void)66*0a6a1f1dSLionel Sambuc got_eof(void)
67*0a6a1f1dSLionel Sambuc {
68*0a6a1f1dSLionel Sambuc m_calls.push_back("got_eof()");
69*0a6a1f1dSLionel Sambuc }
70*0a6a1f1dSLionel Sambuc
71*0a6a1f1dSLionel Sambuc public:
config_reader(std::istream & is)72*0a6a1f1dSLionel Sambuc config_reader(std::istream& is) :
73*0a6a1f1dSLionel Sambuc detail::atf_config_reader(is)
74*0a6a1f1dSLionel Sambuc {
75*0a6a1f1dSLionel Sambuc }
76*0a6a1f1dSLionel Sambuc
77*0a6a1f1dSLionel Sambuc void
read(void)78*0a6a1f1dSLionel Sambuc read(void)
79*0a6a1f1dSLionel Sambuc {
80*0a6a1f1dSLionel Sambuc atf_config_reader::read();
81*0a6a1f1dSLionel Sambuc }
82*0a6a1f1dSLionel Sambuc
83*0a6a1f1dSLionel Sambuc std::vector< std::string > m_calls;
84*0a6a1f1dSLionel Sambuc };
85*0a6a1f1dSLionel Sambuc
86*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_1);
ATF_TEST_CASE_BODY(config_1)87*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_1)
88*0a6a1f1dSLionel Sambuc {
89*0a6a1f1dSLionel Sambuc const char* input =
90*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
91*0a6a1f1dSLionel Sambuc "\n"
92*0a6a1f1dSLionel Sambuc ;
93*0a6a1f1dSLionel Sambuc
94*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
95*0a6a1f1dSLionel Sambuc "got_eof()",
96*0a6a1f1dSLionel Sambuc NULL
97*0a6a1f1dSLionel Sambuc };
98*0a6a1f1dSLionel Sambuc
99*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
100*0a6a1f1dSLionel Sambuc NULL
101*0a6a1f1dSLionel Sambuc };
102*0a6a1f1dSLionel Sambuc
103*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
104*0a6a1f1dSLionel Sambuc }
105*0a6a1f1dSLionel Sambuc
106*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_2);
ATF_TEST_CASE_BODY(config_2)107*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_2)
108*0a6a1f1dSLionel Sambuc {
109*0a6a1f1dSLionel Sambuc const char* input =
110*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
111*0a6a1f1dSLionel Sambuc "\n"
112*0a6a1f1dSLionel Sambuc "# This is a comment on a line of its own.\n"
113*0a6a1f1dSLionel Sambuc "# And this is another one.\n"
114*0a6a1f1dSLionel Sambuc "\n"
115*0a6a1f1dSLionel Sambuc " # Another after some whitespace.\n"
116*0a6a1f1dSLionel Sambuc "\n"
117*0a6a1f1dSLionel Sambuc "# The last one after an empty line.\n"
118*0a6a1f1dSLionel Sambuc ;
119*0a6a1f1dSLionel Sambuc
120*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
121*0a6a1f1dSLionel Sambuc "got_eof()",
122*0a6a1f1dSLionel Sambuc NULL
123*0a6a1f1dSLionel Sambuc };
124*0a6a1f1dSLionel Sambuc
125*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
126*0a6a1f1dSLionel Sambuc NULL
127*0a6a1f1dSLionel Sambuc };
128*0a6a1f1dSLionel Sambuc
129*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
130*0a6a1f1dSLionel Sambuc }
131*0a6a1f1dSLionel Sambuc
132*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_3);
ATF_TEST_CASE_BODY(config_3)133*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_3)
134*0a6a1f1dSLionel Sambuc {
135*0a6a1f1dSLionel Sambuc const char* input =
136*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
137*0a6a1f1dSLionel Sambuc "\n"
138*0a6a1f1dSLionel Sambuc "var1=value1\n"
139*0a6a1f1dSLionel Sambuc "var2 = value2\n"
140*0a6a1f1dSLionel Sambuc "var3 = value3\n"
141*0a6a1f1dSLionel Sambuc "var4 = value4\n"
142*0a6a1f1dSLionel Sambuc "\n"
143*0a6a1f1dSLionel Sambuc "var5=value5\n"
144*0a6a1f1dSLionel Sambuc " var6=value6\n"
145*0a6a1f1dSLionel Sambuc "\n"
146*0a6a1f1dSLionel Sambuc "var7 = \"This is a long value.\"\n"
147*0a6a1f1dSLionel Sambuc "var8 = \"Single-word\"\n"
148*0a6a1f1dSLionel Sambuc "var9 = \" Single-word \"\n"
149*0a6a1f1dSLionel Sambuc "var10 = Single-word\n"
150*0a6a1f1dSLionel Sambuc ;
151*0a6a1f1dSLionel Sambuc
152*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
153*0a6a1f1dSLionel Sambuc "got_var(var1, value1)",
154*0a6a1f1dSLionel Sambuc "got_var(var2, value2)",
155*0a6a1f1dSLionel Sambuc "got_var(var3, value3)",
156*0a6a1f1dSLionel Sambuc "got_var(var4, value4)",
157*0a6a1f1dSLionel Sambuc "got_var(var5, value5)",
158*0a6a1f1dSLionel Sambuc "got_var(var6, value6)",
159*0a6a1f1dSLionel Sambuc "got_var(var7, This is a long value.)",
160*0a6a1f1dSLionel Sambuc "got_var(var8, Single-word)",
161*0a6a1f1dSLionel Sambuc "got_var(var9, Single-word )",
162*0a6a1f1dSLionel Sambuc "got_var(var10, Single-word)",
163*0a6a1f1dSLionel Sambuc "got_eof()",
164*0a6a1f1dSLionel Sambuc NULL
165*0a6a1f1dSLionel Sambuc };
166*0a6a1f1dSLionel Sambuc
167*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
168*0a6a1f1dSLionel Sambuc NULL
169*0a6a1f1dSLionel Sambuc };
170*0a6a1f1dSLionel Sambuc
171*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
172*0a6a1f1dSLionel Sambuc }
173*0a6a1f1dSLionel Sambuc
174*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_4);
ATF_TEST_CASE_BODY(config_4)175*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_4)
176*0a6a1f1dSLionel Sambuc {
177*0a6a1f1dSLionel Sambuc const char* input =
178*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
179*0a6a1f1dSLionel Sambuc "\n"
180*0a6a1f1dSLionel Sambuc "foo = bar # A comment.\n"
181*0a6a1f1dSLionel Sambuc ;
182*0a6a1f1dSLionel Sambuc
183*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
184*0a6a1f1dSLionel Sambuc "got_var(foo, bar)",
185*0a6a1f1dSLionel Sambuc "got_eof()",
186*0a6a1f1dSLionel Sambuc NULL
187*0a6a1f1dSLionel Sambuc };
188*0a6a1f1dSLionel Sambuc
189*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
190*0a6a1f1dSLionel Sambuc NULL
191*0a6a1f1dSLionel Sambuc };
192*0a6a1f1dSLionel Sambuc
193*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
194*0a6a1f1dSLionel Sambuc }
195*0a6a1f1dSLionel Sambuc
196*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_50);
ATF_TEST_CASE_BODY(config_50)197*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_50)
198*0a6a1f1dSLionel Sambuc {
199*0a6a1f1dSLionel Sambuc const char* input =
200*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
201*0a6a1f1dSLionel Sambuc "\n"
202*0a6a1f1dSLionel Sambuc "foo\n"
203*0a6a1f1dSLionel Sambuc ;
204*0a6a1f1dSLionel Sambuc
205*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
206*0a6a1f1dSLionel Sambuc NULL
207*0a6a1f1dSLionel Sambuc };
208*0a6a1f1dSLionel Sambuc
209*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
210*0a6a1f1dSLionel Sambuc "3: Unexpected token `<<NEWLINE>>'; expected equal sign",
211*0a6a1f1dSLionel Sambuc NULL
212*0a6a1f1dSLionel Sambuc };
213*0a6a1f1dSLionel Sambuc
214*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
215*0a6a1f1dSLionel Sambuc }
216*0a6a1f1dSLionel Sambuc
217*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_51);
ATF_TEST_CASE_BODY(config_51)218*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_51)
219*0a6a1f1dSLionel Sambuc {
220*0a6a1f1dSLionel Sambuc const char* input =
221*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
222*0a6a1f1dSLionel Sambuc "\n"
223*0a6a1f1dSLionel Sambuc "foo bar\n"
224*0a6a1f1dSLionel Sambuc "baz\n"
225*0a6a1f1dSLionel Sambuc ;
226*0a6a1f1dSLionel Sambuc
227*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
228*0a6a1f1dSLionel Sambuc NULL
229*0a6a1f1dSLionel Sambuc };
230*0a6a1f1dSLionel Sambuc
231*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
232*0a6a1f1dSLionel Sambuc "3: Unexpected token `bar'; expected equal sign",
233*0a6a1f1dSLionel Sambuc "4: Unexpected token `<<NEWLINE>>'; expected equal sign",
234*0a6a1f1dSLionel Sambuc NULL
235*0a6a1f1dSLionel Sambuc };
236*0a6a1f1dSLionel Sambuc
237*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
238*0a6a1f1dSLionel Sambuc }
239*0a6a1f1dSLionel Sambuc
240*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_52);
ATF_TEST_CASE_BODY(config_52)241*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_52)
242*0a6a1f1dSLionel Sambuc {
243*0a6a1f1dSLionel Sambuc const char* input =
244*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
245*0a6a1f1dSLionel Sambuc "\n"
246*0a6a1f1dSLionel Sambuc "foo =\n"
247*0a6a1f1dSLionel Sambuc "bar = # A comment.\n"
248*0a6a1f1dSLionel Sambuc ;
249*0a6a1f1dSLionel Sambuc
250*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
251*0a6a1f1dSLionel Sambuc NULL
252*0a6a1f1dSLionel Sambuc };
253*0a6a1f1dSLionel Sambuc
254*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
255*0a6a1f1dSLionel Sambuc "3: Unexpected token `<<NEWLINE>>'; expected word or quoted string",
256*0a6a1f1dSLionel Sambuc "4: Unexpected token `#'; expected word or quoted string",
257*0a6a1f1dSLionel Sambuc NULL
258*0a6a1f1dSLionel Sambuc };
259*0a6a1f1dSLionel Sambuc
260*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
261*0a6a1f1dSLionel Sambuc }
262*0a6a1f1dSLionel Sambuc
263*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_53);
ATF_TEST_CASE_BODY(config_53)264*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_53)
265*0a6a1f1dSLionel Sambuc {
266*0a6a1f1dSLionel Sambuc const char* input =
267*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
268*0a6a1f1dSLionel Sambuc "\n"
269*0a6a1f1dSLionel Sambuc "foo = \"Correct value\" # With comment.\n"
270*0a6a1f1dSLionel Sambuc "\n"
271*0a6a1f1dSLionel Sambuc "bar = # A comment.\n"
272*0a6a1f1dSLionel Sambuc "\n"
273*0a6a1f1dSLionel Sambuc "baz = \"Last variable\"\n"
274*0a6a1f1dSLionel Sambuc "\n"
275*0a6a1f1dSLionel Sambuc "# End of file.\n"
276*0a6a1f1dSLionel Sambuc ;
277*0a6a1f1dSLionel Sambuc
278*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
279*0a6a1f1dSLionel Sambuc "got_var(foo, Correct value)",
280*0a6a1f1dSLionel Sambuc NULL
281*0a6a1f1dSLionel Sambuc };
282*0a6a1f1dSLionel Sambuc
283*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
284*0a6a1f1dSLionel Sambuc "5: Unexpected token `#'; expected word or quoted string",
285*0a6a1f1dSLionel Sambuc NULL
286*0a6a1f1dSLionel Sambuc };
287*0a6a1f1dSLionel Sambuc
288*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
289*0a6a1f1dSLionel Sambuc }
290*0a6a1f1dSLionel Sambuc
291*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(config_54);
ATF_TEST_CASE_BODY(config_54)292*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(config_54)
293*0a6a1f1dSLionel Sambuc {
294*0a6a1f1dSLionel Sambuc const char* input =
295*0a6a1f1dSLionel Sambuc "Content-Type: application/X-atf-config; version=\"1\"\n"
296*0a6a1f1dSLionel Sambuc "\n"
297*0a6a1f1dSLionel Sambuc "foo = \"\n"
298*0a6a1f1dSLionel Sambuc "bar = \"text\n"
299*0a6a1f1dSLionel Sambuc "baz = \"te\\\"xt\n"
300*0a6a1f1dSLionel Sambuc "last = \"\\\"\n"
301*0a6a1f1dSLionel Sambuc ;
302*0a6a1f1dSLionel Sambuc
303*0a6a1f1dSLionel Sambuc const char* exp_calls[] = {
304*0a6a1f1dSLionel Sambuc NULL
305*0a6a1f1dSLionel Sambuc };
306*0a6a1f1dSLionel Sambuc
307*0a6a1f1dSLionel Sambuc const char* exp_errors[] = {
308*0a6a1f1dSLionel Sambuc "3: Missing double quotes before end of line",
309*0a6a1f1dSLionel Sambuc "4: Missing double quotes before end of line",
310*0a6a1f1dSLionel Sambuc "5: Missing double quotes before end of line",
311*0a6a1f1dSLionel Sambuc "6: Missing double quotes before end of line",
312*0a6a1f1dSLionel Sambuc NULL
313*0a6a1f1dSLionel Sambuc };
314*0a6a1f1dSLionel Sambuc
315*0a6a1f1dSLionel Sambuc do_parser_test< config_reader >(input, exp_calls, exp_errors);
316*0a6a1f1dSLionel Sambuc }
317*0a6a1f1dSLionel Sambuc
318*0a6a1f1dSLionel Sambuc // -------------------------------------------------------------------------
319*0a6a1f1dSLionel Sambuc // Tests for the free functions.
320*0a6a1f1dSLionel Sambuc // -------------------------------------------------------------------------
321*0a6a1f1dSLionel Sambuc
322*0a6a1f1dSLionel Sambuc ATF_TEST_CASE(merge_configs_both_empty);
ATF_TEST_CASE_HEAD(merge_configs_both_empty)323*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_HEAD(merge_configs_both_empty) {}
ATF_TEST_CASE_BODY(merge_configs_both_empty)324*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(merge_configs_both_empty) {
325*0a6a1f1dSLionel Sambuc vars_map lower, upper;
326*0a6a1f1dSLionel Sambuc
327*0a6a1f1dSLionel Sambuc ATF_REQUIRE(impl::merge_configs(lower, upper).empty());
328*0a6a1f1dSLionel Sambuc }
329*0a6a1f1dSLionel Sambuc
330*0a6a1f1dSLionel Sambuc ATF_TEST_CASE(merge_configs_lower_empty);
ATF_TEST_CASE_HEAD(merge_configs_lower_empty)331*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_HEAD(merge_configs_lower_empty) {}
ATF_TEST_CASE_BODY(merge_configs_lower_empty)332*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(merge_configs_lower_empty) {
333*0a6a1f1dSLionel Sambuc vars_map lower, upper;
334*0a6a1f1dSLionel Sambuc upper["var"] = "value";
335*0a6a1f1dSLionel Sambuc
336*0a6a1f1dSLionel Sambuc vars_map merged = impl::merge_configs(lower, upper);
337*0a6a1f1dSLionel Sambuc ATF_REQUIRE_EQ("value", merged["var"]);
338*0a6a1f1dSLionel Sambuc }
339*0a6a1f1dSLionel Sambuc
340*0a6a1f1dSLionel Sambuc ATF_TEST_CASE(merge_configs_upper_empty);
ATF_TEST_CASE_HEAD(merge_configs_upper_empty)341*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_HEAD(merge_configs_upper_empty) {}
ATF_TEST_CASE_BODY(merge_configs_upper_empty)342*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(merge_configs_upper_empty) {
343*0a6a1f1dSLionel Sambuc vars_map lower, upper;
344*0a6a1f1dSLionel Sambuc lower["var"] = "value";
345*0a6a1f1dSLionel Sambuc
346*0a6a1f1dSLionel Sambuc vars_map merged = impl::merge_configs(lower, upper);
347*0a6a1f1dSLionel Sambuc ATF_REQUIRE_EQ("value", merged["var"]);
348*0a6a1f1dSLionel Sambuc }
349*0a6a1f1dSLionel Sambuc
350*0a6a1f1dSLionel Sambuc ATF_TEST_CASE(merge_configs_mixed);
ATF_TEST_CASE_HEAD(merge_configs_mixed)351*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_HEAD(merge_configs_mixed) {}
ATF_TEST_CASE_BODY(merge_configs_mixed)352*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(merge_configs_mixed) {
353*0a6a1f1dSLionel Sambuc vars_map lower, upper;
354*0a6a1f1dSLionel Sambuc lower["var1"] = "value1";
355*0a6a1f1dSLionel Sambuc lower["var2"] = "value2-l";
356*0a6a1f1dSLionel Sambuc upper["var2"] = "value2-u";
357*0a6a1f1dSLionel Sambuc upper["var3"] = "value3";
358*0a6a1f1dSLionel Sambuc
359*0a6a1f1dSLionel Sambuc vars_map merged = impl::merge_configs(lower, upper);
360*0a6a1f1dSLionel Sambuc ATF_REQUIRE_EQ("value1", merged["var1"]);
361*0a6a1f1dSLionel Sambuc ATF_REQUIRE_EQ("value2-u", merged["var2"]);
362*0a6a1f1dSLionel Sambuc ATF_REQUIRE_EQ("value3", merged["var3"]);
363*0a6a1f1dSLionel Sambuc }
364*0a6a1f1dSLionel Sambuc
365*0a6a1f1dSLionel Sambuc ATF_TEST_CASE(read_config_files_none);
ATF_TEST_CASE_HEAD(read_config_files_none)366*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_HEAD(read_config_files_none) {}
ATF_TEST_CASE_BODY(read_config_files_none)367*0a6a1f1dSLionel Sambuc ATF_TEST_CASE_BODY(read_config_files_none) {
368*0a6a1f1dSLionel Sambuc tools::env::set("ATF_CONFDIR", ".");
369*0a6a1f1dSLionel Sambuc atf::config::__reinit();
370*0a6a1f1dSLionel Sambuc ATF_REQUIRE(vars_map() == impl::read_config_files("test-suite"));
371*0a6a1f1dSLionel Sambuc }
372*0a6a1f1dSLionel Sambuc
373*0a6a1f1dSLionel Sambuc // -------------------------------------------------------------------------
374*0a6a1f1dSLionel Sambuc // Main.
375*0a6a1f1dSLionel Sambuc // -------------------------------------------------------------------------
376*0a6a1f1dSLionel Sambuc
ATF_INIT_TEST_CASES(tcs)377*0a6a1f1dSLionel Sambuc ATF_INIT_TEST_CASES(tcs)
378*0a6a1f1dSLionel Sambuc {
379*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_1);
380*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_2);
381*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_3);
382*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_4);
383*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_50);
384*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_51);
385*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_52);
386*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_53);
387*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, config_54);
388*0a6a1f1dSLionel Sambuc
389*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, merge_configs_both_empty);
390*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, merge_configs_lower_empty);
391*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, merge_configs_upper_empty);
392*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, merge_configs_mixed);
393*0a6a1f1dSLionel Sambuc
394*0a6a1f1dSLionel Sambuc ATF_ADD_TEST_CASE(tcs, read_config_files_none);
395*0a6a1f1dSLionel Sambuc }
396