module nspkg import nspkg.tests.signaturefixtures import os fn test_native_extraction_with_mapped_root_and_device_nodes() ! { $if linux { base := os.join_path(os.temp_dir(), 'alpm-extraction-namespace-${os.getpid()}') os.mkdir_all(base)! defer { os.rmdir_all(base) or { eprintln(err) } } probe := os.join_path(base, 'extraction-tests') os.symlink(@VMODROOT, os.join_path(base, 'nspkg'))! signaturefixtures.command('v', ['-path', base + '|@vlib', '-o', probe, os.join_path(@VMODROOT, 'engine', 'extraction_test.v')])! assert !signaturefixtures.command('ldd', [probe])!.contains('libalpm') mountpoint := os.join_path(base, 'private') os.mkdir(mountpoint)! // positional arguments keep paths out of shell code; mounts die with the namespace. output := signaturefixtures.command('timeout', ['60s', 'unshare', '--user', '--map-root-user', '--mount', '/bin/sh', '-c', r'test "$(readlink /proc/self/ns/mnt)" != "$3" && mount --make-rprivate / && mount -t tmpfs -o size=128m tmpfs "$1" && TMPDIR="$1" "$2" && printf "native extraction namespace verified\n"', 'extraction-probe', mountpoint, probe, os.readlink('/proc/self/ns/mnt')!])! assert output.contains('native extraction namespace verified') } }