nspkg / file_conflict_mount_test.v
20 lines · 18 sloc · 819 bytes · c01b0795d1db56c7bce2539b2c46b110637fdc1a
Raw
1module nspkg
2
3import nspkg.tests.signaturefixtures
4import os
5
6fn test_native_file_preflight_handles_cyclic_directory_mounts() ! {
7 $if linux {
8 base := os.join_path(os.temp_dir(), 'alpm-file-conflict-mounts-${os.getpid()}')
9 os.mkdir_all(base)!
10 defer { os.rmdir_all(base) or { eprintln(err) } }
11 probe := os.join_path(base, 'probe')
12 signaturefixtures.command('v', ['-o', probe,
13 os.join_path(@VMODROOT, 'tests', 'file_conflict_mount_probe.v')])!
14 dependencies := signaturefixtures.command('ldd', [probe])!
15 assert !dependencies.contains('libalpm')
16 output := signaturefixtures.command('timeout', ['20s', 'unshare', '--user', '--map-root-user',
17 '--mount', probe, base, os.readlink('/proc/self/ns/mnt')!])!
18 assert output.contains('native file preflight rejects cyclic bind mounts without mutation')
19 }
20}
21