| 1 | module coracle |
| 2 | |
| 3 | import nspkg.tests.signaturefixtures |
| 4 | import os |
| 5 | |
| 6 | fn C.geteuid() u32 |
| 7 | |
| 8 | fn test_extraction_metadata_warnings_match_libalpm() ! { |
| 9 | $if !linux { |
| 10 | return |
| 11 | } |
| 12 | base := os.join_path(os.vtmp_dir(), 'alpm-extraction-metadata-${os.getpid()}') |
| 13 | os.mkdir_all(base)! |
| 14 | defer { os.rmdir_all(base) or { eprintln(err) } } |
| 15 | probe := os.join_path(base, 'probe') |
| 16 | signaturefixtures.command('v', ['-path', os.dir(@VMODROOT) + '|@vlib|@vmodules', '-o', probe, |
| 17 | os.join_path(@VMODROOT, 'tests/extraction_metadata_probe.v')])! |
| 18 | rooted := os.join_path(base, 'namespace') |
| 19 | os.mkdir(rooted)! |
| 20 | output := signaturefixtures.command('timeout', ['90s', 'unshare', '--user', '--map-root-user', |
| 21 | '--mount', probe, rooted, os.readlink('/proc/self/ns/mnt')!])! |
| 22 | assert output.contains('96 extraction metadata comparisons verified') |
| 23 | assert output.contains('native metadata failure and inode guards verified') |
| 24 | if C.geteuid() != 0 { |
| 25 | ordinary := os.join_path(base, 'ordinary') |
| 26 | os.mkdir(ordinary)! |
| 27 | result := signaturefixtures.command('timeout', ['90s', probe, ordinary, 'ordinary-user'])! |
| 28 | assert result.contains('96 extraction metadata comparisons verified') |
| 29 | assert result.contains('native metadata failure and inode guards verified') |
| 30 | } |
| 31 | } |
| 32 | |