2 // Automated Testing Framework (atf)
4 // Copyright (c) 2009 The NetBSD Foundation, Inc.
5 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
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
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
16 // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 // CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
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
27 // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "../check.hpp"
36 #include "../config.hpp"
37 #include "../macros.hpp"
40 #include "process.hpp"
41 #include "test_helpers.hpp"
43 // Path to the directory containing the libatf-c tests, used to locate the
44 // process_helpers program. If NULL (the default), the code will use a
45 // relative path. Otherwise, the provided path will be used; this is so
46 // that we can locate the helpers binary if the installation uses a
47 // different layout than the one we provide (as is the case in FreeBSD).
48 #if defined(ATF_C_TESTS_BASE)
49 static const char* atf_c_tests_base
= ATF_C_TESTS_BASE
;
51 static const char* atf_c_tests_base
= NULL
;
53 #undef ATF_C_TESTS_BASE
56 build_check_cxx_o(const char* sfile
)
58 std::vector
< std::string
> optargs
;
59 optargs
.push_back("-I" + atf::config::get("atf_includedir"));
60 optargs
.push_back("-Wall");
61 optargs
.push_back("-Werror");
63 return atf::check::build_cxx_o(sfile
, "test.o",
64 atf::process::argv_array(optargs
));
68 build_check_cxx_o_srcdir(const atf::tests::tc
& tc
, const char* sfile
)
70 const atf::fs::path sfilepath
=
71 atf::fs::path(tc
.get_config_var("srcdir")) / sfile
;
72 return build_check_cxx_o(sfilepath
.c_str());
76 header_check(const char *hdrname
)
78 std::ofstream
srcfile("test.cpp");
80 srcfile
<< "#include <" << hdrname
<< ">\n";
83 const std::string failmsg
= std::string("Header check failed; ") +
84 hdrname
+ " is not self-contained";
85 if (!build_check_cxx_o("test.cpp"))
90 get_process_helpers_path(const atf::tests::tc
& tc
, bool is_detail
)
92 const char* helper
= "detail/process_helpers";
93 if (atf_c_tests_base
== NULL
) {
95 return atf::fs::path(tc
.get_config_var("srcdir")) /
96 ".." / ".." / "atf-c" / helper
;
98 return atf::fs::path(tc
.get_config_var("srcdir")) /
99 ".." / "atf-c" / helper
;
101 return atf::fs::path(atf_c_tests_base
) / helper
;