Module Name: src
Committed By: gson
Date: Sat Apr 10 10:32:57 UTC 2021
Modified Files:
src/external/bsd/atf/dist/tools: atf-run.1 atf-run.cpp
Log Message:
Add support for running individual test cases under isolation.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/atf/dist/tools/atf-run.1
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/atf/dist/tools/atf-run.cpp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/atf/dist/tools/atf-run.1
diff -u src/external/bsd/atf/dist/tools/atf-run.1:1.4 src/external/bsd/atf/dist/tools/atf-run.1:1.5
--- src/external/bsd/atf/dist/tools/atf-run.1:1.4 Sat Feb 8 19:13:44 2014
+++ src/external/bsd/atf/dist/tools/atf-run.1 Sat Apr 10 10:32:57 2021
@@ -26,23 +26,22 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd November 1, 2010
+.Dd April 10, 2021
.Dt ATF-RUN 1
.Os
.Sh NAME
.Nm atf-run
-.Nd executes a collection of test programs
+.Nd executes a collection of tests
.Sh SYNOPSIS
.Nm
.Op Fl v Ar var1=value1 Op .. Fl v Ar varN=valueN
-.Op Ar test_program1 Op Ar .. test_programN
+.Op Ar test1 Op Ar .. testN
.Nm
.Fl h
.Sh DESCRIPTION
.Nm
-executes a collection of test programs or, in other words, a complete
-test suite.
-The results of each test program are collected by the tool, and are then
+executes a collection of test cases, test programs, or a complete test suite.
+The results of each test are collected by the tool, and are then
multiplexed into a single machine-parseable report; see
.Xr atf-formats 5
for more details.
@@ -70,8 +69,14 @@ In the first synopsis form,
parses the
.Pa Atffile
in the current directory and runs all the test programs specified in it.
-If any test program names are given as part of the command line, those are
-the ones executed instead of the complete list.
+If any
+.Ar test
+arguments are given as part of the command line, those tests are
+executed instead of the complete list. Each
+.Ar test
+argument can be either the name of a test program, or a string of the form
+.Ar test_program:test_case
+to execute a single test case.
.Pp
In the second synopsis form,
.Nm
Index: src/external/bsd/atf/dist/tools/atf-run.cpp
diff -u src/external/bsd/atf/dist/tools/atf-run.cpp:1.5 src/external/bsd/atf/dist/tools/atf-run.cpp:1.6
--- src/external/bsd/atf/dist/tools/atf-run.cpp:1.5 Tue Feb 11 18:13:45 2014
+++ src/external/bsd/atf/dist/tools/atf-run.cpp Sat Apr 10 10:32:57 2021
@@ -81,11 +81,13 @@ class atf_run : public tools::applicatio
size_t count_tps(std::vector< std::string >) const;
- int run_test(const tools::fs::path&, tools::test_program::atf_tps_writer&,
+ int run_test(const tools::fs::path&, const std::string &,
+ tools::test_program::atf_tps_writer&,
const vars_map&);
int run_test_directory(const tools::fs::path&,
tools::test_program::atf_tps_writer&);
int run_test_program(const tools::fs::path&,
+ const std::string tc,
tools::test_program::atf_tps_writer&,
const vars_map&);
@@ -179,7 +181,7 @@ std::string
atf_run::specific_args(void)
const
{
- return "[test-program1 .. test-programN]";
+ return "[test1 .. testN]";
}
atf_run::options_set
@@ -214,6 +216,7 @@ atf_run::parse_vflag(const std::string&
int
atf_run::run_test(const tools::fs::path& tp,
+ const std::string &tc,
tools::test_program::atf_tps_writer& w,
const vars_map& config)
{
@@ -226,7 +229,7 @@ atf_run::run_test(const tools::fs::path&
const vars_map effective_config =
tools::config_file::merge_configs(config, m_cmdline_vars);
- errcode = run_test_program(tp, w, effective_config);
+ errcode = run_test_program(tp, tc, w, effective_config);
}
return errcode;
}
@@ -247,7 +250,7 @@ atf_run::run_test_directory(const tools:
bool ok = true;
for (std::vector< std::string >::const_iterator iter = af.tps().begin();
iter != af.tps().end(); iter++) {
- const bool result = run_test(tp / *iter, w,
+ const bool result = run_test(tp / *iter, "", w,
tools::config_file::merge_configs(af.conf(), test_suite_vars));
ok &= (result == EXIT_SUCCESS);
}
@@ -362,6 +365,7 @@ atf_run::get_test_case_result(const std:
int
atf_run::run_test_program(const tools::fs::path& tp,
+ const std::string tc,
tools::test_program::atf_tps_writer& w,
const vars_map& config)
{
@@ -394,6 +398,9 @@ atf_run::run_test_program(const tools::f
const std::string& tcname = (*iter).first;
const vars_map& tcmd = (*iter).second;
+ if (! tc.empty() && tcname != tc)
+ continue;
+
w.start_tc(tcname);
try {
@@ -464,6 +471,19 @@ atf_run::run_test_program(const tools::f
return errcode;
}
+static void
+colon_split(const std::string &s, std::string &tp, std::string &tc)
+{
+ size_t colon_pos = s.rfind(':');
+ if (colon_pos != std::string::npos && colon_pos < s.size() - 1) {
+ tp = s.substr(0, colon_pos);
+ tc = s.substr(colon_pos + 1);
+ } else {
+ tp = s;
+ tc = "";
+ }
+}
+
size_t
atf_run::count_tps(std::vector< std::string > tps)
const
@@ -472,7 +492,9 @@ atf_run::count_tps(std::vector< std::str
for (std::vector< std::string >::const_iterator iter = tps.begin();
iter != tps.end(); iter++) {
- tools::fs::path tp(*iter);
+ std::string tpname, tcname;
+ colon_split(*iter, tpname, tcname);
+ tools::fs::path tp(tpname);
tools::fs::file_info fi(tp);
if (fi.get_type() == tools::fs::file_info::dir_type) {
@@ -540,7 +562,9 @@ atf_run::main(void)
bool ok = true;
for (std::vector< std::string >::const_iterator iter = tps.begin();
iter != tps.end(); iter++) {
- const bool result = run_test(tools::fs::path(*iter), w,
+ std::string tp, tc;
+ colon_split(*iter, tp, tc);
+ const bool result = run_test(tools::fs::path(tp), tc, w,
tools::config_file::merge_configs(af.conf(), test_suite_vars));
ok &= (result == EXIT_SUCCESS);
}