Deleted Added
full compact
build_test.c (240120) build_test.c (273929)
1/*
2 * Automated Testing Framework (atf)
3 *
4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
1/* Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright

--- 6 unchanged lines hidden (view full) ---

19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright

--- 6 unchanged lines hidden (view full) ---

16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
24 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29
25
26#include "atf-c/build.h"
27
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33
34#include <atf-c.h>
35
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31
32#include <atf-c.h>
33
36#include "atf-c/build.h"
37#include "atf-c/config.h"
34#include "atf-c/detail/env.h"
35#include "atf-c/detail/test_helpers.h"
36#include "atf-c/h_build.h"
38#include "atf-c/utils.h"
39
37#include "atf-c/utils.h"
38
40#include "detail/env.h"
41#include "detail/test_helpers.h"
42#include "h_build.h"
43
44/* ---------------------------------------------------------------------
45 * Auxiliary functions.
46 * --------------------------------------------------------------------- */
47
39/* ---------------------------------------------------------------------
40 * Auxiliary functions.
41 * --------------------------------------------------------------------- */
42
48void __atf_config_reinit(void);
49
50static
51bool
52equal_arrays(const char *const *exp_array, char **actual_array)
53{
54 bool equal;
55
56 if (*exp_array == NULL && *actual_array == NULL)
57 equal = true;

--- 104 unchanged lines hidden (view full) ---

162 struct c_o_test *test;
163
164 for (test = c_o_tests; test->expargv[0] != NULL; test++) {
165 printf("> Test: %s\n", test->msg);
166
167 verbose_set_env("ATF_BUILD_CC", test->cc);
168 verbose_set_env("ATF_BUILD_CFLAGS", test->cflags);
169 verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
43static
44bool
45equal_arrays(const char *const *exp_array, char **actual_array)
46{
47 bool equal;
48
49 if (*exp_array == NULL && *actual_array == NULL)
50 equal = true;

--- 104 unchanged lines hidden (view full) ---

155 struct c_o_test *test;
156
157 for (test = c_o_tests; test->expargv[0] != NULL; test++) {
158 printf("> Test: %s\n", test->msg);
159
160 verbose_set_env("ATF_BUILD_CC", test->cc);
161 verbose_set_env("ATF_BUILD_CFLAGS", test->cflags);
162 verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
170 __atf_config_reinit();
171
172 {
173 char **argv;
174 if (test->hasoptargs)
175 RE(atf_build_c_o(test->sfile, test->ofile, test->optargs,
176 &argv));
177 else
178 RE(atf_build_c_o(test->sfile, test->ofile, NULL, &argv));

--- 12 unchanged lines hidden (view full) ---

191{
192 struct cpp_test *test;
193
194 for (test = cpp_tests; test->expargv[0] != NULL; test++) {
195 printf("> Test: %s\n", test->msg);
196
197 verbose_set_env("ATF_BUILD_CPP", test->cpp);
198 verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
163
164 {
165 char **argv;
166 if (test->hasoptargs)
167 RE(atf_build_c_o(test->sfile, test->ofile, test->optargs,
168 &argv));
169 else
170 RE(atf_build_c_o(test->sfile, test->ofile, NULL, &argv));

--- 12 unchanged lines hidden (view full) ---

183{
184 struct cpp_test *test;
185
186 for (test = cpp_tests; test->expargv[0] != NULL; test++) {
187 printf("> Test: %s\n", test->msg);
188
189 verbose_set_env("ATF_BUILD_CPP", test->cpp);
190 verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
199 __atf_config_reinit();
200
201 {
202 char **argv;
203 if (test->hasoptargs)
204 RE(atf_build_cpp(test->sfile, test->ofile, test->optargs,
205 &argv));
206 else
207 RE(atf_build_cpp(test->sfile, test->ofile, NULL, &argv));

--- 13 unchanged lines hidden (view full) ---

221 struct cxx_o_test *test;
222
223 for (test = cxx_o_tests; test->expargv[0] != NULL; test++) {
224 printf("> Test: %s\n", test->msg);
225
226 verbose_set_env("ATF_BUILD_CXX", test->cxx);
227 verbose_set_env("ATF_BUILD_CXXFLAGS", test->cxxflags);
228 verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
191
192 {
193 char **argv;
194 if (test->hasoptargs)
195 RE(atf_build_cpp(test->sfile, test->ofile, test->optargs,
196 &argv));
197 else
198 RE(atf_build_cpp(test->sfile, test->ofile, NULL, &argv));

--- 13 unchanged lines hidden (view full) ---

212 struct cxx_o_test *test;
213
214 for (test = cxx_o_tests; test->expargv[0] != NULL; test++) {
215 printf("> Test: %s\n", test->msg);
216
217 verbose_set_env("ATF_BUILD_CXX", test->cxx);
218 verbose_set_env("ATF_BUILD_CXXFLAGS", test->cxxflags);
219 verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
229 __atf_config_reinit();
230
231 {
232 char **argv;
233 if (test->hasoptargs)
234 RE(atf_build_cxx_o(test->sfile, test->ofile, test->optargs,
235 &argv));
236 else
237 RE(atf_build_cxx_o(test->sfile, test->ofile, NULL, &argv));
238 check_equal_array(test->expargv, argv);
239 atf_utils_free_charpp(argv);
240 }
241 }
242}
243
244/* ---------------------------------------------------------------------
220
221 {
222 char **argv;
223 if (test->hasoptargs)
224 RE(atf_build_cxx_o(test->sfile, test->ofile, test->optargs,
225 &argv));
226 else
227 RE(atf_build_cxx_o(test->sfile, test->ofile, NULL, &argv));
228 check_equal_array(test->expargv, argv);
229 atf_utils_free_charpp(argv);
230 }
231 }
232}
233
234/* ---------------------------------------------------------------------
245 * Tests cases for the header file.
246 * --------------------------------------------------------------------- */
247
248HEADER_TC(include, "atf-c/build.h");
249
250/* ---------------------------------------------------------------------
251 * Main.
252 * --------------------------------------------------------------------- */
253
254ATF_TP_ADD_TCS(tp)
255{
256 /* Add the internal test cases. */
257 ATF_TP_ADD_TC(tp, equal_arrays);
258
259 /* Add the test cases for the free functions. */
260 ATF_TP_ADD_TC(tp, c_o);
261 ATF_TP_ADD_TC(tp, cpp);
262 ATF_TP_ADD_TC(tp, cxx_o);
263
235 * Main.
236 * --------------------------------------------------------------------- */
237
238ATF_TP_ADD_TCS(tp)
239{
240 /* Add the internal test cases. */
241 ATF_TP_ADD_TC(tp, equal_arrays);
242
243 /* Add the test cases for the free functions. */
244 ATF_TP_ADD_TC(tp, c_o);
245 ATF_TP_ADD_TC(tp, cpp);
246 ATF_TP_ADD_TC(tp, cxx_o);
247
264 /* Add the test cases for the header file. */
265 ATF_TP_ADD_TC(tp, include);
266
267 return atf_no_error();
268}
248 return atf_no_error();
249}