aboutsummaryrefslogtreecommitdiff
path: root/paludis/util/process_TEST.cc
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/util/process_TEST.cc')
-rw-r--r--paludis/util/process_TEST.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/paludis/util/process_TEST.cc b/paludis/util/process_TEST.cc
index be63e49d1..89ca85a14 100644
--- a/paludis/util/process_TEST.cc
+++ b/paludis/util/process_TEST.cc
@@ -413,5 +413,41 @@ namespace test_cases
TEST_CHECK_EQUAL(stdout_stream.str(), "");
}
} test_clearenv;
+
+ struct SendFDTest : TestCase
+ {
+ SendFDTest() : TestCase("send fd") { }
+
+ void run()
+ {
+ std::stringstream stdout_stream, in_stream;
+ in_stream << "monkey" << std::endl;
+
+ Process cat_process(ProcessCommand({"sh", "-c", "cat <&$MAGIC_FD"}));
+ cat_process.send_input_to_fd(in_stream, -1, "MAGIC_FD");
+ cat_process.capture_stdout(stdout_stream);
+
+ TEST_CHECK_EQUAL(cat_process.run().wait(), 0);
+ TEST_CHECK_EQUAL(stdout_stream.str(), "monkey\n");
+ }
+ } test_send_fd;
+
+ struct SendFDFixedTest : TestCase
+ {
+ SendFDFixedTest() : TestCase("send fd fixed") { }
+
+ void run()
+ {
+ std::stringstream stdout_stream, in_stream;
+ in_stream << "monkey" << std::endl;
+
+ Process cat_process(ProcessCommand({"sh", "-c", "cat <&5"}));
+ cat_process.send_input_to_fd(in_stream, 5, "");
+ cat_process.capture_stdout(stdout_stream);
+
+ TEST_CHECK_EQUAL(cat_process.run().wait(), 0);
+ TEST_CHECK_EQUAL(stdout_stream.str(), "monkey\n");
+ }
+ } test_send_fd_fixed;
}