You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2020/09/27 21:59:36 UTC
[tcl-rivet] 02/02: add support for testing with different MPMs and
bridges
This is an automated email from the ASF dual-hosted git repository.
mxmanghi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
commit 93e86eb5ecbd98123698c3007b7ffeb7d452a13d
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Sun Sep 27 23:52:14 2020 +0200
add support for testing with different MPMs and bridges
---
.gitignore | 1 +
ChangeLog | 5 ++
tests/apachetest/apachetest.tcl | 70 +++++++++++++++++-----------
tests/apachetest/template.conf.2.tcl | 1 -
tests/runtests.tcl | 89 ++++++++++++++++++++++++++----------
5 files changed, 115 insertions(+), 51 deletions(-)
diff --git a/.gitignore b/.gitignore
index d6f9347..0c86a44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,4 @@ tests/rivet/
tests/server.conf
tests/test.conf
tests/uploadedjpeg.jpg
+Session.vim
diff --git a/ChangeLog b/ChangeLog
index 381c7c6..0cad9b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-09-27 Massimo Manghi <mx...@apache.org>
+ * rivet/packages/formbroker/formbroker.tcl: add method form_exists to check for registration
+ of a form
+ * test/apachetest/apachetest.tcl,test/runtests.tcl: add support for testing with various MPMs and bridges
+
2020-02-03 Massimo Manghi <mx...@apache.org>
* src/request/: Update obsolete copyright statements
* src/mod_rivet_ng/rivetCore.c: update comments to upload command
diff --git a/tests/apachetest/apachetest.tcl b/tests/apachetest/apachetest.tcl
index 38206ec..d9658c8 100644
--- a/tests/apachetest/apachetest.tcl
+++ b/tests/apachetest/apachetest.tcl
@@ -1,6 +1,6 @@
# apachetest.tcl -- Tcl-based Apache test suite
-# Copyright 2001-2005 The Apache Software Foundation
+# 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.
@@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# $Id$
-
# 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
@@ -43,16 +41,16 @@ proc kill {signal pid} {
after 100
set i 100
while {1} {
- catch {exec ps -p $pid} out
- if {[regexp $pid $out]} {
- incr i 250
- after 250
- } else {
- break
- }
+ catch {exec ps -p $pid} out
+ if {[regexp $pid $out]} {
+ incr i 250
+ after 250
+ } else {
+ break
+ }
}
if {$i > 100} {
- puts "Waiting [expr {$i/1000.0}] seconds until process was killed"
+ puts "Waiting [expr {$i/1000.0}] seconds until process was killed"
}
}
@@ -71,8 +69,7 @@ namespace eval apachetest {
}
variable httpd_version $::httpd_version
# this file should be in the same directory this script is.
- variable templatefile [file join [file dirname [info script]] \
- template.conf.2.tcl]
+ variable templatefile [file join [file dirname [info script]] template.conf.2.tcl]
}
# apachetest::need_modules --
@@ -94,7 +91,7 @@ namespace eval apachetest {
proc apachetest::need_modules { modlist } {
variable module_assoc
foreach module_pair $modlist {
- set module_assoc([lindex $module_pair 0]) [lindex $module_pair 1]
+ set module_assoc([lindex $module_pair 0]) [lindex $module_pair 1]
}
}
@@ -190,12 +187,12 @@ proc apachetest::startserver { args } {
# 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 } {
+proc apachetest::getbinname { bname } {
variable binname
- set binname [lindex $argv 0]
+ set binname $bname
if { $binname == "" || ! [file executable $binname] } {
- error "Please supply the full name and path of the Apache executable on the command line."
+ error "Invalid executable '$binname', please supply the full name and path of the Apache executable on the command line."
}
return $binname
}
@@ -207,9 +204,15 @@ proc apachetest::getbinname { argv } {
proc apachetest::getcompiledin { binname } {
variable module_assoc
- set bin [open [list | "$binname" -l] r]
- set compiledin [read $bin]
- close $bin
+ if {[catch {
+ set bin [open [list | "$binname" -l] r]
+ set compiledin [read $bin]
+ close $bin} e einfo]} {
+ puts "error: $e"
+ puts "error info: $einfo"
+
+ error "caught error in apachetest::getcompledin"
+ }
set modlist [split $compiledin]
set compiledin [list]
set mod_so_present 0
@@ -234,16 +237,17 @@ proc apachetest::getcompiledin { binname } {
proc apachetest::gethttpdconf { binname } {
set bin [open [list | $binname -V] r]
set options [read $bin]
- close $bin
+ catch {close $bin}
regexp {SERVER_CONFIG_FILE="(.*?)"} "$options" match filename
- if { ! [file exists $filename] } {
+ if {![file exists $filename]} {
-# see if we can find something by combining HTTP_ROOT + SERVER_CONFIG_FILE
+ # 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] } {
+ if {![file exists $completename]} {
error "neither '$filename' or '$completename' exists"
}
return $completename
@@ -376,13 +380,15 @@ proc apachetest::determinemodules { binname } {
}
set needed [lsort $needed]
+ puts "needed: $needed"
+
set needtoget [list]
foreach mod $needed {
if { [lsearch $compiledin $mod] == -1 } {
lappend needtoget $mod
}
}
- if { $needtoget == "" } {
+ if {$needtoget == ""} {
return ""
} else {
return [getloadmodules $conffile $needtoget]
@@ -403,7 +409,7 @@ proc apachetest::determinemodules { binname } {
# Results:
# None.
-proc apachetest::makeconf { outfile {extra ""} } {
+proc apachetest::makeconf { outfile bridge {extra ""} } {
variable binname
variable templatefile
set CWD [pwd]
@@ -423,9 +429,19 @@ proc apachetest::makeconf { outfile {extra ""} } {
puts "reading template from $templatefile"
set fl [open [file join . $templatefile] r]
set template [read $fl]
- append template $extra
close $fl
+# configure a specific bridge if -bridge passed as argument
+
+ if {$bridge == "default"} {
+ set bridge_conf "# Default bridge"
+ } else {
+ set bridge_conf "RivetServerConf MpmBridge $bridge"
+ }
+ set extra [string map [list BRIDGE $bridge_conf] $extra]
+
+ append template $extra
+
puts $template
set out [subst $template]
diff --git a/tests/apachetest/template.conf.2.tcl b/tests/apachetest/template.conf.2.tcl
index 96141ab..09679cf 100644
--- a/tests/apachetest/template.conf.2.tcl
+++ b/tests/apachetest/template.conf.2.tcl
@@ -1,4 +1,3 @@
-# \$Id: \$
# Minimal config file for testing
# Parsed by makeconf.tcl
diff --git a/tests/runtests.tcl b/tests/runtests.tcl
index 87ff358..da4e069 100755
--- a/tests/runtests.tcl
+++ b/tests/runtests.tcl
@@ -2,7 +2,7 @@
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
-# Copyright 2001-2005 The Apache Software Foundation
+# 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.
@@ -17,7 +17,8 @@
# 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 {} {
@@ -44,13 +45,53 @@ proc get_httpd_version {httpd {bd broken_down_version}} {
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 httpd_version [get_httpd_version [lindex $argv 0]]
+ 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"
+puts stderr "Tests will be run against apache ${::httpd_version} version with the $mpm module and the $bridge bridge"
package require apachetest
@@ -64,27 +105,28 @@ if { [encoding system] eq "utf-8" } {
}
if { [catch {
- apachetest::getbinname $argv
+ apachetest::getbinname $httpd_bin
} err ] } {
puts stderr $err
runtests_usage
}
-apachetest::need_modules {
- {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}
- {mod_mpm_prefork mpm_prefork_module}
-}
+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 {
- 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)
+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
@@ -93,6 +135,7 @@ apachetest::makeconf server.conf {
AddLanguage es .es
AddType application/x-httpd-rivet .rvt
AddType application/x-rivet-tcl .tcl
+ BRIDGE
</IfModule>
<IfDefine SERVERCONFTEST>
@@ -122,14 +165,14 @@ set env(TCLLIBPATH) [file normalize [file join [file dirname [info script]] rive
# If 'startserver' is specified on the command line, just start up the
# server without running tests.
-puts "running test with arguments: $argv"
-switch -exact -- [lindex $argv 1] {
+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 [lrange $argv 1 end]
+ set argv $httpd_args
source [file join . rivet.test]
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org