aboutsummaryrefslogtreecommitdiff
path: root/paludis/util/process_TEST.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-21 16:43:51 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-21 19:57:02 +0100
commit4d786588b2318c2183fd065e38d4fc216b658def (patch)
tree3977175de87add924a445b52c37d8e53bb78053a /paludis/util/process_TEST.cc
parenteaa807d2927065610392370e2aa8561bc334a262 (diff)
downloadpaludis-4d786588b2318c2183fd065e38d4fc216b658def.tar.gz
paludis-4d786588b2318c2183fd065e38d4fc216b658def.tar.xz
Process::send_input_to_fd
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;
}