docs: add a simple example

This commit is contained in:
张泊明518370910136 2024-03-04 02:13:37 -05:00
parent b252a54a83
commit 6e2d37d7e5
GPG Key ID: D47306D7062CDA9D
3 changed files with 66 additions and 0 deletions

6
_example/simple/a.cc Normal file
View File

@ -0,0 +1,6 @@
#include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
std::cout << a + b << '\n';
}

52
_example/simple/conf.toml Normal file
View File

@ -0,0 +1,52 @@
[[stages]]
name = "compile"
[stages.executor]
name = "sandbox"
[stages.executor.with]
args = ["/usr/bin/g++", "a.cc", "-o", "a"]
env = ["PATH=/usr/bin:/bin"]
cpuLimit = 10_000_000_000
memoryLimit = 104_857_600
procLimit = 50
copyInCwd = true
copyOut = ["stdout", "stderr"]
copyOutCached = ["a"]
[[stages.executor.with.files]]
content = ""
[[stages.executor.with.files]]
name = "stdout"
max = 4_096
[[stages.executor.with.files]]
name = "stderr"
max = 4_096
[stages.parser]
name = "dummy"
[stages.parser.with]
score = 100
comment = "compile done"
[[stages]]
name = "run"
[stages.executor]
name = "sandbox"
[stages.executor.with]
args = ["./a"]
env = ["PATH=/usr/bin:/bin"]
cpuLimit = 10_000_000_000
memoryLimit = 104_857_600
procLimit = 50
copyOut = ["stdout", "stderr"]
[stages.executor.with.copyInCached]
a = "a"
[[stages.executor.with.files]]
content = "1 1"
[[stages.executor.with.files]]
name = "stdout"
max = 4_096
[[stages.executor.with.files]]
name = "stderr"
max = 4_096
[stages.parser]
name = "dummy"
[stages.parser.with]
score = 100
comment = "run done"

8
_example/simple/run.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -xe
DIRNAME=`dirname -- "$0"`
# cd to make CopyInCwd work
cd $DIRNAME
./../../build/joj3
cd -