Skip to content

Commit 96d4b44

Browse files
committed
Factor out unit test harness TCL, use for trTest and rcxUnitTest
Signed-off-by: Christopher D. Leary <[email protected]>
1 parent 1c0a74c commit 96d4b44

File tree

4 files changed

+39
-29
lines changed

4 files changed

+39
-29
lines changed

src/drt/test/gc_test.tcl

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
11
source "helpers.tcl"
22

3-
set test_dir [pwd]
4-
set openroad_dir [file dirname [file dirname [file dirname $test_dir]]]
5-
set test_path [file join $openroad_dir "build" "src" "drt" "trTest"]
6-
7-
set test_status [catch { exec sh -c "BASE_DIR=$test_dir $test_path" } output option]
8-
9-
puts $test_status
10-
puts $output
11-
if { $test_status != 0 } {
12-
set test_err_info [lassign [dict get $option -errorcode] err_type]
13-
switch -exact -- $err_type {
14-
NONE {
15-
#passed
16-
}
17-
CHILDSTATUS {
18-
# non-zero exit status
19-
set exit_status [lindex $test_err_info 1]
20-
puts "ERROR: test returned exit code $exit_status"
21-
exit 1
22-
23-
}
24-
default {
25-
puts "ERROR: $option"
26-
exit 1
27-
}
28-
}
29-
}
30-
puts "pass"
31-
exit 0
3+
run_unit_test_and_exit [list "build" "src" "drt" "trTest"]

src/rcx/test/rcx_unit_test.tcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "helpers.tcl"
2+
3+
run_unit_test_and_exit [list "build" "src" "rcx" "src" "rcxUnitTest"]

src/rcx/test/regression_tests.tcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ record_tests {
66
45_gcd
77
names
88
}
9+
record_pass_fail_tests {
10+
rcx_unit_test
11+
}

test/helpers.tcl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,38 @@ proc diff_files { file1 file2 } {
5454
}
5555
}
5656

57+
proc run_unit_test_and_exit { relative_path } {
58+
set test_dir [pwd]
59+
set openroad_dir [file dirname [file dirname [file dirname $test_dir]]]
60+
set test_path [file join $openroad_dir {*}$relative_path]
61+
62+
set test_status [catch { exec sh -c "BASE_DIR=$test_dir $test_path" } output option]
63+
64+
puts $test_status
65+
puts $output
66+
if { $test_status != 0 } {
67+
set test_err_info [lassign [dict get $option -errorcode] err_type]
68+
switch -exact -- $err_type {
69+
NONE {
70+
#passed
71+
}
72+
CHILDSTATUS {
73+
# non-zero exit status
74+
set exit_status [lindex $test_err_info 1]
75+
puts "ERROR: test returned exit code $exit_status"
76+
exit 1
77+
78+
}
79+
default {
80+
puts "ERROR: $option"
81+
exit 1
82+
}
83+
}
84+
}
85+
puts "pass"
86+
exit 0
87+
}
88+
5789
# Output voltage file is specified as ...
5890
suppress_message PSM 2
5991
# Output current file specified ...

0 commit comments

Comments
 (0)