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 <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2022-08-10 13:56:02 +02:00 committed by Rob Bradford
parent 6d452fad52
commit 5810e3bee8

View File

@ -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 {