summaryrefslogtreecommitdiff
path: root/common/subprocess_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'common/subprocess_unittest.cc')
-rw-r--r--common/subprocess_unittest.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/common/subprocess_unittest.cc b/common/subprocess_unittest.cc
index 5ca44e80..cc1f3537 100644
--- a/common/subprocess_unittest.cc
+++ b/common/subprocess_unittest.cc
@@ -171,13 +171,15 @@ TEST_F(SubprocessTest, PipeRedirectFdTest) {
// Test that a pipe file descriptor open in the parent is not open in the child.
TEST_F(SubprocessTest, PipeClosedWhenNotRedirectedTest) {
brillo::ScopedPipe pipe;
- const vector<string> cmd = {kBinPath "/sh", "-c",
- base::StringPrintf("echo on pipe >/proc/self/fd/%d", pipe.writer)};
+
+ // test_subprocess will return with the errno of fstat, which should be EBADF
+ // if the passed file descriptor is closed in the child.
+ const vector<string> cmd = {
+ test_utils::GetBuildArtifactsPath("test_subprocess"),
+ "fstat",
+ std::to_string(pipe.writer)};
EXPECT_TRUE(subprocess_.ExecFlags(
- cmd,
- 0,
- {},
- base::Bind(&ExpectedResults, 1, "")));
+ cmd, 0, {}, base::Bind(&ExpectedResults, EBADF, "")));
loop_.Run();
}