blob: 25ea97f4c529a9261cac5c6dc75e412add87d05e [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
23proc onetest { test_name note start } {
24 global aborted
25 global testprefix
26 global verbose
27 global color
28 global xfail
29
30 if { $aborted > 0 } {
31 untested "$testprefix$test_name"
32 return
33 }
34
35 if { $verbose > 0 } {
36 send_user "$testprefix$test_name$note\n"
37 }
38 expect {
39 "$start" { }
40
41 eof { unresolved "$testprefix$test_name"; set aborted 1; }
42 timeout { unresolved "$testprefix$test_name"; set aborted 1; }
43 }
44
45 if { $aborted > 0 } {
46 send_user "sync failed: $testprefix$test_name$note -- $testprefix aborted!\n"
47 return
48 }
49
50 if { $color } {
51 set pat "(32mOK|31mfailed)"
52 } else {
53 set pat "(OK|failed)"
54 }
55 expect {
56 # need this because otherwise expect will skip over a "failed" and
57 # grab the next "OK" (or the other way around)
58 -re "$pat" {
59 if { "$expect_out(0,string)" == "32mOK" || "$expect_out(0,string)" == "OK" } {
60 pass "$testprefix$test_name"
61 } else {
62 if { $xfail } {
63 xfail "$testprefix$test_name"
64 } else {
65 fail "$testprefix$test_name"
66 }
67 }
68 return
69 }
70
71 eof { unresolved "$testprefix$test_name"; set aborted 1; }
72 timeout { unresolved "$testprefix$test_name"; set aborted 1; }
73 }
74
75 if { $aborted > 0 } {
76 send_user "failed: $testprefix$test_name$note -- $testprefix aborted!\n"
77 return
78 }
79}
80
81proc headerline { line } {
82 global aborted
83 if { $aborted > 0 } { return; }
84 expect {
85 $line { return; }
86 eof { send_user "numbering mismatch!\n"; set aborted 1; }
87 timeout { send_user "numbering mismatch!\n"; set aborted 1; }
88 }
89}
90
91proc simpletest { start } {
92 onetest "$start" "" "$start"
93}
94
95proc simpletest_nov6 { start } {
96 global have_ipv6
97 global xfail
98
99 set xfail [expr 1-$have_ipv6]
100 onetest "$start" "" "$start"
101 set xfail 0
102}
103
104