blob: 2f6bceadbef28ff174f4ad72809aa0cd3715b033 [file] [log] [blame]
David Lamparterf281ab92013-02-26 16:21:20 +01001
2# every test should always be run and always return some status.
3# so, if we lose sync with a multi-test program, aborted will be used
4# to flag the remainder of the tests as untested.
5#set aborted 0
6
7# only match with color codes since "failed" / "OK" might otherwise
8# be part of the output...
9#set color 1
10
David Lamparterf281ab92013-02-26 16:21:20 +010011set xfail 0
12
David Lamparterc69905b2013-01-24 01:39:14 +010013proc onesimple { test_name match } {
14 global verbose
15 global aborted
16 global testprefix
17 if { $aborted > 0 } {
18 untested "$testprefix$test_name"
19 return
20 }
21 if { $verbose > 0 } {
22 send_user "$testprefix$test_name$note\n"
23 }
24 expect {
25 "$match" { pass "$testprefix$test_name"; }
26 eof { fail "$testprefix$test_name"; set aborted 1; }
27 timeout { unresolved "$testprefix$test_name"; set aborted 1; }
28 }
29}
30
David Lamparterf281ab92013-02-26 16:21:20 +010031proc onetest { test_name note start } {
32 global aborted
33 global testprefix
34 global verbose
35 global color
36 global xfail
37
38 if { $aborted > 0 } {
39 untested "$testprefix$test_name"
40 return
41 }
42
43 if { $verbose > 0 } {
44 send_user "$testprefix$test_name$note\n"
45 }
46 expect {
47 "$start" { }
48
49 eof { unresolved "$testprefix$test_name"; set aborted 1; }
50 timeout { unresolved "$testprefix$test_name"; set aborted 1; }
51 }
52
53 if { $aborted > 0 } {
54 send_user "sync failed: $testprefix$test_name$note -- $testprefix aborted!\n"
55 return
56 }
57
58 if { $color } {
59 set pat "(32mOK|31mfailed)"
60 } else {
61 set pat "(OK|failed)"
62 }
63 expect {
64 # need this because otherwise expect will skip over a "failed" and
65 # grab the next "OK" (or the other way around)
66 -re "$pat" {
67 if { "$expect_out(0,string)" == "32mOK" || "$expect_out(0,string)" == "OK" } {
68 pass "$testprefix$test_name"
69 } else {
70 if { $xfail } {
71 xfail "$testprefix$test_name"
72 } else {
73 fail "$testprefix$test_name"
74 }
75 }
76 return
77 }
78
79 eof { unresolved "$testprefix$test_name"; set aborted 1; }
80 timeout { unresolved "$testprefix$test_name"; set aborted 1; }
81 }
82
83 if { $aborted > 0 } {
84 send_user "failed: $testprefix$test_name$note -- $testprefix aborted!\n"
85 return
86 }
87}
88
89proc headerline { line } {
90 global aborted
91 if { $aborted > 0 } { return; }
92 expect {
93 $line { return; }
94 eof { send_user "numbering mismatch!\n"; set aborted 1; }
95 timeout { send_user "numbering mismatch!\n"; set aborted 1; }
96 }
97}
98
99proc simpletest { start } {
100 onetest "$start" "" "$start"
101}
102