test: Skip TCP tests if getaddrinfo doesn't work
authorSimon McVittie <smcv@collabora.com>
Mon, 4 Jun 2018 15:27:50 +0000 (16:27 +0100)
committerSimon McVittie <smcv@collabora.com>
Mon, 4 Jun 2018 16:56:31 +0000 (17:56 +0100)
commit42772170a997b2a53174165b446065d9cc28c9a4
tree5c4d93cac6a01d50a161e793150d943837e8b38f
parent44027e9ec6183ed3744d786d04048b5c7733934e
test: Skip TCP tests if getaddrinfo doesn't work

For example, this can be the case in bubblewrap or Debian pbuilder after
unsharing the network namespace:

    bwrap \
    --bind / / \
    --dev-bind /dev /dev \
    --bind /dev/shm /dev/shm \
    --bind /dev/pts /dev/pts \
    --unshare-net \
    ${builddir}/test/test-loopback --tap
    ...
    ok 1 /connect/tcp # SKIP Name resolution does not work here:
    getaddrinfo("127.0.0.1", "0", {flags=ADDRCONFIG, family=INET,
    socktype=STREAM, protocol=TCP}): Name or service not known

On some systems this can be circumvented by using nss_wrapper from
<https://cwrap.org/nss_wrapper.html>:

    cat > hosts <<EOF
    127.0.0.1 localhost
    EOF
    bwrap \
    ... \
    env \
    LD_PRELOAD=libnss_wrapper.so \
    NSS_WRAPPER_HOSTS=$(pwd)/hosts \
    ${builddir}/test/test-loopback --tap
    ...
    # listening at tcp:host=127.0.0.1,port=39219,family=ipv4,guid=...

but for systems where that does't work, we should be prepared to skip
the affected tests.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106812
(cherry picked from commit f1faafd59bec67d347edb10447c4b9b18193458c)
test/corrupt.c
test/fdpass.c
test/internals/server-oom.c
test/loopback.c
test/relay.c
test/test-utils-glib.c
test/test-utils-glib.h