You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by da...@apache.org on 2002/03/16 19:13:42 UTC
cvs commit: tcl-rivet/tests/apachetest apachetest.tcl template.conf.tcl
davidw 02/03/16 10:13:42
Modified: tests broken.test config.test rivet.test runtests.tcl
Added: tests/apachetest apachetest.tcl template.conf.tcl
Removed: tests makeconf.tcl template.conf.tcl
Log:
* tests/runtests.tcl: Updated to run with apachetest, eliminating
makeconf.tcl, and moving template.conf.tcl to the apachetest
directory.
* tests/apachetest/apachetest.tcl: New file, grouping together the
test functions in one place, and in a namespace.
Revision Changes Path
1.3 +2 -2 tcl-rivet/tests/broken.test
Index: broken.test
===================================================================
RCS file: /home/cvs/tcl-rivet/tests/broken.test,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- broken.test 15 Mar 2002 17:59:01 -0000 1.2
+++ broken.test 16 Mar 2002 18:13:42 -0000 1.3
@@ -1,9 +1,9 @@
-# $Id: broken.test,v 1.2 2002/03/15 17:59:01 davidw Exp $
+# $Id: broken.test,v 1.3 2002/03/16 18:13:42 davidw Exp $
set testfilename1 broken.rvt
::tcltest::test broken-1.1 {error page test} {
- server::start {} {
+ apachetest::start {} {
catch {
set page [::http::geturl "${urlbase}$testfilename1"]
set match [string trim [::http::data $page]]
1.2 +4 -4 tcl-rivet/tests/config.test
Index: config.test
===================================================================
RCS file: /home/cvs/tcl-rivet/tests/config.test,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- config.test 15 Mar 2002 18:42:53 -0000 1.1
+++ config.test 16 Mar 2002 18:13:42 -0000 1.2
@@ -1,9 +1,9 @@
-# $Id: config.test,v 1.1 2002/03/15 18:42:53 davidw Exp $
+# $Id: config.test,v 1.2 2002/03/16 18:13:42 davidw Exp $
set testfilename1 config.rvt
::tcltest::test config-1.1 {ErrorScript config test} {
- server::start {
+ apachetest::start {
-c "RivetUserConf ErrorScript 'puts \"Page broken\"'"
} {
catch {
@@ -15,7 +15,7 @@
} {Page broken}
::tcltest::test config-1.2 {ErrorScript config test} {
- server::start {
+ apachetest::start {
-c "RivetUserConf ErrorScript 'puts \"Page broken\"'" -c "AccessFileName test-htaccess"
} {
catch {
@@ -88,7 +88,7 @@
foreach Config $ConfigList {
incr i
::tcltest::test config-${i}.1 {config test} {
- server::start $Config {
+ apachetest::start $Config {
catch {
set page [::http::geturl "${urlbase}$testfilename1?config-2"]
set match [string trim [::http::data $page]]
1.16 +4 -25 tcl-rivet/tests/rivet.test
Index: rivet.test
===================================================================
RCS file: /home/cvs/tcl-rivet/tests/rivet.test,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- rivet.test 15 Mar 2002 18:41:55 -0000 1.15
+++ rivet.test 16 Mar 2002 18:13:42 -0000 1.16
@@ -6,7 +6,7 @@
# See README file for more information.
-# $Id: rivet.test,v 1.15 2002/03/15 18:41:55 davidw Exp $
+# $Id: rivet.test,v 1.16 2002/03/16 18:13:42 davidw Exp $
package require tcltest
package require http
@@ -15,27 +15,6 @@
# Use this to start and stop the server:
-namespace eval server {
- variable binname
-}
-set server::binname $binname
-
-proc server::start { options code } {
- variable serverpid 0
- variable binname
- after 200
- set serverpid [eval exec $binname -X -f "[file join [pwd] server.conf]" $options &]
- after 100
- puts "Apache started as PID $serverpid"
- if { ! [catch {
- uplevel $code
- } err] } {
- puts $err
- }
- after 100
- exec kill $serverpid
-}
-
set TestList {cookies.test get.test post.test tclfile.test env.test hello.test include.test binary.test parse.test upload.test makeurl.test}
# Test stanzas are created by giving the test a name and a
@@ -43,13 +22,13 @@
# with the desired result, which is placed after the block of code.
# See man tcltest for more information.
-set testgroup1 0
+set testgroup1 1
set testgroup2 1
set testgroup3 1
if { $testgroup1 } {
foreach Test $TestList {
- server::start {} {
+ apachetest::start {} {
source $Test
}
}
@@ -59,7 +38,7 @@
# around some.
if { $testgroup2 } {
- server::start {} {
+ apachetest::start {} {
foreach Test $TestList {
source $Test
}
1.9 +34 -16 tcl-rivet/tests/runtests.tcl
Index: runtests.tcl
===================================================================
RCS file: /home/cvs/tcl-rivet/tests/runtests.tcl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- runtests.tcl 12 Mar 2002 16:45:12 -0000 1.8
+++ runtests.tcl 16 Mar 2002 18:13:42 -0000 1.9
@@ -2,20 +2,42 @@
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
-proc getbinname { } {
- global argv
- set binname [lindex $argv 0]
- if { $binname == "" || ! [file exists $binname] } {
- puts stderr "Please supply the full name and path of the Apache executable on the command line!"
- exit 1
- }
- return $binname
+source [file join apachetest apachetest.tcl]
+
+apachetest::getbinname $argv
+
+apachetest::makeconf server.conf {
+ LoadModule rivet_module [file join $CWD .. src mod_rivet[info sharedlibextension]]
+
+ <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
+ </IfModule>
+
+ RivetServerConf UploadFilesToVar on
+
+ <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>
}
-set binname [ getbinname ]
+# copy the rivet init files.
-source makeconf.tcl
-makeconf $binname server.conf
+if { ! [file exists [file join rivet init.tcl]] } {
+ file copy -force [file join .. rivet] .
+}
# we do this to keep tcltest happy - it reads argv...
set commandline [lindex $argv 1]
@@ -23,11 +45,7 @@
switch -exact $commandline {
startserver {
- if { [catch {
- exec $binname -X -f "[file join [pwd] server.conf]"
- } err] } {
- puts "$errorInfo"
- }
+ apachetest::startserver
}
default {
source [file join . rivet.test]
1.1 tcl-rivet/tests/apachetest/apachetest.tcl
Index: apachetest.tcl
===================================================================
# $Id: apachetest.tcl,v 1.1 2002/03/16 18:13:42 davidw Exp $
# Tcl based Apache test suite, by David N. Welton <da...@dedasys.com>
# This test suite provides a means to create configuration files, and
# start apache with user-specified options. All it needs to run is
# the name of the Apache executable, which must, however, be compiled
# with the right options.
package provide apachetest 0.1
namespace eval apachetest {
# Associate module names with their internal names.
array set module_assoc {
mod_log_config config_log_module
mod_mime mime_module
mod_negotiation negotiation_module
mod_dir dir_module
mod_access access_module
mod_auth auth_module
}
# name of the apache binary, such as /usr/sbin/httpd
variable binname ""
# this file should be in the same directory this script is.
variable templatefile [file join [file dirname [info script]] \
template.conf.tcl]
}
# start - start the server in the background with 'options' and then
# run 'code'.
proc apachetest::start { options code } {
variable serverpid 0
variable binname
# There has got to be a better way to do this, aside from waiting.
after 200
set serverpid [eval exec $binname -X -f \
"[file join [pwd] server.conf]" $options &]
after 100
puts "Apache started as PID $serverpid"
if { ! [catch {
uplevel $code
} err] } {
puts $err
}
after 100
exec kill $serverpid
}
# startserver - start the server with 'options'.
proc apachetest::startserver { options } {
variable binname
eval exec $binname -X -f \
"[file join [pwd] server.conf]" $options
}
# getbinname - get the name of the apache binary, and check to make
# sure it's ok. The user should supply this parameter.
proc apachetest::getbinname { argv } {
variable binname
set binname [lindex $argv 0]
if { $binname == "" || ! [file exists $binname] } {
error "Please supply the full name and path of the Apache executable on the command line!"
}
return $binname
}
# get the modules that are compiled into Apache directly, and return
# the XXX_module name. Check also for the existence of mod_so, which
# we need to load the shared object in the directory above...
proc apachetest::getcompiledin { binname } {
variable module_assoc
set bin [open [list | "$binname" -l] r]
set compiledin [read $bin]
close $bin
set modlist [split $compiledin]
set compiledin [list]
set mod_so_present 0
foreach entry $modlist {
if { [regexp {(.*)\.c$} $entry match modname] } {
if { $modname == "mod_so" } {
set mod_so_present 1
}
if { [info exists module_assoc($modname)] } {
lappend compiledin $module_assoc($modname)
}
}
}
if { $mod_so_present == 0 } {
error "We need mod_so in Apache to run these tests"
}
return $compiledin
}
# find the httpd.conf file
proc apachetest::gethttpdconf { binname } {
set bin [ open [list | "$binname" -V ] r ]
set options [ read $bin ]
close $bin
regexp {SERVER_CONFIG_FILE="(.*?)"} "$options" match filename
if { ! [file exists $filename] } {
# see if we can find something by combining HTTP_ROOT + SERVER_CONFIG_FILE
regexp {HTTPD_ROOT="(.*?)"} "$options" match httpdroot
set completename [file join $httpdroot $filename]
if { ! [file exists $completename] } {
error "neither '$filename' or '$completename' exists"
}
return $completename
}
return $filename
}
# if we need to load some modules, find out how to do it from the
# 'real' (the one installed on the system) conf file, with this proc
proc apachetest::getloadmodules { conffile needtoget } {
set fl [open $conffile r]
set confdata [read $fl]
close $fl
set loadline [list]
foreach mod $needtoget {
if { ! [regexp -line "^.*?(LoadModule\\s+$mod\\s+.+)\$"\
$confdata match line] } {
error "No LoadModule line for $mod!"
} else {
lappend loadline $line
}
}
return [join $loadline "\n"]
}
# compare what's compiled in with what we need
proc apachetest::determinemodules { binname } {
variable module_assoc
set compiledin [lsort [getcompiledin $binname]]
set conffile [gethttpdconf $binname]
foreach {n k} [array get module_assoc] {
lappend needed $k
}
set needed [lsort $needed]
set needtoget [list]
foreach mod $needed {
if { [lsearch $compiledin $mod] == -1 } {
lappend needtoget $mod
}
}
if { $needtoget == "" } {
return ""
} else {
return [getloadmodules $conffile $needtoget]
}
}
# dump out a config
# outfile is the file to write to.
# extra is for extra config things we want to tack on.
proc apachetest::makeconf { outfile {extra ""} } {
variable binname
variable templatefile
set CWD [pwd]
# replace with determinemodules
set LOADMODULES [determinemodules $binname]
set fl [open [file join . $templatefile] r]
set template [read $fl]
append template $extra
close $fl
set out [subst $template]
set of [open $outfile w]
puts $of "$out"
close $of
}
1.1 tcl-rivet/tests/apachetest/template.conf.tcl
Index: template.conf.tcl
===================================================================
# \$Id\$
# Minimal config file for testing
# Parsed by makeconf.tcl
ServerRoot "$CWD"
PidFile "$CWD/httpd.pid"
ResourceConfig "$CWD/srm.conf"
AccessConfig "$CWD/access.conf"
Timeout 300
MaxRequestsPerChild 0
$LOADMODULES
Port 8081
ServerName localhost
DocumentRoot "$CWD"
<Directory "$CWD">
Options All MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>
AccessFileName .htaccess
HostnameLookups Off
ErrorLog $CWD/error_log
LogLevel debug
LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined
CustomLog "$CWD/access_log" combined
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org