File: bailout.test

package info (click to toggle)
libapache2-mod-rivet 3.2.0-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 5,868 kB
  • sloc: xml: 8,496; tcl: 7,212; ansic: 6,959; sh: 5,030; makefile: 261; sql: 91; lisp: 78
file content (171 lines) | stat: -rw-r--r-- 5,742 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# bailout.test -- test redirect command.
#
# redirect must trigger an AbortScript and have
# predictable data stored in the abort code

# $Id: bailout.test 1760054 2016-09-09 16:02:29Z mxmanghi $

::tcltest::test bailout-1.1 {::rivet::redirect command} {
    apachetest::start {} {
        RivetServerConf AbortScript "::rivet::apache_log_error err \\\"catching redirect\\\""
        RivetServerConf AbortScript "set tmpfp \[open redirect_code.txt w+\]"
        RivetServerConf AbortScript "puts \$tmpfp \[::rivet::abort_code\]"
        RivetServerConf AbortScript "close \$tmpfp"
    } {
        set url "${urlbase}redirect.rvt?base=$urlbase"
        #puts $url
        catch {set page1 [::http::geturl $url]}
        puts "verifying abort code"
        set rdfp [open redirect_code.txt r]
        set redirect_code [dict create {*}[read $rdfp]]
        set r1 [dict exists $redirect_code location]
        set r2 [dict exists $redirect_code error_code]
    } 
    list $r1 $r2
} {1 1}


::tcltest::test bailout-1.2 {::rivet::exit command} {
    apachetest::start {} {
        RivetServerConf AbortScript "::rivet::apache_log_error err \\\"catching exit\\\""
        RivetServerConf AbortScript "set abcode \[::rivet::abort_code\]"
        RivetServerConf AbortScript "puts -nonewline \[::rivet::abort_page -exiting\]"
        RivetServerConf AbortScript "puts -nonewline \\\" \[dict get \$abcode error_code\] \[dict get \$abcode return_code\]\\\""
    } {
        puts "test exit command"
        set url "${urlbase}exit.tcl"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r
} {1 exit 100} 

::tcltest::test bailout-2.0 {::rivet::catch procedure successful execution} {
    apachetest::start {} {
    } {
        set url "${urlbase}catch.rvt"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {OK}

::tcltest::test bailout-2.1 {::rivet::catch command generic error handling} {
    apachetest::start {} {
    } {
        set url "${urlbase}catch.rvt?abort=1"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {OK}

::tcltest::test bailout-2.2 {::rivet::catch command abort_page handling} {
    apachetest::start {} {
        RivetServerConf AbortScript "::rivet::apache_log_error err \\\"catching abort condition\\\""
        RivetServerConf AbortScript "puts -nonewline \[::rivet::abort_page -aborting\]"
    } {
        puts "test ::rivet::catch and ::rivet::abort_page interaction"
        set url "${urlbase}catch.rvt?abort=2"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r
} {1}

::tcltest::test bailout-2.3 {::rivet::catch handling options dictionary} {
    apachetest::start {} {
    } {
        set url "${urlbase}catch.rvt?abort=3"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {3 error}

::tcltest::test bailout-3.0 {::rivet::try successful procedure call} {
    apachetest::start {} {
    } {
        set url "${urlbase}try.rvt"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {finalize}

::tcltest::test bailout-3.1 {::rivet::try handling break return code} {
    apachetest::start {} {
    } {
        set url "${urlbase}try.rvt?cond=3"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {break try 3 finalize}

::tcltest::test bailout-3.2 {::rivet::try handling error return code} {
    apachetest::start {} {
    } {
        set url "${urlbase}try.rvt?cond=1"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {error try 1 finalize}

::tcltest::test bailout-3.3 {::rivet::try handling continue return code} {
    apachetest::start {} {
    } {
        set url "${urlbase}try.rvt?cond=4"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {continue try 4 finalize}

::tcltest::test bailout-3.4 {::rivet::try abort_page handling} {
    apachetest::start {} {
        RivetServerConf AbortScript "::rivet::apache_log_error err \\\"catching abort condition\\\""
        RivetServerConf AbortScript "puts -nonewline \\\" \[::rivet::abort_page -aborting\]\\\""
        RivetServerConf AbortScript "puts -nonewline \\\" \[::rivet::abort_code\]\\\""
    } {
        set url "${urlbase}try.rvt?cond=abort"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {finalize 1 arg1}

::tcltest::test bailout-3.5 {::rivet::try handling ::rivet::exit} {
    apachetest::start {} {
        RivetServerConf AbortScript "::rivet::apache_log_error err \\\"catching abort condition\\\""
        RivetServerConf AbortScript "set abcode \[::rivet::abort_code\]"
        RivetServerConf AbortScript "puts -nonewline \\\" \[::rivet::abort_page -exiting\]\\\""
        RivetServerConf AbortScript "puts -nonewline \\\" \[dict get \$abcode error_code\] \[dict get \$abcode return_code\]\\\""
    } {
        set url "${urlbase}try.rvt?cond=exit"
        set page [::http::geturl $url]
        set r [::http::data $page]
        ::http::cleanup $page
    }
    set r [string trim $r]
    set r
} {finalize 1 exit 101}