From 5810e3bee8ebb068499a459a6e9b7b08ab95a8d7 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 10 Aug 2022 13:56:02 +0200 Subject: [PATCH] test_infra: Enhance error reporting related to pipe resizing Whenever starting a test with the capture_output option, both stdout and stderr pipes are resized to a greater capacity. But the problem is that when the system call fcntl() fails, we need to know about the error returned by the system so that we can apply the necessary changes. This patch simply enhances the error checking and reporting related to the invocation of fcntl() when trying to resize a pipe. Refers to #4475 Signed-off-by: Sebastien Boeuf --- test_infra/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index da613907a..8d900375d 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -1242,15 +1242,24 @@ impl<'a> GuestCommand<'a> { let fd = child.stdout.as_ref().unwrap().as_raw_fd(); let pipesize = unsafe { libc::fcntl(fd, libc::F_SETPIPE_SZ, PIPE_SIZE) }; + if pipesize == -1 { + return Err(io::Error::last_os_error()); + } let fd = child.stderr.as_ref().unwrap().as_raw_fd(); let pipesize1 = unsafe { libc::fcntl(fd, libc::F_SETPIPE_SZ, PIPE_SIZE) }; + if pipesize1 == -1 { + return Err(io::Error::last_os_error()); + } if pipesize >= PIPE_SIZE && pipesize1 >= PIPE_SIZE { Ok(child) } else { Err(std::io::Error::new( std::io::ErrorKind::Other, - "resizing pipe w/ 'fnctl' failed!", + format!( + "resizing pipe w/ 'fnctl' failed: stdout pipesize {}, stderr pipesize {}", + pipesize, pipesize1 + ), )) } } else {