Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
2
2026ustc-jianmu-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
832
Issues
832
List
Boards
Labels
Service Desk
Milestones
Merge Requests
52
Merge Requests
52
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
compiler_staff
2026ustc-jianmu-compiler
Commits
8ca8504d
Commit
8ca8504d
authored
Oct 13, 2026
by
王宇航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Harden Lab2 evaluation scripts
parent
7926be65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
tests/2-ir-gen/autogen/eval_lab2.py
tests/2-ir-gen/autogen/eval_lab2.py
+20
-4
tests/2-ir-gen/autogen/eval_lab2.sh
tests/2-ir-gen/autogen/eval_lab2.sh
+1
-0
No files found.
tests/2-ir-gen/autogen/eval_lab2.py
View file @
8ca8504d
#!/usr/bin/env python3
from
pathlib
import
Path
import
subprocess
# 17
lv0_1
=
{
...
...
@@ -110,6 +111,11 @@ suite = [
]
def
cleanup_case
(
test_path
):
for
path
in
(
test_path
,
test_path
+
".o"
,
test_path
+
".ll"
):
Path
(
path
).
unlink
(
missing_ok
=
True
)
def
eval
():
f
=
open
(
"eval_result"
,
'w'
)
EXE_PATH
=
"../../../build/cminusfc"
...
...
@@ -129,6 +135,7 @@ def eval():
ANSWER_PATH
=
ANSWER_BASE_PATH
+
level_name
+
"/"
+
case
score
=
cases
[
case
][
0
]
need_input
=
cases
[
case
][
1
]
cleanup_case
(
TEST_PATH
)
COMMAND
=
[
TEST_PATH
]
...
...
@@ -136,12 +143,21 @@ def eval():
result
=
subprocess
.
run
([
EXE_PATH
,
"-o"
,
TEST_PATH
+
".ll"
,
"-emit-llvm"
,
TEST_PATH
+
".cminus"
],
stderr
=
subprocess
.
PIPE
,
timeout
=
1
)
except
Exception
as
_
:
cleanup_case
(
TEST_PATH
)
f
.
write
(
'
\t
Fail
\n
'
)
continue
if
result
.
returncode
==
0
:
subprocess
.
run
([
"clang"
,
"-O0"
,
"-w"
,
"-no-pie"
,
TEST_PATH
+
".ll"
,
"-o"
,
TEST_PATH
,
"-L"
,
"../../../build"
,
"-lcminus_io"
])
try
:
compile_result
=
subprocess
.
run
([
"clang"
,
"-O0"
,
"-w"
,
"-no-pie"
,
TEST_PATH
+
".ll"
,
"-o"
,
TEST_PATH
,
"-L"
,
"../../../build"
,
"-lcminus_io"
])
except
OSError
:
compile_result
=
None
if
compile_result
is
None
or
compile_result
.
returncode
!=
0
:
f
.
write
(
'
\t
Fail
\n
'
)
has_bonus
=
False
cleanup_case
(
TEST_PATH
)
continue
input_option
=
None
if
need_input
:
with
open
(
ANSWER_PATH
+
".in"
,
"rb"
)
as
fin
:
...
...
@@ -161,10 +177,10 @@ def eval():
f
.
write
(
'
\t
Fail
\n
'
)
has_bonus
=
False
finally
:
subprocess
.
call
(
[
"rm"
,
"-rf"
,
TEST_PATH
,
TEST_PATH
+
".o"
,
TEST_PATH
+
".ll"
])
cleanup_case
(
TEST_PATH
)
else
:
cleanup_case
(
TEST_PATH
)
f
.
write
(
'
\t
Fail
\n
'
)
has_bonus
=
False
...
...
tests/2-ir-gen/autogen/eval_lab2.sh
View file @
8ca8504d
#!/bin/bash
cd
"
$(
dirname
"
$0
"
)
"
||
exit
1
python3 eval_lab2.py
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment