From 6e2d37d7e59b7577678f3b3b8f69367e903e10c8 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Mon, 4 Mar 2024 02:13:37 -0500 Subject: [PATCH] docs: add a simple example --- _example/simple/a.cc | 6 +++++ _example/simple/conf.toml | 52 +++++++++++++++++++++++++++++++++++++++ _example/simple/run.sh | 8 ++++++ 3 files changed, 66 insertions(+) create mode 100644 _example/simple/a.cc create mode 100644 _example/simple/conf.toml create mode 100755 _example/simple/run.sh diff --git a/_example/simple/a.cc b/_example/simple/a.cc new file mode 100644 index 0000000..2c7ca74 --- /dev/null +++ b/_example/simple/a.cc @@ -0,0 +1,6 @@ +#include +int main() { + int a, b; + std::cin >> a >> b; + std::cout << a + b << '\n'; +} diff --git a/_example/simple/conf.toml b/_example/simple/conf.toml new file mode 100644 index 0000000..a5ed250 --- /dev/null +++ b/_example/simple/conf.toml @@ -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" diff --git a/_example/simple/run.sh b/_example/simple/run.sh new file mode 100755 index 0000000..a964c9b --- /dev/null +++ b/_example/simple/run.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -xe +DIRNAME=`dirname -- "$0"` +# cd to make CopyInCwd work +cd $DIRNAME +./../../build/joj3 +cd -