File: runtests.tcl

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 (178 lines) | stat: -rwxr-xr-x 5,309 bytes parent folder | download | duplicates (3)
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
172
173
174
175
176
177
178
#!/bin/sh
# the next line restarts using tclsh \
	exec tclsh "$0" "$@"

# Copyright 2001-2020 The Apache Tcl Team / The Apache Software Foundation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set auto_path [linsert $auto_path 0 [file join [file dirname [info script]] apachetest]]
set default_mpm prefork
set httpd_args   {}
puts stderr "runtests.tcl is running with auto_path: $auto_path"

proc runtests_usage {} {
    puts stderr "Usage: $::argv0 /path/to/apache/httpd ?startserver? ?-mpm <MPM module>? ?-bridge <MPM Bridge>?"
    exit 1
}

proc get_httpd_version {httpd {bd broken_down_version}} {
    upvar 1 $bd broken_down_version

	catch {exec $httpd -v} raw_string

	set version_l [regexp -inline {([0-9]{1,})\.([0-9]{1,})\.([0-9]{1,})} $raw_string]
	if {[llength $version_l]} {

        lassign $version_l m major minor patchlevel
        set broken_down_version [list $major $minor $patchlevel]

    } else {

        return -code error "could not identify the Apache httpd version from '$raw_string'"

    }
    return $m
}

# -- process_args
#
# basically this procedure strips from the argument list
# the arguments not pertaining to the httpd server
# Used to provide a way to control the test suite execution
#

proc process_args {arguments} {
    global mpm
    global bridge
    global httpd_args

    puts "n arguments: [llength $arguments]"
    while {[llength $arguments]} {
        set arguments [lassign $arguments a]
        switch $a {
            -mpm {
                set arguments [lassign $arguments mpm]
            }
            -bridge {
                set arguments [lassign $arguments bridge]
            }
            default {
                lappend httpd_args $a
            }
        }
    }
}

if { [llength $argv] < 1 } {
    runtests_usage
} else {
    set mpm $default_mpm
    set bridge "default"

    set httpd_bin     [lindex $argv 0]
    set httpd_version [get_httpd_version $httpd_bin]
    process_args      [lrange $argv 1 end]

    puts "httpd_bin: $httpd_bin"
    puts "httpd_args: $httpd_args"
    puts "httpd_version: $httpd_version"
    puts "mpm: $mpm, bridge: $bridge"

}

puts stderr "Tests will be run against apache ${::httpd_version} version with the $mpm module and the $bridge bridge"

package require apachetest

if { [encoding system] eq "utf-8" } {
    puts stderr {
        System encoding is utf-8 - this is known to cause problems
        with the test environment!  Continuing with tests in 5 seconds
        using the iso8859-1 encoding.
    }
    after 5000
}

if { [catch {
    apachetest::getbinname $httpd_bin
} err ] } {
    puts stderr $err
    runtests_usage
}

apachetest::need_modules [list \
        {mod_mime                       mime_module} \
        {mod_negotiation                negotiation_module} \
        {mod_dir                        dir_module} \
        {mod_log_config                 log_config_module} \
        {mod_authz_core                 authz_core_module} \
        {mod_authz_host                 authz_host_module} \
        {mod_unixd                      unixd_module} \
        [list mod_mpm_${mpm}            mpm_${mpm}_module]]

apachetest::makeconf server.conf $bridge {
    LoadModule rivet_module [file join $CWD .. src/.libs mod_rivet[info sharedlibextension]]

    # User and Group directives removed to ease dependency of test 
    # suite from the output of command 'id' (from which
    # the values for these directives were inferred (Bug #53396)

    <IfModule mod_mime.c>
        TypesConfig $CWD/mime.types
        AddLanguage en .en
        AddLanguage it .it
        AddLanguage es .es
        AddType application/x-httpd-rivet .rvt
        AddType application/x-rivet-tcl   .tcl
        BRIDGE
    </IfModule>

    <IfDefine SERVERCONFTEST>
        RivetServerConf BeforeScript 'puts "Page Header"'
        RivetServerConf AfterScript 'puts "Page Footer"'
    </IfDefine>

    <IfDefine DIRTEST>
        <Directory />
            RivetDirConf BeforeScript 'puts "Page Header"'
            RivetDirConf AfterScript 'puts "Page Footer"'
        </Directory>
    </IfDefine>

    # We can use this to include our own stuff for each test.
    Include test.conf

    # For testing, we want core dumps.
    CoreDumpDirectory $CWD
}

# Copy the rivet init files.
file delete -force rivet
file copy   -force [file join .. rivet] .
set env(TCLLIBPATH) [file normalize [file join [file dirname [info script]] rivet]]

# If 'startserver' is specified on the command line, just start up the
# server without running tests.

puts "running test with arguments: $httpd_args"
switch -exact -- [lindex $httpd_args 1] {
    startserver {
	    apachetest::startserver
    }
    default {
        #set argv [lrange $argv 1 end]
        set argv $httpd_args
        source [file join . rivet.test]
    }
}