Documentation
¶
Index ¶
- Constants
- Variables
- func CleanCompilation(subid int) error
- func CopyInBox(b Sandbox, p1 string, p2 string) error
- func GetLangByFilename(filename string) string
- func Initialize() error
- func MakeGoodCommand(command []string) ([]string, error)
- type BoxScheduler
- type Checker
- type CompileRequest
- type CompileResponse
- type Directory
- type ExecRequest
- type ExecResponse
- type Language
- type RunConfig
- type RunStats
- type Sandbox
- type Task
Constants ¶
View Source
const MAGIC_REPLACE = "<REPLACE>"
Variables ¶
View Source
var Langs = map[string]Language{ "c": { Extensions: []string{".c"}, Compiled: true, PrintableName: "C", InternalName: "c", CompileCommand: []string{"gcc", "-fuse-ld=mold", "-std=c11", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MAGIC_REPLACE, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.c", CompiledName: "/box/output", Mounts: []Directory{{In: "/etc"}}, }, "cpp": { Extensions: []string{".cpp", ".c++", ".cc", ".cxx", ".cpp11"}, Compiled: true, PrintableName: "C++11", InternalName: "cpp", CompileCommand: []string{"g++", "-fuse-ld=mold", "-std=c++11", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MAGIC_REPLACE, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.cpp", CompiledName: "/box/output", Mounts: []Directory{{In: "/etc"}}, }, "cpp14": { Extensions: []string{".cpp", ".c++", ".cc", ".cxx", ".cpp14"}, Compiled: true, PrintableName: "C++14", InternalName: "cpp14", CompileCommand: []string{"g++", "-fuse-ld=mold", "-std=c++14", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MAGIC_REPLACE, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.cpp", CompiledName: "/box/output", Mounts: []Directory{{In: "/etc"}}, }, "cpp17": { Extensions: []string{".cpp", ".c++", ".cc", ".cxx", ".cpp17"}, Compiled: true, PrintableName: "C++17", InternalName: "cpp17", CompileCommand: []string{"g++", "-fuse-ld=mold", "-std=c++17", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MAGIC_REPLACE, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.cpp", CompiledName: "/box/output", Mounts: []Directory{{In: "/etc"}}, }, "cpp20": { Extensions: []string{".cpp", ".c++", ".cc", ".cxx", ".cpp20"}, Compiled: true, PrintableName: "C++20", InternalName: "cpp20", CompileCommand: []string{"g++", "-fuse-ld=mold", "-std=c++20", "-O2", "-s", "-static", "-DKNOVA", "-DONLINE_JUDGE", MAGIC_REPLACE, "-o", "/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.cpp", CompiledName: "/box/output", Mounts: []Directory{{In: "/etc"}}, }, "pascal": { Extensions: []string{".pas"}, Compiled: true, PrintableName: "Pascal", InternalName: "pascal", CompileCommand: []string{"fpc", "-O2", "-XSst", "-Mobjfpc", "-vw", "-dKNOVA", "-dONLINE_JUDGE", MAGIC_REPLACE, "-o/box/output"}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.pas", CompiledName: "/box/output", Mounts: []Directory{{In: "/etc"}}, }, "golang": { Extensions: []string{".go"}, Compiled: true, PrintableName: "Go", InternalName: "golang", CompileCommand: []string{"/usr/bin/go", "build", MAGIC_REPLACE}, RunCommand: []string{"/box/main"}, SourceName: "/box/main.go", CompiledName: "/box/main", BuildEnv: map[string]string{"GOMAXPROCS": "1", "CGO_ENABLED": "0", "GOCACHE": "/go/cache", "GOPATH": "/box", "GO111MODULE": "off"}, RunEnv: map[string]string{"GOMAXPROCS": "1"}, Mounts: []Directory{{In: "/go", Opts: "tmp", Verbatim: true}}, }, "haskell": { Disabled: true, Extensions: []string{".hs", ".lhs"}, Compiled: true, PrintableName: "Haskell", InternalName: "haskell", CompileCommand: []string{"ghc", "-o", "/box/output", MAGIC_REPLACE}, RunCommand: []string{"/box/output"}, SourceName: "/box/main.hs", CompiledName: "/box/output", }, "java": { Disabled: true, Extensions: []string{".java"}, Compiled: true, PrintableName: "Java", InternalName: "java", CompileCommand: []string{"javac", MAGIC_REPLACE}, RunCommand: []string{"java", "Main"}, SourceName: "/Main.java", CompiledName: "/Main.class", Mounts: []Directory{{In: "/etc"}}, }, "python3": { Extensions: []string{".py", ".py3"}, Compiled: false, PrintableName: "Python 3", InternalName: "python3", RunCommand: []string{"python3", "/box/main.py"}, SourceName: "/box/main.py", CompiledName: "/box/main.py", }, "outputOnly": { Extensions: []string{".output_only"}, Compiled: false, PrintableName: "Output Only", InternalName: "outputOnly", RunCommand: []string{"cat", "/box/output"}, SourceName: "/box/output_src", CompiledName: "/box/output", }, }
NOTE: Last extension MUST be unique (for proper detection of submissions in problem archives)
Functions ¶
func CleanCompilation ¶
func GetLangByFilename ¶
func Initialize ¶
func Initialize() error
Initialize should be called after reading the flags, but before manager.New
func MakeGoodCommand ¶
makeGoodCommand makes sure it's a full path (with no symlinks) for the command. Some languages (like java) are hidden pretty deep in symlinks, and we don't want a hardcoded path that could be different on other platforms.
Types ¶
type BoxScheduler ¶
type Checker ¶
type Checker interface {
Prepare(context.Context) (string, error)
Cleanup(context.Context) error
// RunChecker returns a comment and a decimal number [0, 100] signifying the percentage of correctness of the subtest
RunChecker(ctx context.Context, programOut, correctInput, correctOut io.Reader) (string, decimal.Decimal)
}
Checker is an interface for a function that statelessly tries to evaluate a subtest from a submission
type CompileRequest ¶
type CompileResponse ¶
type Directory ¶
type Directory struct {
In string `toml:"in"`
Out string `toml:"out"`
Opts string `toml:"opts"`
Removes bool `toml:"removes"`
// Verbatim doesn't set Out to In implicitly if it isn't set
Verbatim bool `toml:"verbatim"`
}
Directory represents a directory rule
type ExecRequest ¶
type ExecResponse ¶
type Language ¶
type Language struct {
Disabled bool
// Useful to categorize by file upload
Extensions []string
Compiled bool
PrintableName string
InternalName string
CompileCommand []string `toml:"compile_command"`
RunCommand []string `toml:"run_command"`
BuildEnv map[string]string `toml:"build_env"`
RunEnv map[string]string `toml:"run_env"`
// Mounts represents all directories to be mounted
Mounts []Directory `toml:"mounts"`
SourceName string `toml:"source_name"`
CompiledName string `toml:"compiled_name"`
}
Language is the data available for a language
type Sandbox ¶
type Sandbox interface {
// ReadFile reads contents of path from sandbox and pipes them to the given writer
ReadFile(path string, w io.Writer) error
WriteFile(path string, r io.Reader, mode fs.FileMode) error
// RemoveFile(path string) error
FileExists(path string) bool
GetID() int
MemoryQuota() int64
// if stdout == stderr, then it will act like exec.CombinedOutput()
RunCommand(ctx context.Context, cmd []string, conf *RunConfig) (*RunStats, error)
io.Closer
}
Click to show internal directories.
Click to hide internal directories.