* Copyright 2018 by Intra2net AG
*/
-#define BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE
+#include <boost/version.hpp>
+#if BOOST_VERSION > /* guessed */ 104400
+/*
+ * Boost overeagerly terminates a unit test when a child exits non-zero
+ * without offering a means of disabling this behavior locally. All we
+ * have is below macro which isn’t even available on older versions of
+ * the unittest runner.
+ */
+# define BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE
+#else
+/* Boost too old; skip test that validate error handling. */
+# define NO_CHILD_FAIL_TESTS
+#endif
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
const char *const bad_command [] = { "/does_not_exist", NULL };
+# ifndef NO_CHILD_FAIL_TESTS
BOOST_AUTO_TEST_CASE(abspath_bad_shell_fail)
{
assert (access(bad_command [0], X_OK) != 0);
BOOST_CHECK(!exres.normal_exit);
BOOST_CHECK_EQUAL(result.size (), 0);
}
+# endif /* [!NO_CHILD_FAIL_TESTS] */
+# ifndef NO_CHILD_FAIL_TESTS
BOOST_AUTO_TEST_CASE(abspath_bad_noshell_fail)
{
assert (access(bad_command [0], X_OK) != 0);
"child failed to exec(): "
"error 2 (No such file or directory)");
}
+# endif /* [!NO_CHILD_FAIL_TESTS] */
+# ifndef NO_CHILD_FAIL_TESTS
BOOST_AUTO_TEST_CASE(abspath_bad_noshell_stderr)
{
assert (access(bad_command [0], X_OK) != 0);
"child failed to exec(): "
"error 2 (No such file or directory)");
}
+# endif /* [!NO_CHILD_FAIL_TESTS] */
const char *const false_argv_abs [] = { "/bin/false", NULL };
const char *const true_argv_abs [] = { "/bin/true" , NULL };
const char *const false_argv_rel [] = { "false" , NULL };
const char *const true_argv_rel [] = { "true" , NULL };
+# ifndef NO_CHILD_FAIL_TESTS
BOOST_AUTO_TEST_CASE(abspath_false_noshell_fail_exit)
{
ExecResult exres = ExecResult ();
BOOST_CHECK_EQUAL(exres.return_code, EXIT_FAILURE);
BOOST_CHECK_EQUAL(result.size (), 0);
}
+# endif /* [!NO_CHILD_FAIL_TESTS] */
+# ifndef NO_CHILD_FAIL_TESTS
BOOST_AUTO_TEST_CASE(abspath_false_shell_fail_exit)
{
ExecResult exres = ExecResult ();
BOOST_CHECK_EQUAL(exres.return_code, EXIT_FAILURE);
BOOST_CHECK_EQUAL(result.size (), 0);
}
+# endif /* [!NO_CHILD_FAIL_TESTS] */
BOOST_AUTO_TEST_CASE(relpath_true_noshell_ok)
{
BOOST_CHECK_EQUAL(result.size (), 0);
}
+# ifndef NO_CHILD_FAIL_TESTS
BOOST_AUTO_TEST_CASE(relpath_true_noshell_fail)
{
ExecResult exres = ExecResult ();
"child failed to exec(): "
"error 2 (No such file or directory)");
}
+# endif /* [!NO_CHILD_FAIL_TESTS] */
BOOST_AUTO_TEST_CASE(abspath_true_noshell_ok)
{
BOOST_CHECK_EQUAL(result.size (), 0);
}
+# ifndef NO_CHILD_FAIL_TESTS
BOOST_AUTO_TEST_CASE(relpath_false_noshell_fail)
{
ExecResult exres = ExecResult ();
/* no return code check since we couldn't exit */
BOOST_CHECK_EQUAL(result.size (), 0);
}
+# endif /* [!NO_CHILD_FAIL_TESTS] */
const char *const echo_abs = "/bin/echo";
const char *const echo_rel = "echo";