diff options
author | Julio Merino <jmmv@FreeBSD.org> | 2014-02-14 14:41:25 +0000 |
---|---|---|
committer | Julio Merino <jmmv@FreeBSD.org> | 2014-02-14 14:41:25 +0000 |
commit | 8fee91db34c6746951ced9a348b36c5b758d576e (patch) | |
tree | a986bed64ee725de3eb52c5f0838f6c59b8aa7d9 /atf-c++/detail/test_helpers.cpp | |
parent | bf351e294647b19b2abb7e59344e619866206e71 (diff) | |
download | src-8fee91db34c6746951ced9a348b36c5b758d576e.tar.gz src-8fee91db34c6746951ced9a348b36c5b758d576e.zip |
Import atf-0.19:vendor/atf/atf-0.19
Experimental version released on February 7th, 2014.
This is the last release to bundle the code for the deprecated tools.
The next release will drop their code and will stop worrying about
backwards compatibility between the ATF libraries and what the old tools
may or may not support.
If you still require the old tools for some reason, grab a copy of the
'tools' directory now. The code in this directory is standalone and
does not depend on any internal details of atf-c++ any longer.
* Various fixes and improvements to support running as part of the FreeBSD
test suite.
* Project hosting moved from Google Code (as a subproject of Kyua) to
GitHub (as a first-class project). The main reason for the change is
the suppression of binary downloads in Google Code on Jan 15th, 2014.
See https://github.com/jmmv/atf/
* Removed builtin help from atf-sh(1) and atf-check(1) for simplicity
reasons. In other words, their -h option is gone.
* Moved the code of the deprecated tools into a 'tools' directory and
completely decoupled their code from the internals of atf-c++. The
reason for this is to painlessly allow a third-party to maintain a
copy of these tools after we delete them because upcoming changes to
atf-c++ would break the stale tools.
Notes
Notes:
svn path=/vendor/atf/dist/; revision=261886
svn path=/vendor/atf/atf-0.19/; revision=261887; tag=vendor/atf/atf-0.19
Diffstat (limited to 'atf-c++/detail/test_helpers.cpp')
-rw-r--r-- | atf-c++/detail/test_helpers.cpp | 82 |
1 files changed, 33 insertions, 49 deletions
diff --git a/atf-c++/detail/test_helpers.cpp b/atf-c++/detail/test_helpers.cpp index 191649d03d59..38e651634dde 100644 --- a/atf-c++/detail/test_helpers.cpp +++ b/atf-c++/detail/test_helpers.cpp @@ -40,80 +40,64 @@ #include "process.hpp" #include "test_helpers.hpp" -void -build_check_cxx_o_aux(const atf::fs::path& sfile, const char* failmsg, - const bool expect_pass) +// Path to the directory containing the libatf-c tests, used to locate the +// process_helpers program. If NULL (the default), the code will use a +// relative path. Otherwise, the provided path will be used; this is so +// that we can locate the helpers binary if the installation uses a +// different layout than the one we provide (as is the case in FreeBSD). +#if defined(ATF_C_TESTS_BASE) +static const char* atf_c_tests_base = ATF_C_TESTS_BASE; +#else +static const char* atf_c_tests_base = NULL; +#endif +#undef ATF_C_TESTS_BASE + +bool +build_check_cxx_o(const char* sfile) { std::vector< std::string > optargs; optargs.push_back("-I" + atf::config::get("atf_includedir")); optargs.push_back("-Wall"); optargs.push_back("-Werror"); - const bool result = atf::check::build_cxx_o( - sfile.str(), "test.o", atf::process::argv_array(optargs)); - if ((expect_pass && !result) || (!expect_pass && result)) - ATF_FAIL(failmsg); + return atf::check::build_cxx_o(sfile, "test.o", + atf::process::argv_array(optargs)); } -void -build_check_cxx_o(const atf::tests::tc& tc, const char* sfile, - const char* failmsg, const bool expect_pass) +bool +build_check_cxx_o_srcdir(const atf::tests::tc& tc, const char* sfile) { const atf::fs::path sfilepath = atf::fs::path(tc.get_config_var("srcdir")) / sfile; - build_check_cxx_o_aux(sfilepath, failmsg, expect_pass); + return build_check_cxx_o(sfilepath.c_str()); } void header_check(const char *hdrname) { - std::ofstream srcfile("test.c"); + std::ofstream srcfile("test.cpp"); ATF_REQUIRE(srcfile); srcfile << "#include <" << hdrname << ">\n"; srcfile.close(); const std::string failmsg = std::string("Header check failed; ") + hdrname + " is not self-contained"; - build_check_cxx_o_aux(atf::fs::path("test.c"), failmsg.c_str(), true); + if (!build_check_cxx_o("test.cpp")) + ATF_FAIL(failmsg); } atf::fs::path -get_process_helpers_path(const atf::tests::tc& tc) -{ - return atf::fs::path(tc.get_config_var("srcdir")) / - ".." / "atf-c" / "detail" / "process_helpers"; -} - -void -test_helpers_detail::check_equal(const char* expected[], - const string_vector& actual) +get_process_helpers_path(const atf::tests::tc& tc, bool is_detail) { - const char** expected_iter = expected; - string_vector::const_iterator actual_iter = actual.begin(); - - bool equals = true; - while (equals && *expected_iter != NULL && actual_iter != actual.end()) { - if (*expected_iter != *actual_iter) { - equals = false; - } else { - expected_iter++; - actual_iter++; - } - } - if (equals && ((*expected_iter == NULL && actual_iter != actual.end()) || - (*expected_iter != NULL && actual_iter == actual.end()))) - equals = false; - - if (!equals) { - std::cerr << "EXPECTED:\n"; - for (expected_iter = expected; *expected_iter != NULL; expected_iter++) - std::cerr << *expected_iter << "\n"; - - std::cerr << "ACTUAL:\n"; - for (actual_iter = actual.begin(); actual_iter != actual.end(); - actual_iter++) - std::cerr << *actual_iter << "\n"; - - ATF_FAIL("Expected results differ to actual values"); + const char* helper = "detail/process_helpers"; + if (atf_c_tests_base == NULL) { + if (is_detail) + return atf::fs::path(tc.get_config_var("srcdir")) / + ".." / ".." / "atf-c" / helper; + else + return atf::fs::path(tc.get_config_var("srcdir")) / + ".." / "atf-c" / helper; + } else { + return atf::fs::path(atf_c_tests_base) / helper; } } |