diff options
| author | Enji Cooper <ngie@FreeBSD.org> | 2026-08-17 09:41:49 +0000 |
|---|---|---|
| committer | Enji Cooper <ngie@FreeBSD.org> | 2026-08-17 09:41:49 +0000 |
| commit | 0c9bf043d6892725fd76cd2026949405c9381663 (patch) | |
| tree | 076723db8845ca592088620dde4d293fedb9dbfe /atf-c++/tests.cpp | |
| parent | cd355e3667c67b15d9850bacb416b13486e22c24 (diff) | |
vendor/atf: import atf-0.24-rc1vendor/atf/atf-0.24-rc1
This release candidate will likely serve as the actual upstream
release tag for version 0.24, but for now it should be considered a
release-candidate worthy tag as this code has not gone through a full
FreeBSD test suite run or been built with `make tinderbox` yet on all
supported architectures.
Obtained from: https://github.com/freebsd/atf/releases/tag/atf-0.24-rc1
Diffstat (limited to 'atf-c++/tests.cpp')
| -rw-r--r-- | atf-c++/tests.cpp | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/atf-c++/tests.cpp b/atf-c++/tests.cpp index ede9609e32d6..9edd89c69f02 100644 --- a/atf-c++/tests.cpp +++ b/atf-c++/tests.cpp @@ -58,7 +58,6 @@ extern "C" { } #include "atf-c++/detail/application.hpp" -#include "atf-c++/detail/auto_array.hpp" #include "atf-c++/detail/env.hpp" #include "atf-c++/detail/exceptions.hpp" #include "atf-c++/detail/fs.hpp" @@ -123,13 +122,7 @@ static void set_program_name(const char* argv0) { const std::string program_name = atf::fs::path(argv0).leaf_name(); - // Libtool workaround: if running from within the source tree (binaries - // that are not installed yet), skip the "lt-" prefix added to files in - // the ".libs" directory to show the real (not temporary) name. - if (program_name.substr(0, 3) == "lt-") - Program_Name = program_name.substr(3); - else - Program_Name = program_name; + Program_Name = program_name; } bool @@ -207,22 +200,22 @@ impl::tc::init(const vars_map& config) { atf_error_t err; - auto_array< const char * > array(new const char*[(config.size() * 2) + 1]); - const char **ptr = array.get(); + std::vector< const char * > array; + array.reserve((config.size() * 2) + 1); + for (vars_map::const_iterator iter = config.begin(); iter != config.end(); iter++) { - *ptr = (*iter).first.c_str(); - *(ptr + 1) = (*iter).second.c_str(); - ptr += 2; + array.push_back((*iter).first.c_str()); + array.push_back((*iter).second.c_str()); } - *ptr = NULL; + array.push_back(nullptr); wraps[&pimpl->m_tc] = this; cwraps[&pimpl->m_tc] = this; err = atf_tc_init(&pimpl->m_tc, pimpl->m_ident.c_str(), pimpl->wrap_head, pimpl->wrap_body, pimpl->m_has_cleanup ? pimpl->wrap_cleanup : NULL, - array.get()); + array.data()); if (atf_is_error(err)) throw_atf_error(err); } @@ -273,6 +266,7 @@ impl::tc::get_md_vars(void) char **ptr; for (ptr = array; *ptr != NULL; ptr += 2) vars[*ptr] = *(ptr + 1); + atf_utils_free_charpp(array); } catch (...) { atf_utils_free_charpp(array); throw; @@ -454,9 +448,7 @@ init_tcs(void (*add_tcs)(tc_vector&), tc_vector& tcs, const atf::tests::vars_map& vars) { add_tcs(tcs); - for (tc_vector::iterator iter = tcs.begin(); iter != tcs.end(); iter++) { - impl::tc* tc = *iter; - + for (auto& tc : tcs) { tc->init(vars); } } @@ -609,27 +601,25 @@ safe_main(int argc, char** argv, void (*add_tcs)(tc_vector&)) int errcode; - tc_vector tcs; if (lflag) { if (argc > 0) throw usage_error("Cannot provide test case names with -l"); - - init_tcs(add_tcs, tcs, vars); - errcode = list_tcs(tcs); } else { if (argc == 0) throw usage_error("Must provide a test case name"); else if (argc > 1) throw usage_error("Cannot provide more than one test case name"); INV(argc == 1); - - init_tcs(add_tcs, tcs, vars); - errcode = run_tc(tcs, argv[0], resfile); } - for (tc_vector::iterator iter = tcs.begin(); iter != tcs.end(); iter++) { - impl::tc* tc = *iter; - - delete tc; + tc_vector tcs; + try { + init_tcs(add_tcs, tcs, vars); + errcode = lflag ? list_tcs(tcs) : run_tc(tcs, argv[0], resfile); + } catch (...) { + for (auto& tc: tcs) { + delete tc; + } + throw; } return errcode; |
