Skip to content

Commit 7087ee4

Browse files
committed
Fix tests
1 parent 821f4f9 commit 7087ee4

File tree

5 files changed

+27
-25
lines changed

5 files changed

+27
-25
lines changed

grader_config.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ show_test_build_hint = false
55
[setup]
66
# 在运行测试之前需要执行的准备步骤
77

8-
[[setup.steps]]
9-
name = "Compile tsh"
10-
type = "command"
11-
command = "make"
12-
args = ["all", "-j"]
13-
required = true # 如果这一步失败,则终止所有测试
14-
message = "Preparing tsh..."
15-
success_message = "tsh compiled successfully"
16-
timeout = 60.0
8+
# [[setup.steps]]
9+
# name = "Compile tsh"
10+
# type = "command"
11+
# command = "make"
12+
# args = ["all", "-j"]
13+
# required = true # 如果这一步失败,则终止所有测试
14+
# message = "Preparing tsh..."
15+
# success_message = "tsh compiled successfully"
16+
# timeout = 60.0
1717

1818
[paths]
1919
tests_dir = "tests"

tests/cases/12-sigtstp-proc-group/check_ps_output.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
def check_ps_output(stdout):
88
"""
99
Check that the ps output contains:
10-
1. The header line with PID, TTY, STAT, TIME, COMMAND
11-
2. At least one "mysplit 4" process with T (stopped) status
10+
1. The header line (more flexible format checking)
11+
2. At least one "mysplit 4" process with stopped status (T, T+, Ts, etc.)
1212
3. The shell process itself
1313
"""
1414
lines = stdout.strip().split("\n")
@@ -25,25 +25,27 @@ def check_ps_output(stdout):
2525

2626
ps_output = lines[ps_output_start:]
2727

28-
# Check header
29-
if not ps_output or not re.match(
30-
r"\s*PID\s+TTY\s+STAT\s+TIME\s+COMMAND", ps_output[0]
28+
# Check header - more flexible now
29+
if not ps_output or not (
30+
all(col in ps_output[0].upper() for col in ["PID", "TTY", "STAT", "TIME"])
31+
and any(col in ps_output[0].upper() for col in ["COMMAND", "CMD"])
3132
):
3233
return False, "Missing or invalid ps output header"
3334

34-
# Check for stopped mysplit processes
35+
# Check for stopped mysplit processes - support more status formats
3536
mysplit_stopped = False
3637

3738
for line in ps_output[1:]: # Skip header
3839
if not line.strip():
3940
continue
4041

41-
# Look for stopped mysplit processes (STAT should be T)
42-
if "./mysplit 4" in line and re.search(r"\bT\b", line):
42+
# Look for stopped mysplit processes with various stop status indicators
43+
if "./mysplit 4" in line and re.search(r'\b(T|Ts|T\+|STOPPED)\b', line, re.IGNORECASE):
4344
mysplit_stopped = True
45+
break
4446

4547
if not mysplit_stopped:
46-
return False, "No stopped mysplit processes found (STAT should be T)"
48+
return False, "No stopped mysplit processes found"
4749

4850
return True, "PS output correctly shows stopped processes"
4951

tests/cases/12-sigtstp-proc-group/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ wait_for_output = true
2323

2424
[[run.steps]]
2525
type = "sleep"
26-
seconds = 2
26+
seconds = 1
2727

2828
[[run.steps]]
2929
type = "signal"

tests/cases/17-cd/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ args = ["-p"]
1717

1818
[[run.steps]]
1919
type = "input"
20-
content = "pwd"
20+
content = "/bin/pwd"
2121

2222
[[run.steps]]
2323
type = "input"
2424
content = "cd .."
2525

2626
[[run.steps]]
2727
type = "input"
28-
content = "pwd"
28+
content = "/bin/pwd"
2929

3030
[[run.steps]]
3131
type = "close"

tests/cases/18-io-redirect/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ args = ["-p"]
1818
# 测试输出重定向
1919
[[run.steps]]
2020
type = "input"
21-
content = "echo 'Hello, World!' > output.txt"
21+
content = "/bin/echo 'Hello, World!' > output.txt"
2222

2323
[[run.steps]]
2424
type = "input"
25-
content = "cat output.txt"
25+
content = "/bin/cat output.txt"
2626

2727
# 测试输入重定向
2828
[[run.steps]]
2929
type = "input"
30-
content = "echo 'Test input redirection' > input.txt"
30+
content = "/bin/echo 'Test input redirection' > input.txt"
3131

3232
[[run.steps]]
3333
type = "input"
34-
content = "cat < input.txt"
34+
content = "/bin/cat < input.txt"
3535

3636
# 关闭 shell
3737
[[run.steps]]

0 commit comments

Comments
 (0)