On Fri, Jul 12, 2019 at 12:23:49PM -0400, Stefan Berger wrote:
Add a test case to commandtest.c to test the transfer of data to a
process who received the read-end of pipes' file descriptors. Transfer
large (128 kb) byte streams.
Extend the commandhelper.c with support for --readfd <fd> command line
parameter and convert the data receive loop to use poll and receive data
on multiple file descriptors (up to 3) and read data into distinct buffers
that we grow while adding more (string) data.
Signed-off-by: Stefan Berger <stefanb(a)linux.ibm.com>
---
tests/commandhelper.c | 70 +++++++++++++++++++++++---
tests/commandtest.c | 113 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 177 insertions(+), 6 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
@@ -62,13 +63,27 @@ int main(int argc, char **argv) {
char *cwd;
FILE *log = fopen(abs_builddir "/commandhelper.log", "w");
int ret = EXIT_FAILURE;
+ int readfds[3] = { STDIN_FILENO, };
+ int numreadfds = 1;
+ struct pollfd fds[3];
+ int numpollfds = 0;
s/int/size_t/ for array sizes
+ char *buffers[3] = {NULL, NULL, NULL};
+ size_t buflen[3] = {0, 0, 0};
+ char c;
Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|