Compare commits

...

1 Commits

Author SHA1 Message Date
Dmitry Kalinkin
74b43602bc libredirect: skip system() test when not in a sandbox 2023-02-14 12:13:34 -05:00
2 changed files with 16 additions and 6 deletions

View File

@@ -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 \

View File

@@ -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();