Compare commits
3 Commits
05b3d948c2
...
fca3fc678c
Author | SHA1 | Date | |
---|---|---|---|
fca3fc678c | |||
9fe69280f9 | |||
2b84f94abb |
2
.github/workflows/container.yml
vendored
2
.github/workflows/container.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
||||
path: |
|
||||
~/.local/share/containers
|
||||
~/.config/containers
|
||||
key: ${{ runner.os }}
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/*.Dockerfile', 'build_image.sh', 'VERSION') }}
|
||||
- name: Login to Container Registry
|
||||
uses: redhat-actions/podman-login@v1
|
||||
with:
|
||||
|
@ -68,6 +68,11 @@ func (s *service) Compile(meta *JudgeMeta) (*JudgeStatus, e.Status) {
|
||||
Destination: "/woj/problem/judge",
|
||||
Readonly: true,
|
||||
},
|
||||
{
|
||||
// Rust will write intermediate files into source directory instead of /tmp
|
||||
Source: "",
|
||||
Destination: "/woj/user",
|
||||
},
|
||||
{
|
||||
Source: sourceFile,
|
||||
Destination: fmt.Sprintf("/woj/user/%s.%s", meta.Run.User, meta.Run.Lang),
|
||||
@ -109,5 +114,5 @@ func (s *service) Compile(meta *JudgeMeta) (*JudgeStatus, e.Status) {
|
||||
// 5. grant permission
|
||||
_ = os.Chmod(targetFile, 0755)
|
||||
|
||||
return &JudgeStatus{CompileMessage: msgText}, e.Success
|
||||
return &JudgeStatus{CompileMessage: msgText}, status
|
||||
}
|
||||
|
@ -35,7 +35,10 @@ type MountInfo struct {
|
||||
|
||||
func (m *MountInfo) Args() []string {
|
||||
mapping := m.Source + ":" + m.Destination
|
||||
if m.Readonly {
|
||||
if m.Source == "" {
|
||||
// 64MB tmpfs
|
||||
return []string{"-m", "none:" + m.Destination + ":tmpfs:size=67108864"}
|
||||
} else if m.Readonly {
|
||||
return []string{"-R", mapping}
|
||||
} else {
|
||||
return []string{"-B", mapping}
|
||||
@ -112,8 +115,9 @@ func (s *service) JailRun(arg *RunArgs) (RuntimeStatus, error) {
|
||||
args := []string{
|
||||
"--quiet",
|
||||
"--use_cgroupv2",
|
||||
"-T", "/tmp",
|
||||
"-E", "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin",
|
||||
"--disable_rlimits", // Rust requires this
|
||||
"-m", "none:/tmp:tmpfs:size=67108864", // 64MB tmpfs
|
||||
"-E", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
// following envs must sync with resource/runner
|
||||
"-E", "WOJ_LAUNCHER=/woj/framework/scripts/woj_launcher",
|
||||
"-E", "TEMPLATE=/woj/framework/template",
|
||||
|
1
resource/runner/framework/rootfs/.gitignore
vendored
1
resource/runner/framework/rootfs/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/full
|
||||
/run
|
||||
*.tar
|
||||
|
@ -1,2 +1,2 @@
|
||||
GO=/usr/local/go/bin/go
|
||||
GO=/usr/bin/go
|
||||
GO_BUILD_FLAGS=-trimpath
|
1
resource/runner/framework/template/nodejs.mk
Normal file
1
resource/runner/framework/template/nodejs.mk
Normal file
@ -0,0 +1 @@
|
||||
NODEJS=/usr/bin/node
|
@ -1,2 +1,2 @@
|
||||
RUSTC = /root/.cargo/bin/rustc
|
||||
RUSTC = /usr/bin/rustc
|
||||
RUSTFLAGS = -C opt-level=2 -W warnings
|
@ -27,7 +27,7 @@
|
||||
"Lang" : "pypy3",
|
||||
"Judge" : {"Type": "default", "Script": "", "Cmp": "NCMP"},
|
||||
"Runtime": {
|
||||
"Run": {"TimeLimit": 1000, "MemoryLimit": 80, "NProcLimit": 1}
|
||||
"Run": {"TimeLimit": 1000, "MemoryLimit": 70, "NProcLimit": 1}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -31,11 +31,13 @@ include ${TEMPLATE}/c.mk ${TEMPLATE}/Judger.mk
|
||||
# 其余通用环境变量,详见 nsjail.go
|
||||
|
||||
compile:
|
||||
# /woj/user 目录当且仅当 compile 阶段为 RW
|
||||
$(CC) $(CFLAGS) -o $(PREFIX)/user/$(USER_PROG).out $(PREFIX)/user/$(USER_PROG).$(LANG) $(PREFIX)/problem/judge/gadget.c
|
||||
|
||||
judge:
|
||||
# !! Rename on *.out.usr or *.judge is not allowed !!
|
||||
# 自定义评测方式
|
||||
sed '/gadgets/d' $(PREFIX)/user/$(TEST_NUM).out.usr >$(PREFIX)/user/$(TEST_NUM).out.usr1
|
||||
# 特别注意:整个文件系统为 readonly filesystem,临时文件只能放在 /tmp 下
|
||||
sed '/gadgets/d' $(PREFIX)/user/$(TEST_NUM).out.usr > /tmp/$(TEST_NUM).out.usr1
|
||||
# 评测结果要求符合 testlib 的格式 -> $(TEST_NUM).judge
|
||||
$(NCMP) $(PREFIX)/problem/data/input/$(TEST_NUM).input $(PREFIX)/user/$(TEST_NUM).out.usr1 $(PREFIX)/problem/data/output/$(TEST_NUM).output $(PREFIX)/user/$(TEST_NUM).judge -appes
|
||||
$(NCMP) $(PREFIX)/problem/data/input/$(TEST_NUM).input /tmp/$(TEST_NUM).out.usr1 $(PREFIX)/problem/data/output/$(TEST_NUM).output $(PREFIX)/user/$(TEST_NUM).judge -appes
|
||||
|
7
resource/runner/problem/example/std/ans.c
Normal file
7
resource/runner/problem/example/std/ans.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include<stdio.h>
|
||||
int main() {
|
||||
long long a, b;
|
||||
scanf("%lld%lld", &a, &b);
|
||||
printf("%lld\n", a + b);
|
||||
return 0;
|
||||
}
|
8
resource/runner/problem/example/std/ans.cpp
Normal file
8
resource/runner/problem/example/std/ans.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
long long a, b;
|
||||
cin >> a >> b;
|
||||
cout << a + b << endl;
|
||||
return 0;
|
||||
}
|
1
resource/runner/problem/example/std/ans.py
Normal file
1
resource/runner/problem/example/std/ans.py
Normal file
@ -0,0 +1 @@
|
||||
print(sum(map(int, input().strip().split())))
|
15
resource/runner/problem/example/std/ans.rs
Normal file
15
resource/runner/problem/example/std/ans.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
let mut input = String::new();
|
||||
io::stdin().read_line(&mut input).unwrap();
|
||||
|
||||
let nums: Vec<i32> = input
|
||||
.trim()
|
||||
.split_whitespace()
|
||||
.map(|num| num.parse().unwrap())
|
||||
.collect();
|
||||
|
||||
let sum = nums[0] + nums[1];
|
||||
println!("{}", sum);
|
||||
}
|
@ -1,20 +1,15 @@
|
||||
FROM docker.io/library/debian:bookworm-slim
|
||||
WORKDIR /woj
|
||||
|
||||
# Install dependencies & languages: c/cpp/python3/pypy3
|
||||
RUN apt-get update && apt-get upgrade -y && apt-get install -y software-properties-common \
|
||||
# RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list.d/debian.sources
|
||||
|
||||
# Install dependencies & languages: c/cpp/python3/pypy3/go/rust/nodejs
|
||||
RUN apt-get update && apt-get upgrade -y \
|
||||
&& apt-get install -y \
|
||||
git parallel wget curl \
|
||||
autoconf bison cmake flex gperf libnl-route-3-dev libprotobuf-dev libtool m4 make pkg-config protobuf-compiler \
|
||||
gcc g++ clang \
|
||||
python3 pypy3 \
|
||||
gcc g++ clang python3 pypy3 golang-go rustc nodejs \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists
|
||||
# Install golang
|
||||
RUN wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz && rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.1.linux-amd64.tar.gz && rm go1.22.1.linux-amd64.tar.gz
|
||||
# Install Rust
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
# Setup PATH
|
||||
ENV PATH=/usr/local/go/bin:/root/.cargo/bin:$PATH
|
||||
|
||||
# Copy source code
|
||||
RUN mkdir -p /woj/framework && mkdir -p /woj/problem
|
||||
|
Loading…
Reference in New Issue
Block a user