Add -DUSE_BWRAP option, defaulting to OFF
Bubblewrap (https://github.com/containers/bubblewrap) is
an unprivileged sandbox. It allows running tests in parallel,
without any port clashes with already running servers.
@@ -64,7 +64,18 @@ target_link_libraries(test-receiver ${Proton_LIBRARIES})
add_executable(clogger clogger.c)
target_link_libraries(clogger ${Proton_LIBRARIES})
-set(TEST_WRAP ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/run.py)
+# Bubblewrap is an unprivileged sandboxing tool for Linux. Setting --unshare-net allows
+# running tests in parallel (the ctest -j option) without port clashes
+set(USE_BWRAP OFF CACHE BOOL "Wrap test executions with bwrap (https://github.com/containers/bubblewrap)")
+if(USE_BWRAP)
+ # Inaccessible DNS servers produce "proton:io Temporary failure in name resolution".
+ # For system_tests_bad_configuration we need to get "proton:io Name or service not known",
+ # so blank /etc/nsswitch.conf to achieve that.
+ set(BWRAP_ARGS bwrap --bind / / --bind /dev/zero /etc/nsswitch.conf --unshare-net --dev /dev --die-with-parent --)
+else()
+ set(BWRAP_ARGS "")
+endif()
+set(TEST_WRAP ${BWRAP_ARGS} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/run.py)
add_test(unit_tests_size_10000 ${TEST_WRAP} unit_tests_size 10000)
add_test(unit_tests_size_512 ${TEST_WRAP} unit_tests_size 512)
