diff options
author | Tim Beale <timbeale@catalyst.net.nz> | 2019-05-23 17:44:37 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-05-31 05:18:20 +0000 |
commit | 067b4fc03fec20e944eac2645f400471f2bc0b21 (patch) | |
tree | 7a8fd4b4434da4411d4607922d6b4dcc9768aafc /selftest/wscript | |
parent | c9e62513822fa5fce9ad29c164273a2db64ff18d (diff) | |
download | samba-067b4fc03fec20e944eac2645f400471f2bc0b21.tar.gz |
selftest: Add linux namespace support (USE_NAMESPACES=1)
This hooks up the selftest/ns/* scripts added earlier with the selftest
system, so developers can optionally run a testenv or test using linux
namespaces instead of socket-wrapper.
The idea is this is experimental functionality that we can extend
further in future, in order to make testing Samba more versatile.
+ The top-level WAF script now does an 'unshare' to create a new
top-level 'selftest' namespace in which to create the testenv(s).
+ selftest.pl creates a common 'selftest0' bridge to connect together
the individual DCs.
+ Update Samba.pm so it can use real IPs instead of loopback addresses.
In fork_and_exec(), we add a couple of hooks so that the binary gets
started in a different namespace (using unshare/start_in_ns.sh), and
the parent process connects the new child namespace up to the common
selftest0 bridge (using add_bridge_iface.sh).
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'selftest/wscript')
-rw-r--r-- | selftest/wscript | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/selftest/wscript b/selftest/wscript index 5c864ebed96..f204f34201b 100644 --- a/selftest/wscript +++ b/selftest/wscript @@ -246,9 +246,12 @@ def cmd_testonly(opt): env.OPTIONS += " --nss_wrapper_so_path=" + CONFIG_GET(opt, 'LIBNSS_WRAPPER_SO_PATH') env.OPTIONS += " --resolv_wrapper_so_path=" + CONFIG_GET(opt, 'LIBRESOLV_WRAPPER_SO_PATH') - env.OPTIONS += " --socket_wrapper_so_path=" + CONFIG_GET(opt, 'LIBSOCKET_WRAPPER_SO_PATH') env.OPTIONS += " --uid_wrapper_so_path=" + CONFIG_GET(opt, 'LIBUID_WRAPPER_SO_PATH') + # selftest can optionally use kernel namespaces instead of socket-wrapper + if os.environ.get('USE_NAMESPACES') is None: + env.OPTIONS += " --socket_wrapper_so_path=" + CONFIG_GET(opt, 'LIBSOCKET_WRAPPER_SO_PATH') + #if unversioned_sys_platform in ('freebsd', 'netbsd', 'openbsd', 'sunos'): # env.OPTIONS += " --use-dns-faking" @@ -277,6 +280,13 @@ def cmd_testonly(opt): # We use the full path rather than relative path to avoid problems on some platforms (ie. solaris 8). env.CORE_COMMAND = '${PERL} ${srcdir}/selftest/selftest.pl --target=${SELFTEST_TARGET} --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/selftest/skip ${TESTLISTS} ${OPTIONS} ${TESTS}' + # If using namespaces (rather than socket-wrapper), run the selftest script + # in its own network namespace (by doing an 'unshare'). (To create a new + # namespace as a non-root user, we have to also unshare the current user + # namespace, and remap ourself as root in the namespace created) + if os.environ.get('USE_NAMESPACES') is not None: + env.CORE_COMMAND = 'unshare --net --user --map-root-user ' + env.CORE_COMMAND + if env.ADDRESS_SANITIZER: # For now we cannot run with leak detection no_leak_check = "ASAN_OPTIONS=detect_leaks=0" |