summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kalinkin <dmitry.kalinkin@gmail.com>2023-02-14 12:13:34 -0500
committerDmitry Kalinkin <dmitry.kalinkin@gmail.com>2023-02-14 12:13:34 -0500
commit74b43602bc49d750715de5059102feadb34e5995 (patch)
treec8925783ee05c69dd50cce8d21e84d689a6a1d8f
parentMerge pull request #214207 from Artturin/ssytemdbuildbash1 (diff)
downloadnixpkgs-origin/pr/libredirect_system_test.tar.gz
libredirect: skip system() test when not in a sandboxorigin/pr/libredirect_system_test
-rw-r--r--pkgs/build-support/libredirect/default.nix19
-rw-r--r--pkgs/build-support/libredirect/test.c3
2 files changed, 16 insertions, 6 deletions
diff --git a/pkgs/build-support/libredirect/default.nix b/pkgs/build-support/libredirect/default.nix
index 6e2de7fa11b0..0536d8f6aa6b 100644
--- a/pkgs/build-support/libredirect/default.nix
+++ b/pkgs/build-support/libredirect/default.nix
@@ -32,6 +32,14 @@ else stdenv.mkDerivation rec {
buildPhase = ''
runHook preBuild
+ ENABLE_TEST_SYSTEM=1
+ if [ "$(cat /proc/self/uid_map)" = " 0 0 4294967295" ]; then
+ echo "Boot namespace detected! Disabling tests that use system()."
+ echo "The system() relies on /bin/sh which may not be compatible with nixpkgs's"
+ echo "glibc, so we can't test this without the sandboxing isolation."
+ ENABLE_TEST_SYSTEM=0
+ fi
+
${if stdenv.isDarwin && stdenv.isAarch64 then ''
# We need the unwrapped binutils and clang:
# We also want to build a fat library with x86_64, arm64, arm64e in there.
@@ -45,16 +53,15 @@ else stdenv.mkDerivation rec {
-isystem ${llvmPackages_13.libclang.lib}/lib/clang/*/include \
-L${llvmPackages_13.clang.libc}/lib \
-Wl,-install_name,$libName \
- -Wall -std=c99 -O3 -fPIC libredirect.c \
- -shared -o "$libName"
'' else if stdenv.isDarwin then ''
- $CC -Wall -std=c99 -O3 -fPIC libredirect.c \
+ $CC \
-Wl,-install_name,$out/lib/$libName \
- -shared -o "$libName"
'' else ''
- $CC -Wall -std=c99 -O3 -fPIC libredirect.c \
+ $CC \
+ ''} \
+ -Wall -std=c99 -O3 -fPIC libredirect.c \
+ -DENABLE_TEST_SYSTEM=$ENABLE_TEST_SYSTEM \
-shared -o "$libName"
- ''}
if [ -n "$doInstallCheck" ]; then
$CC -Wall -std=c99 \
diff --git a/pkgs/build-support/libredirect/test.c b/pkgs/build-support/libredirect/test.c
index 7dd384ae3ed7..8eb92ef555c5 100644
--- a/pkgs/build-support/libredirect/test.c
+++ b/pkgs/build-support/libredirect/test.c
@@ -146,6 +146,8 @@ int main(int argc, char *argv[])
assert_mktemp_path(TESTDIR "/temp", "", buf);
test_spawn();
+
+#if ENABLE_TEST_SYSTEM
test_system();
// Only run subprocess if no arguments are given
@@ -154,6 +156,7 @@ int main(int argc, char *argv[])
if (argc == 1) {
test_subprocess();
}
+#endif
test_execv();