Update of /cvsroot/naviserver/naviserver/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10396/tests Modified Files: all.tcl http.test ns_addrbyhost.test ns_adp_compress.test ns_hostbyaddr.test ns_hrefs.test ns_parseargs.test Added Files: test.nscfg Log Message: * nsd/nsd.h: * nsd/driver.c: * nsd/tclinit.c: * nsd/nsmain.c: Add -c command line option which causes the server to start in command mode, reading commands from stdin and executing them like a tclsh. * Makefile: * tests/test.nscfg: * tests/all.tcl: Add new Makefile targets test, runtest and gdb which start the server in command mode. Modify the test runner and add a test server config file. * tests/http.test: * tests/ns_addrbyhost.test: * tests/ns_adp_compress.test: * tests/ns_hostbyaddr.test: * tests/ns_hrefs.test: * tests/ns_parseargs.test: Update tests to use tlctest syntax and features. Index: ns_addrbyhost.test =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/ns_addrbyhost.test,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ns_addrbyhost.test 16 Feb 2005 08:41:01 -0000 1.1.1.1 --- ns_addrbyhost.test 3 Apr 2005 06:38:01 -0000 1.2 *************** *** 31,56 **** # - source harness.tcl - load libnsd.so package require tcltest 2.2 namespace import -force ::tcltest::* - test ns_addrbyhost {ns_addrbyhost} { - assertEquals "127.0.0.1" [ns_addrbyhost "localhost"] - # ns_log messages confuse tcltest into thinking the test had a failure - ns_logctl hold - assertEquals 1 [catch {ns_addrbyhost "this_should_not_resolve"} msg] - assertEquals "could not lookup this_should_not_resolve" $msg - ns_logctl truncate ! # RFE #999452: Add -all switch to ns_addrbyhost ! # ! # This test will fail if we don't have connectivity/DNS service ! # or if the DNS entries change in a significant way. ! assertEquals 1 [expr {[llength [ns_addrbyhost -all "www.google.com"]] > 1}] ! assertEquals 1 [llength [ns_addrbyhost "www.google.com"]] ! } {} cleanupTests --- 31,49 ---- # package require tcltest 2.2 namespace import -force ::tcltest::* ! test ns_addrbyhost-1.1 {good host} -body { ! ns_addrbyhost localhost ! } -result 127.0.0.1 ! ! test ns_addrbyhost-1.2 {bad host} -body { ! ns_addrbyhost this_should_not_resolve ! } -returnCodes error -result {could not lookup this_should_not_resolve} ! ! cleanupTests --- NEW FILE: test.nscfg --- # # ... # set servername test ns_section "ns/parameters" ns_param home ./tests ns_section "ns/servers" ns_param $servername "Test Server" ns_section "ns/server/${servername}" ns_param pageroot servers/server1/pages ns_param enabletclpages true ns_section "ns/server/${servername}/tcl" ns_param initfile ../nsd/init.tcl ns_param library ../tcl Index: http.test =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/http.test,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** http.test 16 Feb 2005 08:41:01 -0000 1.1.1.1 --- http.test 3 Apr 2005 06:38:01 -0000 1.2 *************** *** 32,36 **** source harness.tcl - load libnsd.so package require tcltest 2.2 --- 32,35 ---- *************** *** 39,50 **** if {[info exists ::env(AOLSERVER_HTTP_TEST)]} { testConstraint serverTests true - } else { - puts " - To enable HTTP compliance tests, set environment variable - AOLSERVER_HTTP_TEST=hostname:port of the server running - http-test-config.tcl. - " } if {[testConstraint serverTests]} { foreach {host port} [split $::env(AOLSERVER_HTTP_TEST) :] break --- 38,44 ---- if {[info exists ::env(AOLSERVER_HTTP_TEST)]} { testConstraint serverTests true } + if {[testConstraint serverTests]} { foreach {host port} [split $::env(AOLSERVER_HTTP_TEST) :] break Index: ns_hrefs.test =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/ns_hrefs.test,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ns_hrefs.test 16 Feb 2005 08:41:01 -0000 1.1.1.1 --- ns_hrefs.test 3 Apr 2005 06:38:01 -0000 1.2 *************** *** 31,59 **** # - source harness.tcl - load libnsd.so package require tcltest 2.2 namespace import -force ::tcltest::* - test ns_hrefs-1.1 {ns_hrefs} { - assertEquals "" [ns_hrefs {}] - assertEquals "" [ns_hrefs {<a>}] - assertEquals "{}" [ns_hrefs {<a href="">}] - assertEquals "{}" [ns_hrefs {<a href=''>}] - assertEquals "simple" [ns_hrefs {<a href="simple">}] - assertEquals "href=tricky" [ns_hrefs {<a href="href=tricky">}] - assertEquals "first" [ns_hrefs {<a href="first" href="second">}] - assertEquals "naked" [ns_hrefs {<a href=naked dummy>}] ! assertEquals "" [ns_hrefs {a href="bogus">}] ! assertEquals "" [ns_hrefs {<a href="bogus"}] ! assertEquals "" [ns_hrefs {<a href "bogus">}] ! assertEquals "" [ns_hrefs {<a "href="bogus"">}] - # [ 995078 ] ns_hrefs only checks first attribute in <a> - assertEquals "hard" [ns_hrefs {<a dummy href="hard">}] - } {} cleanupTests --- 31,101 ---- # package require tcltest 2.2 namespace import -force ::tcltest::* ! test ns_hrefs-1.1 {syntax} -body { ! ns_hrefs ! } -returnCodes error -result {wrong # args: should be "ns_hrefs html"} ! ! test ns_hrefs-1.2 {syntax} -body { ! ns_hrefs {} ! } -result {} ! ! ! ! test ns_hrefs-2.1 {parse with result} -body { ! ns_hrefs {<a>} ! } -result {} ! ! test ns_hrefs-2.2 {parse with result} -body { ! ns_hrefs {<a href="">} ! } -result {{}} ! ! test ns_hrefs-2.3 {parse with result} -body { ! ns_hrefs {<a href=''>} ! } -result {{}} ! ! test ns_hrefs-2.4 {parse with result} -body { ! ns_hrefs {<a href="simple">} ! } -result {simple} ! ! test ns_hrefs-2.5 {parse with result} -body { ! ns_hrefs {<a href="href=tricky">} ! } -result {href=tricky} ! ! test ns_hrefs-2.6 {parse with result} -body { ! ns_hrefs {<a href="first" href="second">} ! } -result {first} ! ! test ns_hrefs-2.7 {parse with result} -body { ! ns_hrefs {<a href=naked dummy>} ! } -result {naked} ! ! test ns_hrefs-2.8 {parse with result} -body { ! ns_hrefs {<a first href="second">} ! } -result {second} ! ! ! ! test ns_hrefs-3.1 {parse without result} -body { ! ns_hrefs {a href="bogus">} ! } -result {} ! ! test ns_hrefs-3.2 {parse without result} -body { ! ns_hrefs {<a href="bogus"} ! } -result {} ! ! test ns_hrefs-3.3 {parse without result} -body { ! ns_hrefs {<a href "bogus">} ! } -result {} ! ! test ns_hrefs-3.4 {parse without result} -body { ! ns_hrefs {a "href="bogus"">} ! } -result {} ! cleanupTests Index: ns_adp_compress.test =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/ns_adp_compress.test,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ns_adp_compress.test 16 Feb 2005 08:41:02 -0000 1.1.1.1 --- ns_adp_compress.test 3 Apr 2005 06:38:01 -0000 1.2 *************** *** 32,36 **** source harness.tcl - load libnsd.so package require tcltest 2.2 --- 32,35 ---- *************** *** 39,48 **** if {[info exists ::env(AOLSERVER_HTTP_TEST)]} { testConstraint serverTests true - } else { - puts " - To enable HTTP compliance tests, set environment variable - AOLSERVER_HTTP_TEST=hostname:port of the server running - http-test-config.tcl. - " } --- 38,41 ---- Index: ns_hostbyaddr.test =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/ns_hostbyaddr.test,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ns_hostbyaddr.test 16 Feb 2005 08:41:01 -0000 1.1.1.1 --- ns_hostbyaddr.test 3 Apr 2005 06:38:01 -0000 1.2 *************** *** 31,49 **** # - source harness.tcl - load libnsd.so package require tcltest 2.2 namespace import -force ::tcltest::* - test ns_hostbyaddr {ns_hostbyaddr} { - assertEquals "localhost" [ns_hostbyaddr "127.0.0.1"] ! # ns_log messages confuse tcltest into thinking the test had a failure ! ns_logctl hold ! assertEquals 1 [catch {ns_hostbyaddr "0.0.0.0"} msg] ! assertEquals "could not lookup 0.0.0.0" $msg ! ns_logctl truncate ! } {} cleanupTests --- 31,49 ---- # package require tcltest 2.2 namespace import -force ::tcltest::* ! ! test ns_hostbyaddr-1.1 {good address} -body { ! ns_hostbyaddr 127.0.0.1 ! } -match glob -result localhost* ! ! test ns_hostbyaddr-1.2 {bad address} -body { ! ns_hostbyaddr 0.0.0.0 ! } -returnCodes error -result {could not lookup 0.0.0.0} ! ! cleanupTests Index: ns_parseargs.test =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/ns_parseargs.test,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ns_parseargs.test 26 Mar 2005 14:25:26 -0000 1.1 --- ns_parseargs.test 3 Apr 2005 06:38:01 -0000 1.2 *************** *** 4,9 **** - load ../nsd/libnsd.so - package require tcltest 2.2 namespace import -force ::tcltest::* --- 4,7 ---- *************** *** 48,51 **** --- 46,63 ---- } -result {} + test ns_parseargs-2.3 {object type conversion / display} -constraints { + knownBug + } -body { + set tid [ns_thread begin { + proc x {} { + ns_parseargs {-a} {-a A} + } + x + }] + ns_thread wait $tid + } -cleanup { + unset -nocomplain -- tid + } -result {} + Index: all.tcl =================================================================== RCS file: /cvsroot/naviserver/naviserver/tests/all.tcl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** all.tcl 16 Feb 2005 08:41:02 -0000 1.1.1.1 --- all.tcl 3 Apr 2005 06:38:01 -0000 1.2 *************** *** 1,6 **** - #!/bin/sh - # the next line restarts using tclsh \ - exec tclsh "$0" "$@" - # # The contents of this file are subject to the AOLserver Public License --- 1,2 ---- *************** *** 35,55 **** # ! package require Tcl 8.4 ! ! if {![info exists ::tcl_platform(threaded)] || !$::tcl_platform(threaded)} { ! error "tests must run from a threaded tclsh" ! } package require tcltest 2.2 ! set LD_LIBRARY_PATH [list] ! if {[info exists env(LD_LIBRARY_PATH)]} { ! lappend LD_LIBRARY_PATH $env(LD_LIBRARY_PATH) ! } ! lappend LD_LIBRARY_PATH ../../nsd ../../nsthread ! set env(LD_LIBRARY_PATH) [join $LD_LIBRARY_PATH :] ! ! tcltest::configure -testdir [file dirname [info script]] ! eval tcltest::configure $argv ! tcltest::runAllTests --- 31,49 ---- # ! # ! # all.tcl -- ! # ! # This file contains a top-level script to run all of the tests. ! # Execute it by invoking "source all.tcl" when running nsd in ! # command mode in this directory. ! # + package require Tcl 8.4 package require tcltest 2.2 + namespace import tcltest::* + eval configure $argv -singleproc true -testdir [file dirname [info script]] ! # Output on stderr confuses tcltest ! ns_logctl hold ! runAllTests |