feat(runner): compile Go and check answers per test group

This commit is contained in:
shira committed 2026-10-11 08:59:29 +03:00
1 parent e95c681165
commit afee564bf4
61 files changed
+2592 -143

No files matched your search

+25 -4
View File
@@ -5,6 +5,7 @@ import (
"bytes"
"math"
"regexp"
"slices"
"strconv"
"time"
)
@@ -34,7 +35,7 @@ func nsjailArgs(cfg Config, spec Spec, limits Limits, seccompPolicy string) []st
"--mode", "o",
"--log_fd", strconv.Itoa(nsjailLogFD),
"--hostname", sandboxHostname,
"--cwd", ScratchPath,
"--cwd", workDir(spec),
// Inside and outside the user namespace the program is the same
// unprivileged ID, never root.
"--user", idMapping(cfg.SandboxUID),
@@ -42,7 +43,7 @@ func nsjailArgs(cfg Config, spec Spec, limits Limits, seccompPolicy string) []st
"--time_limit", strconv.Itoa(ceilSeconds(limits.WallTime + nsjailTimeBackstop)),
"--rlimit_as", strconv.Itoa(addressSpaceLimitMB),
"--rlimit_cpu", strconv.Itoa(ceilSeconds(limits.CPUTime + cpuRlimitBackstop)),
"--rlimit_fsize", strconv.Itoa(ceilMB(cfg.FileSizeBytes)),
"--rlimit_fsize", strconv.Itoa(ceilMB(fileSizeLimit(cfg, limits))),
"--rlimit_nofile", strconv.Itoa(cfg.OpenFiles),
"--rlimit_core", "0",
"--disable_proc",
@@ -54,19 +55,39 @@ func nsjailArgs(cfg Config, spec Spec, limits Limits, seccompPolicy string) []st
for _, mount := range cfg.ReadOnlyMounts {
args = append(args, "--bindmount_ro", mount)
}
for _, mount := range spec.Mounts {
flag := "--bindmount_ro"
if mount.Writable {
flag = "--bindmount"
}
args = append(args, flag, mount.Source+":"+mount.Target)
}
args = append(args,
"--bindmount_ro", spec.BoxDir+":"+BoxPath,
"--bindmount", "/dev/null",
"--bindmount_ro", "/dev/urandom",
"--mount", "none:"+ScratchPath+":tmpfs:size="+strconv.FormatInt(cfg.TmpfsBytes, 10),
)
for _, variable := range cfg.Env {
for _, variable := range append(slices.Clone(cfg.Env), spec.Env...) {
args = append(args, "--env", variable)
}
args = append(args, "--")
return append(args, spec.Argv...)
}
func workDir(spec Spec) string {
if spec.WorkDir != "" {
return spec.WorkDir
}
return ScratchPath
}
func fileSizeLimit(cfg Config, limits Limits) int64 {
if limits.FileSizeBytes > 0 {
return limits.FileSizeBytes
}
return cfg.FileSizeBytes
}
func idMapping(id int) string {
value := strconv.Itoa(id)
return value + ":" + value + ":1"