[Libguestfs] [PATCH libnbd v2 3/5] tests: Add a new test for nbd_aio_connect.

Eric Blake eblake at redhat.com
Thu Apr 8 20:26:47 UTC 2021


On 4/8/21 5:36 AM, Richard W.M. Jones wrote:
> This was not tested before.
> ---
>  .gitignore          |   1 +
>  tests/Makefile.am   |   7 +++
>  tests/aio-connect.c | 106 ++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 114 insertions(+)
> 

> +int
> +main (int argc, char *argv[])
> +{
> +  struct nbd_handle *nbd;
> +  int port;
> +  char port_str[16];
> +  pid_t pid;
> +  size_t i;
> +  struct sockaddr_in addr;
> +
> +  unlink (PIDFILE);
> +
> +  /* Pick a port at random, hope it's free. */
> +  srand (time (NULL) + getpid ());
> +  port = 32768 + (rand () & 32767);

Is this going to bite us down the road? Are there tricks such as 'ss
-ltn' (see nbdkit/tests/functions.sh:pick_unused_port) that we should
try for better reliability?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list