blob: b41f072cc9148e7a90952f03bd7ec7656bba64cf [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
11set config_h [open "../config.h" "r"]
12set config_h_text [read $config_h]
13close $config_h
14set i [string first "#define HAVE_IPV6" $config_h_text]
15if { $i >= 0 } {
16 set have_ipv6 1
17} else {
18 set have_ipv6 0
19}
20send_user "IPv6 enabled: $have_ipv6\n"
21set xfail 0
22
David Lamparterc69905b2013-01-24 01:39:14 +010023proc onesimple { test_name match } {
24 global verbose
25 global aborted
26 global testprefix
27 if { $aborted > 0 } {
28 untested "$testprefix$test_name"
29 return
30 }
31 if { $verbose > 0 } {
32 send_user "$testprefix$test_name$note\n"
33 }
34 expect {
35 "$match" { pass "$testprefix$test_name"; }
36 eof { fail "$testprefix$test_name"; set aborted 1; }
37 timeout { unresolved "$testprefix$test_name"; set aborted 1; }
38 }
39}
40
David Lamparterf281ab92013-02-26 16:21:20 +010041proc onetest { test_name note start } {
42 global aborted
43 global testprefix
44 global verbose
45 global color
46 global xfail
47
48 if { $aborted > 0 } {
49 untested "$testprefix$test_name"
50 return
51 }
52
53 if { $verbose > 0 } {
54 send_user "$testprefix$test_name$note\n"
55 }
56 expect {
57 "$start" { }
58
59 eof { unresolved "$testprefix$test_name"; set aborted 1; }
60 timeout { unresolved "$testprefix$test_name"; set aborted 1; }
61 }
62
63 if { $aborted > 0 } {
64 send_user "sync failed: $testprefix$test_name$note -- $testprefix aborted!\n"
65 return
66 }
67
68 if { $color } {
69 set pat "(32mOK|31mfailed)"
70 } else {
71 set pat "(OK|failed)"
72 }
73 expect {
74 # need this because otherwise expect will skip over a "failed" and
75 # grab the next "OK" (or the other way around)
76 -re "$pat" {
77 if { "$expect_out(0,string)" == "32mOK" || "$expect_out(0,string)" == "OK" } {
78 pass "$testprefix$test_name"
79 } else {
80 if { $xfail } {
81 xfail "$testprefix$test_name"
82 } else {
83 fail "$testprefix$test_name"
84 }
85 }
86 return
87 }
88
89 eof { unresolved "$testprefix$test_name"; set aborted 1; }
90 timeout { unresolved "$testprefix$test_name"; set aborted 1; }
91 }
92
93 if { $aborted > 0 } {
94 send_user "failed: $testprefix$test_name$note -- $testprefix aborted!\n"
95 return
96 }
97}
98
99proc headerline { line } {
100 global aborted
101 if { $aborted > 0 } { return; }
102 expect {
103 $line { return; }
104 eof { send_user "numbering mismatch!\n"; set aborted 1; }
105 timeout { send_user "numbering mismatch!\n"; set aborted 1; }
106 }
107}
108
109proc simpletest { start } {
110 onetest "$start" "" "$start"
111}
112
113proc simpletest_nov6 { start } {
114 global have_ipv6
115 global xfail
116
117 set xfail [expr 1-$have_ipv6]
118 onetest "$start" "" "$start"
119 set xfail 0
120}
121
122