BOOST_AUTO_TEST_CASE(abspath_zeros_shell_ok_result)
{
- ExecResult exres;
+ ExecResult exres = ExecResult ();
const std::string result =
capture_exec (I2n::join_string (zero_bytes_argv, " "),
exres);
BOOST_AUTO_TEST_CASE(abspath_zeros_noshell_ok_result)
{
- ExecResult exres;
+ ExecResult exres = ExecResult ();
const std::string result = capture_exec (zero_bytes_argv, exres);
BOOST_CHECK(exres.normal_exit);
{
assert (access(bad_command [0], X_OK) != 0);
- ExecResult exres;
+ ExecResult exres = ExecResult ();
+ /*
+ * Note that the next line will make the unit test spew a message
+ * to stderr which cannot be prevented due to the limitations of
+ * popen(3).
+ */
const std::string result =
capture_exec (I2n::join_string (bad_command, " "));
{
assert (access(bad_command [0], X_OK) != 0);
- ExecResult exres;
+ ExecResult exres = ExecResult ();
const std::string result = capture_exec (bad_command, exres);
BOOST_CHECK(!exres.terminated_by_signal);
{
assert (access(bad_command [0], X_OK) != 0);
- ExecResult exres;
+ ExecResult exres = ExecResult ();
const std::string result = capture_exec (bad_command, exres, false, true);
- BOOST_CHECK_NE(result.size (), 0);
+ BOOST_CHECK(!exres.terminated_by_signal);
+ BOOST_CHECK_EQUAL(result.size (), 0);
}
- const char *const false_argv [] = { "/bin/false", NULL };
+ 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 };
BOOST_AUTO_TEST_CASE(abspath_false_noshell_fail_exit)
{
- ExecResult exres;
- const std::string result = capture_exec (false_argv, exres, true, false);
+ ExecResult exres = ExecResult ();
+ const std::string result =
+ capture_exec (false_argv_abs, exres, true, false, false);
BOOST_CHECK(exres.normal_exit);
BOOST_CHECK_EQUAL(exres.return_code, EXIT_FAILURE);
BOOST_AUTO_TEST_CASE(abspath_false_shell_fail_exit)
{
- ExecResult exres;
+ ExecResult exres = ExecResult ();
const std::string result =
- capture_exec (std::string (false_argv [0]), exres);
+ capture_exec (std::string (false_argv_abs [0]), exres);
BOOST_CHECK(exres.normal_exit);
BOOST_CHECK_EQUAL(exres.return_code, EXIT_FAILURE);
BOOST_CHECK_EQUAL(result.size (), 0);
}
+ BOOST_AUTO_TEST_CASE(relpath_true_noshell_ok)
+ {
+ ExecResult exres = ExecResult ();
+ const std::string result =
+ capture_exec (true_argv_rel, exres, true, false, true);
+
+ BOOST_CHECK(exres.normal_exit);
+ BOOST_CHECK_EQUAL(exres.return_code, EXIT_SUCCESS);
+ BOOST_CHECK_EQUAL(result.size (), 0);
+ }
+
+ BOOST_AUTO_TEST_CASE(relpath_true_noshell_fail)
+ {
+ ExecResult exres = ExecResult ();
+ const std::string result =
+ capture_exec (true_argv_rel, exres, true, false, false);
+
+ BOOST_CHECK(exres.normal_exit);
+ /* no return code check since we couln't exit */
+ BOOST_CHECK_EQUAL(result.size (), 0);
+ }
+
+ BOOST_AUTO_TEST_CASE(abspath_true_noshell_ok)
+ {
+ ExecResult exres = ExecResult ();
+ const std::string result =
+ capture_exec (true_argv_abs, exres, true, false, true);
+
+ BOOST_CHECK(exres.normal_exit);
+ BOOST_CHECK_EQUAL(exres.return_code, EXIT_SUCCESS);
+ BOOST_CHECK_EQUAL(result.size (), 0);
+ }
+
+ BOOST_AUTO_TEST_CASE(relpath_false_noshell_fail)
+ {
+ ExecResult exres = ExecResult ();
+ const std::string result =
+ capture_exec (false_argv_rel, exres, true, false, true);
+
+ BOOST_CHECK(exres.normal_exit);
+ /* no return code check since we couln't exit */
+ BOOST_CHECK_EQUAL(result.size (), 0);
+ }
+
BOOST_AUTO_TEST_SUITE_END() /* [pipestream->read] */
BOOST_AUTO_TEST_SUITE_END() /* [pipestream] */