Changeset cf4e708 in mod_gnutls for test/common.bash


Ignore:
Timestamp:
Jan 23, 2016, 5:11:43 PM (4 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
debian/master, debian/stretch-backports, jessie-backports, master, upstream
Children:
ddf6027
Parents:
bca7629
Message:

Run tests in separate network namespaces

Creating a network namespace for each test avoids port conflicts so
Apache instances can run in parallel, and also isolates the tests from
the host system.

Test namespaces are automatically used if the "unshare" command is
available, and can be disabled by passing "--disable-test-namespaces"
to ./configure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/common.bash

    rbca7629 rcf4e708  
    1616    done
    1717}
     18
     19
     20
     21# Usage: netns_reexec ${@}
     22#
     23# If USE_TEST_NAMESPACE is set and MGS_NETNS_ACTIVE is not, exec the
     24# running command inside a new namespace with active loopback
     25# interface and MGS_NETNS_ACTIVE defined. This function can be used to
     26# isolate each testcase inside its own network namespace. Since
     27# MGS_NETNS_ACTIVE is used to track status, there's no harm in calling
     28# it multiple times (e.g. in the test-* script and runtests).
     29function netns_reexec
     30{
     31    if [ -n "${USE_TEST_NAMESPACE}" ] && [ -z "${MGS_NETNS_ACTIVE}" ]; then
     32        exec "${UNSHARE}" --net -r /bin/bash -c \
     33             "export MGS_NETNS_ACTIVE=1; ip link set up lo; exec ${0} ${@}"
     34    fi
     35    return 0
     36}
Note: See TracChangeset for help on using the changeset viewer.