| 1 | module nspkg |
| 2 | |
| 3 | import nspkg.tests.signaturefixtures |
| 4 | import os |
| 5 | |
| 6 | fn test_native_extraction_with_mapped_root_and_device_nodes() ! { |
| 7 | $if linux { |
| 8 | base := os.join_path(os.temp_dir(), 'alpm-extraction-namespace-${os.getpid()}') |
| 9 | os.mkdir_all(base)! |
| 10 | defer { os.rmdir_all(base) or { eprintln(err) } } |
| 11 | probe := os.join_path(base, 'extraction-tests') |
| 12 | os.symlink(@VMODROOT, os.join_path(base, 'nspkg'))! |
| 13 | signaturefixtures.command('v', ['-path', base + '|@vlib', '-o', probe, |
| 14 | os.join_path(@VMODROOT, 'engine', 'extraction_test.v')])! |
| 15 | assert !signaturefixtures.command('ldd', [probe])!.contains('libalpm') |
| 16 | mountpoint := os.join_path(base, 'private') |
| 17 | os.mkdir(mountpoint)! |
| 18 | // positional arguments keep paths out of shell code; mounts die with the namespace. |
| 19 | output := signaturefixtures.command('timeout', ['60s', 'unshare', '--user', '--map-root-user', |
| 20 | '--mount', '/bin/sh', '-c', |
| 21 | 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"', |
| 22 | 'extraction-probe', mountpoint, probe, os.readlink('/proc/self/ns/mnt')!])! |
| 23 | assert output.contains('native extraction namespace verified') |
| 24 | } |
| 25 | } |
| 26 | |