aboutsummaryrefslogtreecommitdiff
path: root/paludis/util/process_TEST.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-20 15:50:41 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-21 14:58:17 +0100
commit7d902d768782fae65bdc368a9c0d24b81c381e00 (patch)
tree613ef11993e1b6eeb6133503c43b26784dc0496d /paludis/util/process_TEST.cc
parent6c8ec28a8dd13cdb76f2a367bd54ca1302894bec (diff)
downloadpaludis-7d902d768782fae65bdc368a9c0d24b81c381e00.tar.gz
paludis-7d902d768782fae65bdc368a9c0d24b81c381e00.tar.xz
Process::set_stdin_fd
Diffstat (limited to 'paludis/util/process_TEST.cc')
-rw-r--r--paludis/util/process_TEST.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/paludis/util/process_TEST.cc b/paludis/util/process_TEST.cc
index fc57c197a..b0abb159b 100644
--- a/paludis/util/process_TEST.cc
+++ b/paludis/util/process_TEST.cc
@@ -19,6 +19,8 @@
#include <paludis/util/process.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/pipe.hh>
+#include <paludis/util/safe_ofstream.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <sstream>
@@ -262,5 +264,34 @@ namespace test_cases
TEST_CHECK_EQUAL(fd_stream.str(), "monkey\n");
}
} test_grab_fd_fixed;
+
+ struct StdinFDTest : TestCase
+ {
+ StdinFDTest() : TestCase("stdin fd") { }
+
+ void run()
+ {
+ std::unique_ptr<Pipe> input_pipe(new Pipe(true));
+
+ std::stringstream stdout_stream;
+ Process cat_process(ProcessCommand({"rev"}));
+ cat_process.capture_stdout(stdout_stream);
+ cat_process.set_stdin_fd(input_pipe->read_fd());
+
+ RunningProcessHandle handle(cat_process.run());
+
+ {
+ {
+ SafeOFStream s(input_pipe->write_fd());
+ s << "backwards" << std::endl;
+ }
+ TEST_CHECK(0 == ::close(input_pipe->write_fd()));
+ input_pipe->clear_write_fd();
+ }
+
+ TEST_CHECK_EQUAL(handle.wait(), 0);
+ TEST_CHECK_EQUAL(stdout_stream.str(), "sdrawkcab\n");
+ }
+ } test_stdin_fd;
}