module coracle import os fn sandbox_download_command(executable string, args []string) !string { mut process := os.new_process(executable) process.set_args(args) process.set_redirect_stdio() process.run() defer { process.close() } output := process.stdout_slurp() diagnostic := process.stderr_slurp() process.wait() if process.code != 0 { return error('${executable} ${args} failed ${process.code}: ${diagnostic}\n${output}') } return output } fn test_sandboxed_transport_matches_libalpm_and_keeps_callbacks_in_parent() ! { $if linux { dir := os.join_path(os.temp_dir(), 'alpm-sandbox-download-${os.getpid()}') os.mkdir_all(dir, mode: 0o755)! defer { os.rmdir_all(dir) or { eprintln(err) } } probe := os.join_path(dir, 'probe') sandbox_download_command('v', ['-path', os.dir(@VMODROOT) + '|@vlib|@vmodules', '-o', probe, os.join_path(@VMODROOT, 'tests', 'sandbox_download_probe.v')])! for fs in ['on', 'off'] { for syscalls in ['on', 'off'] { base := os.join_path(dir, '${fs}-${syscalls}') os.mkdir_all(base, mode: 0o755)! output := sandbox_download_command('timeout', ['30s', 'unshare', '--user', '--map-root-user', '--map-auto', '--setgroups=allow', probe, base, fs, syscalls])! assert output.contains('sandbox downloads verified') } } } }