diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-11-12 10:53:10 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-11-12 11:01:17 +0200 |
commit | 2862e10791592ce9ce5f6b4d66c68798c74e19da (patch) | |
tree | 96b3cae37ee1401e35d8480e49096f94b6c6c340 | |
parent | 5d91de768f4a5f75f6b663e7d80c94f47e45de23 (diff) | |
download | vmod-dbrw-2862e10791592ce9ce5f6b4d66c68798c74e19da.tar.gz vmod-dbrw-2862e10791592ce9ce5f6b4d66c68798c74e19da.tar.bz2 |
Improve the testsuite
New macro AT_DBRW_INIT ensures the test database is initialized.
When finished, it creates the file .TESTINIT if the initialization
succeeded or FAILURE, if it did not. The latter contains the
error output from initdb. These files are then used to decide whether
to proceed with the tests.
All tests include this macro at the very beginning.
* tests/Makefile.am (CLEANFILES): Add files.
* tests/atlocal.in (INITFILE, FAILFILE): New variables.
* tests/initdb.at: Rewrite as a new define AT_DBRW_INITDB.
* tests/exact01.at: Include AT_DBRW_INIT at the start,
Use AT_DBINIT_PREREQ
* tests/testsuite.at (AT_DBRW_INIT, AT_DBINIT_PREREQ): New macros.
* tests/rewrite01.at: Likewise.
* tests/rewrite02.at: Likewise.
* tests/rewrite03.at: Likewise.
* tests/rewrite04.at: Likewise.
* tests/rewrite05.at: Likewise.
* tests/rewrite06.at: Likewise.
-rw-r--r-- | src/.gitignore | 1 | ||||
-rw-r--r-- | tests/.gitignore | 2 | ||||
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/atlocal.in | 2 | ||||
-rw-r--r-- | tests/exact01.at | 5 | ||||
-rw-r--r-- | tests/initdb.at | 23 | ||||
-rw-r--r-- | tests/rewrite01.at | 5 | ||||
-rw-r--r-- | tests/rewrite02.at | 5 | ||||
-rw-r--r-- | tests/rewrite03.at | 5 | ||||
-rw-r--r-- | tests/rewrite04.at | 5 | ||||
-rw-r--r-- | tests/rewrite05.at | 5 | ||||
-rw-r--r-- | tests/rewrite06.at | 5 | ||||
-rw-r--r-- | tests/testsuite.at | 20 |
13 files changed, 61 insertions, 24 deletions
diff --git a/src/.gitignore b/src/.gitignore index 7f6e438..63db32d 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,2 +1,3 @@ +*.rst vcc_if.c vcc_if.h diff --git a/tests/.gitignore b/tests/.gitignore index e36f81c..f9cbf3f 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,3 +1,5 @@ +.TESTINIT +FAILURE atconfig atlocal initdb diff --git a/tests/Makefile.am b/tests/Makefile.am index 1d0094e..6d06b53 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,7 +17,7 @@ EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 DISTCLEANFILES = atconfig $(check_SCRIPTS) MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) - +CLEANFILES = .TESTINIT FAILURE ## ------------ ## ## package.m4. ## diff --git a/tests/atlocal.in b/tests/atlocal.in index 424072d..057b132 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -3,6 +3,8 @@ # Copyright (C) 2013-2014 Sergey Poznyakoff PATH=@abs_builddir@:@abs_top_builddir@/src:@abs_top_srcdir@/build-aux:$top_srcdir:$srcdir:$PATH +INITFILE=@abs_builddir@/.TESTINIT +FAILFILE=@abs_builddir@/FAILURE VARNISHTEST="@VARNISHSRC@/bin/varnishtest/varnishtest -Dvarnishd=@VARNISHSRC@/bin/varnishd/varnishd" VARNISHVERSION=@VARNISHVERSION@ : ${DBRW_TEST_DBTYPE=@DBRW_TEST_DBTYPE@} diff --git a/tests/exact01.at b/tests/exact01.at index a98d832..41d3807 100644 --- a/tests/exact01.at +++ b/tests/exact01.at @@ -16,8 +16,11 @@ AT_SETUP(Exact) AT_KEYWORDS(exact exact01) + +AT_DBRW_INIT + AT_CHECK([ -AT_DBCRED_PREREQ +AT_DBINIT_PREREQ AT_VCL([SELECT dest FROM redirects WHERE host='$host' AND url='$url'], [txreq -url /local -hdr "Host:en.example.net" rxresp diff --git a/tests/initdb.at b/tests/initdb.at index 471942c..d158664 100644 --- a/tests/initdb.at +++ b/tests/initdb.at @@ -14,13 +14,11 @@ # You should have received a copy of the GNU General Public License # along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>. -AT_SETUP([Initialize database]) -AT_KEYWORDS([exact01 rewrite01 rewrite02 rewrite03 rewrite04 rewrite05 - rewrite06]) - +m4_define([AT_DBRW_INITDB],[ AT_CHECK([ +rm -f $FAILFILE $INITFILE AT_DBCRED_PREREQ -initdb -c mysql "$DBRW_TEST_PARAMS" 2>err <<'EOT' +initdb -c $DBRW_TEST_DBTYPE "$DBRW_TEST_PARAMS" 2>err <<'EOT' DROP TABLE IF EXISTS redirects; CREATE TABLE redirects ( host varchar(255) NOT NULL DEFAULT '', @@ -46,15 +44,16 @@ CREATE TABLE rewrite ( INSERT INTO rewrite VALUES ('en.example.net','/local','http://uno.example.com/remote',NULL,NULL,NULL), -('en.example.net','/local/%','http://dos.example.com/$1','$url','/local/(.*)',NULL), -('en.example.net','/local2/%','http://to.example.net/$1$2','$url','/local2/([[^\\?]]*)(\\?.*)?',NULL), -('to.example.net','/local/%','http://dos.example.net/$1','$url','/local/(.*)','QSA'), -('tre.example.net','/local/%','http://dos.example.net/$1?i=10','$url','/local/(.*)','QSA,R=302'); +('en.example.net','/local/%','http://dos.example.com/$[]1','$url','/local/(.*)',NULL), +('en.example.net','/local2/%','http://to.example.net/$[]1$[]2','$url','/local2/([[^\\?]]*)(\\?.*)?',NULL), +('to.example.net','/local/%','http://dos.example.net/$[]1','$url','/local/(.*)','QSA'), +('tre.example.net','/local/%','http://dos.example.net/$[]1?i=10','$url','/local/(.*)','QSA,R=302'); EOT ], [0], [], -[ignore]) - -AT_CLEANUP
\ No newline at end of file +[], +[mv err $FAILFILE], +[echo "OK" > $INITFILE]) +])
\ No newline at end of file diff --git a/tests/rewrite01.at b/tests/rewrite01.at index d6d3ca1..14232f3 100644 --- a/tests/rewrite01.at +++ b/tests/rewrite01.at @@ -16,8 +16,11 @@ AT_SETUP(Rewrite) AT_KEYWORDS(rewrite rewrite01) + +AT_DBRW_INIT + AT_CHECK([ -AT_DBCRED_PREREQ +AT_DBINIT_PREREQ AT_VCL([SELECT dest,pattern,value FROM rewrite WHERE host='$host' AND '$url' LIKE url], diff --git a/tests/rewrite02.at b/tests/rewrite02.at index 1f5d0b6..1ea4173 100644 --- a/tests/rewrite02.at +++ b/tests/rewrite02.at @@ -16,8 +16,11 @@ AT_SETUP(Rewrite 2) AT_KEYWORDS(rewrite rewrite02) + +AT_DBRW_INIT + AT_CHECK([ -AT_DBCRED_PREREQ +AT_DBINIT_PREREQ AT_VCL([SELECT dest,pattern,value FROM rewrite WHERE host='$host' AND '$url' LIKE url], diff --git a/tests/rewrite03.at b/tests/rewrite03.at index 2e1236d..6433f7d 100644 --- a/tests/rewrite03.at +++ b/tests/rewrite03.at @@ -16,8 +16,11 @@ AT_SETUP(Rewrite 3) AT_KEYWORDS(rewrite rewrite03) + +AT_DBRW_INIT + AT_CHECK([ -AT_DBCRED_PREREQ +AT_DBINIT_PREREQ AT_VCL([SELECT dest,pattern,value FROM rewrite WHERE host='$host' AND '$url' LIKE url], diff --git a/tests/rewrite04.at b/tests/rewrite04.at index e8bbef8..4715c6f 100644 --- a/tests/rewrite04.at +++ b/tests/rewrite04.at @@ -16,8 +16,11 @@ AT_SETUP(Rewrite 4) AT_KEYWORDS(rewrite rewrite04) + +AT_DBRW_INIT + AT_CHECK([ -AT_DBCRED_PREREQ +AT_DBINIT_PREREQ AT_VCL([SELECT dest,pattern,value FROM rewrite WHERE host='$host' AND '$url' LIKE url], diff --git a/tests/rewrite05.at b/tests/rewrite05.at index f33c27d..5927ba3 100644 --- a/tests/rewrite05.at +++ b/tests/rewrite05.at @@ -16,8 +16,11 @@ AT_SETUP(Rewrite 5) AT_KEYWORDS(rewrite rewrite05) + +AT_DBRW_INIT + AT_CHECK([ -AT_DBCRED_PREREQ +AT_DBINIT_PREREQ AT_VCL([SELECT dest,pattern,value FROM rewrite WHERE host='$host' AND '$url' LIKE url], diff --git a/tests/rewrite06.at b/tests/rewrite06.at index 5bd0c8f..39666b7 100644 --- a/tests/rewrite06.at +++ b/tests/rewrite06.at @@ -16,8 +16,11 @@ AT_SETUP(Rewrite 6) AT_KEYWORDS(rewrite rewrite06) + +AT_DBRW_INIT + AT_CHECK([ -AT_DBCRED_PREREQ +AT_DBINIT_PREREQ AT_VCL([SELECT dest,pattern,value,flags FROM rewrite WHERE host='$host' AND '$url' LIKE url], diff --git a/tests/testsuite.at b/tests/testsuite.at index 2dd1bb3..aafef83 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -17,8 +17,22 @@ m4_version_prereq([2.52g]) m4_define([AT_SKIP_TEST],[exit 77]) -m4_define([AT_DBCRED_PREREQ],[test -z "$DBRW_TEST_DBTYPE" && AT_SKIP_TEST -test -z "$DBRW_TEST_PARAMS" && AT_SKIP_TEST]) +m4_define([AT_DBCRED_PREREQ],[dnl +AT_SKIP_IF(test -z "$DBRW_TEST_DBTYPE" \ + -o -z "$DBRW_TEST_PARAMS")]) + +m4_include([initdb.at]) + +m4_define([AT_DBINIT_PREREQ],[dnl +AT_DBCRED_PREREQ +AT_SKIP_IF(test -f $FAILFILE) +]) + +m4_define([AT_DBRW_INIT],[ +if ! test -f $INITFILE; then + AT_DBRW_INITDB +fi +]) m4_define([AT_VCL],[ at_vcl_backend "m4_bpatsubst([$1],\$,\\$)" > test.vtc @@ -37,8 +51,6 @@ m4_define([AT_VARNISHTEST], AT_INIT -m4_include([initdb.at]) - m4_include([exact01.at]) m4_include([rewrite01.at]) |