File: config.test

package info (click to toggle)
libapache2-mod-rivet 3.2.2-1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 6,296 kB
  • sloc: xml: 8,554; tcl: 7,568; ansic: 7,094; sh: 5,017; makefile: 195; sql: 91; lisp: 78
file content (126 lines) | stat: -rw-r--r-- 3,234 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
# $Id$

set testfilename1 config.rvt

::tcltest::test config-1.1 {ErrorScript config test} {
    apachetest::start {
	    -c "RivetUserConf ErrorScript 'puts \"Page broken\"'"
    } {} {
        catch {
            set page [::http::geturl "${urlbase}$testfilename1?brokenpage"]
            set match [string trim [::http::data $page]]
            ::http::cleanup $page
        }
    }
    set match
} {Page broken}

::tcltest::test config-1.2 {ErrorScript config test} {
    apachetest::start {
	-c "RivetUserConf ErrorScript 'puts \"Page broken\"'" -c "AccessFileName test-htaccess"
    } {} {
        catch {
            set page [::http::geturl "${urlbase}$testfilename1?brokenpage"]
            set match [string trim [::http::data $page]]
            ::http::cleanup $page
        }
    }
    set match
} {Local Page Header
this page is BROKEN}

::tcltest::test config-2.1 {BeforeScript test} {
    set fl [open htaccess2 w]
    puts $fl {RivetUserConf BeforeScript 'puts "Local Page Header"'}
    close $fl
    apachetest::start { -c "AccessFileName htaccess2" } {} {
        catch {
            set page [::http::geturl "${urlbase}$testfilename1?goodpage"]
            set match [string trim [::http::data $page]]
            ::http::cleanup $page
            # Now change what's in the ".htaccess" file, and see if it
            # picks it up.
            set fl [open htaccess2 w]
            puts $fl {RivetUserConf BeforeScript 'puts "New Local Page Header"'}
            close $fl
            set page [::http::geturl "${urlbase}$testfilename1?goodpage"]
            append match [string trim [::http::data $page]]
            ::http::cleanup $page
        }
    }
    set match
} {Local Page Header
Page BodyNew Local Page Header
Page Body}

# List of all the configs to try

set ConfigList {
    {-c "RivetUserConf BeforeScript 'puts \"Page Header\"'"}
    {-c "RivetUserConf BeforeScript 'puts \"Page Header\"'" -c "AccessFileName test-htaccess"}
    {-c "RivetUserConf AfterScript 'puts \"Page Footer\"'"}
    {-c "RivetUserConf AfterScript 'puts \"Page Footer\"'" -c "AccessFileName test-htaccess"}
    {-D DIRTEST}
    {-D DIRTEST -c "AccessFileName test-htaccess"}
    {-D DIRTEST -D SERVERCONFTEST}
    {-D SERVERCONFTEST -c "AccessFileName test-htaccess"}
    {-D SERVERCONFTEST}
    {-D DIRTEST -D SERVERCONFTEST -c "AccessFileName test-htaccess"}
}

# Corresponding list of results we should get

set ResultList {
{Page Header
Page Body}

{Local Page Header
Page Body
Local Page Footer}

{Page Body
Page Footer}

{Local Page Header
Page Body
Local Page Footer}

{Page Header
Page Body
Page Footer}

{Local Page Header
Page Body
Local Page Footer}

{Page Header
Page Body
Page Footer}

{Local Page Header
Page Body
Local Page Footer}

{Page Header
Page Body
Page Footer}

{Local Page Header
Page Body
Local Page Footer}
}


set i 0
foreach Config $ConfigList {
    incr i
    ::tcltest::test config-auto-${i}.1 {config test} {
        apachetest::start $Config {} {
            catch {
                set page [::http::geturl "${urlbase}$testfilename1?goodpage"]
                set match [string trim [::http::data $page]]
            }
        }
        set match
    } [lindex $ResultList [expr $i - 1]]
}