aboutsummaryrefslogtreecommitdiff
path: root/paludis/util/process_TEST.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-20 14:56:23 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-21 14:58:17 +0100
commit6c8ec28a8dd13cdb76f2a367bd54ca1302894bec (patch)
tree790c09f63104a2aadff8166a21b714d722786665 /paludis/util/process_TEST.cc
parentb17e35dcdbd14c3a73511b19c0e82cd52d212499 (diff)
downloadpaludis-6c8ec28a8dd13cdb76f2a367bd54ca1302894bec.tar.gz
paludis-6c8ec28a8dd13cdb76f2a367bd54ca1302894bec.tar.xz
Process::capture_output_to_fd
Diffstat (limited to 'paludis/util/process_TEST.cc')
-rw-r--r--paludis/util/process_TEST.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/paludis/util/process_TEST.cc b/paludis/util/process_TEST.cc
index a7361f3c0..fc57c197a 100644
--- a/paludis/util/process_TEST.cc
+++ b/paludis/util/process_TEST.cc
@@ -232,5 +232,35 @@ namespace test_cases
}
}
} test_setuid;
+
+ struct GrabFDTest : TestCase
+ {
+ GrabFDTest() : TestCase("grab fd") { }
+
+ void run()
+ {
+ std::stringstream fd_stream;
+ Process echo_process(ProcessCommand({"sh", "-c", "echo monkey 1>&$MAGIC_FD"}));
+ echo_process.capture_output_to_fd(fd_stream, -1, "MAGIC_FD");
+
+ TEST_CHECK_EQUAL(echo_process.run().wait(), 0);
+ TEST_CHECK_EQUAL(fd_stream.str(), "monkey\n");
+ }
+ } test_grab_fd;
+
+ struct GrabFDFixedTest : TestCase
+ {
+ GrabFDFixedTest() : TestCase("grab fd fixed") { }
+
+ void run()
+ {
+ std::stringstream fd_stream;
+ Process echo_process(ProcessCommand({"sh", "-c", "echo monkey 1>&5"}));
+ echo_process.capture_output_to_fd(fd_stream, 5, "");
+
+ TEST_CHECK_EQUAL(echo_process.run().wait(), 0);
+ TEST_CHECK_EQUAL(fd_stream.str(), "monkey\n");
+ }
+ } test_grab_fd_fixed;
}