diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-01-02 18:50:14 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-01-02 18:50:14 +0200 |
commit | 1b0a4de9fa73dd2453cbd2902c2cd4d000f4abe7 (patch) | |
tree | 061ee328e2464d5bed9f5882642fbc25d32de8bc | |
parent | a510f517e1aff073e6b37a5fa9e8ed825de836af (diff) | |
download | wydawca-1b0a4de9fa73dd2453cbd2902c2cd4d000f4abe7.tar.gz wydawca-1b0a4de9fa73dd2453cbd2902c2cd4d000f4abe7.tar.bz2 |
Add testcases for distribution tarball checking.
* src/directive.c (run_check_script): Reword diagnostic messages.
* tests/check-fail.at: New testcase.
* tests/check-notify.at: New testcase.
* tests/check-ok.at: New testcase.
* tests/Makefile.am: Add new files.
* tests/testsuite.at: Include new tests.
* tests/atlocal.in (wydawca_init_testdirs): Create three
source subdirectories.
(wydawca_upload): Treat first argument as the name of a
source subdirectory.
* tests/etc/notify.rc: Add check-failure notification.
* tests/etc/wydawca.rcin (ckfail, ckok): New spools.
* tests/mailstats.at, tests/notify-upl.at, tests/upload.at: Update.
* tests/upload-dry.at: Update output template.
-rw-r--r-- | src/directive.c | 8 | ||||
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/atlocal.in | 6 | ||||
-rw-r--r-- | tests/check-fail.at | 56 | ||||
-rw-r--r-- | tests/check-notify.at | 86 | ||||
-rw-r--r-- | tests/check-ok.at | 56 | ||||
-rw-r--r-- | tests/etc/notify.rc | 20 | ||||
-rw-r--r-- | tests/etc/wydawca.rcin | 27 | ||||
-rw-r--r-- | tests/mailstats.at | 2 | ||||
-rw-r--r-- | tests/notify-upl.at | 3 | ||||
-rw-r--r-- | tests/testsuite.at | 4 | ||||
-rw-r--r-- | tests/upload-dry.at | 6 | ||||
-rw-r--r-- | tests/upload.at | 2 |
13 files changed, 266 insertions, 13 deletions
diff --git a/src/directive.c b/src/directive.c index f648e07..3d70fa8 100644 --- a/src/directive.c +++ b/src/directive.c @@ -519,32 +519,32 @@ run_check_script (const char *script, struct file_triplet *trp, trp->check_result = status; if (WIFEXITED (status)) { status = WEXITSTATUS (status); if (status) { - logmsg (LOG_ERR, "%s for triplet %s, spool %s returned %d", + logmsg (LOG_ERR, "%s for %s@%s returned %d", descr, trp->name, trp->spool->tag, status); return 1; } else if (debug_level > 2) - logmsg (LOG_DEBUG, "%s for triplet %s, spool %s returned %d", + logmsg (LOG_DEBUG, "%s for %s@%s returned %d", descr, trp->name, trp->spool->tag, status); } else if (WIFSIGNALED (status)) { int sig = WTERMSIG (status); logmsg (LOG_NOTICE, - "%s for triplet %s, spool %s terminated on signal %d", + "%s for %s@%s terminated on signal %d", descr, trp->name, trp->spool->tag, sig); return 1; } else { logmsg (LOG_NOTICE, - "%s for triplet %s, spool %s terminated with unhandled status", + "%s for %s@%s terminated with unhandled status", descr, trp->name, trp->spool->tag); return 1; } return 0; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 7d8aead..3da497b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -37,12 +37,15 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac ## ------------ ## ## Test suite. ## ## ------------ ## TESTSUITE_AT = \ + check-fail.at\ + check-notify.at\ + check-ok.at\ testsuite.at\ notify-upl.at\ mailstats.at\ upload.at\ upload-dry.at\ version.at\ diff --git a/tests/atlocal.in b/tests/atlocal.in index b3906f8..7f6e327 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -11,13 +11,13 @@ trap "cleanup; test -r $XFAILFILE && cat $XFAILFILE; exit $?" 1 2 13 15 WD_CONFSRC=@abs_top_srcdir@/tests/etc WD_DISTDIR=@abs_top_srcdir@/tests/dist WD_SRC=@abs_top_builddir@/tests/source WD_DST=@abs_top_builddir@/tests/dest wydawca_init_testdirs() { - for dir in "$WD_SRC" "$WD_DST" + for dir in "$WD_SRC" "$WD_SRC/test" "${WD_SRC}/fail" "${WD_SRC}/ok" "$WD_DST" do if test -d "$dir"; then rm -rf "$dir"/* else mkdir "$dir" fi @@ -34,15 +34,17 @@ wydawca_expandmeta() { wydawca_config() { wydawca_expandmeta $WD_CONFSRC/${1}in $1 } wydawca_upload() { + dir="$WD_SRC/$1" + shift for file in $@ do - cp "$WD_DISTDIR/$file" "$WD_SRC" + cp "$WD_DISTDIR/$file" "$dir" done } wydawca_cmp() { p=$1 shift diff --git a/tests/check-fail.at b/tests/check-fail.at new file mode 100644 index 0000000..8d1e86a --- /dev/null +++ b/tests/check-fail.at @@ -0,0 +1,56 @@ +# Check distribution verification tests - failure -*- Autotest -*- +# Copyright (C) 2010 Sergey Poznyakoff +# +# Wydawca is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Wydawca is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Wydawca. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Verification test failure]) +AT_KEYWORDS([uploads check-test check-fail]) + +AT_DATA([template], +[wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started +wydawca: [[NOTICE]] file.directive.asc: COMMENT: Gnupload for Wydawca testsuite +wydawca: [[ERR]] spool check script for file@ckfail returned 1 +wydawca: [[INFO]] errors: 1 +wydawca: [[INFO]] warnings: 0 +wydawca: [[INFO]] bad signatures: 0 +wydawca: [[INFO]] access violation attempts: 0 +wydawca: [[INFO]] complete triplets: 1 +wydawca: [[INFO]] incomplete triplets: 0 +wydawca: [[INFO]] bad triplets: 0 +wydawca: [[INFO]] expired triplets: 0 +wydawca: [[INFO]] triplet successes: 0 +wydawca: [[INFO]] files uploaded: 0 +wydawca: [[INFO]] files archived: 0 +wydawca: [[INFO]] symlinks created: 0 +wydawca: [[INFO]] symlinks removed: 0 +wydawca: [[INFO]] check failures: 1 +wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished +]) + +AT_CHECK([ +wydawca_init_testdirs +wydawca_config wydawca.rc +wydawca_upload fail file file.directive.asc file.sig + +wydawca_expandmeta template experr + +wydawca --no-preproc -c wydawca.rc +], +[0], +[], +[experr]) + +wydawca_clean_testdirs + +AT_CLEANUP diff --git a/tests/check-notify.at b/tests/check-notify.at new file mode 100644 index 0000000..16ae296 --- /dev/null +++ b/tests/check-notify.at @@ -0,0 +1,86 @@ +# Check distribution verification tests - failure notification -*- Autotest -*- +# Copyright (C) 2010 Sergey Poznyakoff +# +# Wydawca is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Wydawca is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Wydawca. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Verification test failure notification]) +AT_KEYWORDS([uploads check-test check-fail check-fail-notify notify]) + +AT_DATA([template], +[wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started +wydawca: [[NOTICE]] file.directive.asc: COMMENT: Gnupload for Wydawca testsuite +wydawca: [[ERR]] spool check script for file@ckfail returned 1 +wydawca: [[INFO]] errors: 1 +wydawca: [[INFO]] warnings: 0 +wydawca: [[INFO]] bad signatures: 0 +wydawca: [[INFO]] access violation attempts: 0 +wydawca: [[INFO]] complete triplets: 1 +wydawca: [[INFO]] incomplete triplets: 0 +wydawca: [[INFO]] bad triplets: 0 +wydawca: [[INFO]] expired triplets: 0 +wydawca: [[INFO]] triplet successes: 0 +wydawca: [[INFO]] files uploaded: 0 +wydawca: [[INFO]] files archived: 0 +wydawca: [[INFO]] symlinks created: 0 +wydawca: [[INFO]] symlinks removed: 0 +wydawca: [[INFO]] check failures: 1 +wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished +]) + +AT_DATA([outtmpl], +[-F wydawca-noreply@localhost @USER@@localhost +========= +From: wydawca-noreply@localhost +To: "Wydawca Test User" <@USER@@localhost> +Subject: file rejected +X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) + +Your upload of file has been rejected by the distribution +verification procedure with the following diagnostics: + +WYDAWCA_SPOOL=ckfail +WYDAWCA_SOURCE=@WD_SRC@/fail +WYDAWCA_DEST=@WD_DST@ +WYDAWCA_URL=ftp://wydawca.ckfail +WYDAWCA_TRIPLET_BASE=file +WYDAWCA_DIST_FILE=file + +Please fix the tarball and resubmit. + +Regards, +Wydawca +The Project Submission Robot +]) + +AT_CHECK([ +wydawca_init_testdirs +wydawca_config wydawca.rc +mv wydawca.rc simple.rc +cat $WD_CONFSRC/notify.rc simple.rc > wydawca.rc + +wydawca_upload fail file file.directive.asc file.sig + +wydawca_expandmeta outtmpl expout +wydawca_expandmeta template experr + +wydawca --no-preproc -c wydawca.rc || exit $? +cat $WD_DST/mail.out +], +[0], +[expout], +[experr]) + +wydawca_clean_testdirs + +AT_CLEANUP diff --git a/tests/check-ok.at b/tests/check-ok.at new file mode 100644 index 0000000..8942631 --- /dev/null +++ b/tests/check-ok.at @@ -0,0 +1,56 @@ +# Check distribution verification tests - success -*- Autotest -*- +# Copyright (C) 2010 Sergey Poznyakoff +# +# Wydawca is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Wydawca is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Wydawca. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Verification test success]) +AT_KEYWORDS([uploads check-test check-success check-ok]) + +AT_DATA([template], +[wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started +wydawca: [[NOTICE]] file.directive.asc: COMMENT: Gnupload for Wydawca testsuite +wydawca: [[INFO]] errors: 0 +wydawca: [[INFO]] warnings: 0 +wydawca: [[INFO]] bad signatures: 0 +wydawca: [[INFO]] access violation attempts: 0 +wydawca: [[INFO]] complete triplets: 1 +wydawca: [[INFO]] incomplete triplets: 0 +wydawca: [[INFO]] bad triplets: 0 +wydawca: [[INFO]] expired triplets: 0 +wydawca: [[INFO]] triplet successes: 1 +wydawca: [[INFO]] files uploaded: 2 +wydawca: [[INFO]] files archived: 0 +wydawca: [[INFO]] symlinks created: 0 +wydawca: [[INFO]] symlinks removed: 0 +wydawca: [[INFO]] check failures: 0 +wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished +]) + +AT_CHECK([ +wydawca_init_testdirs +wydawca_config wydawca.rc +wydawca_upload ok file file.directive.asc file.sig + +wydawca_expandmeta template experr + +wydawca --no-preproc -c wydawca.rc || exit $? +wydawca_cmp proj file file.sig +], +[0], +[], +[experr]) + +wydawca_clean_testdirs + +AT_CLEANUP diff --git a/tests/etc/notify.rc b/tests/etc/notify.rc index 528d8f5..4461ce3 100644 --- a/tests/etc/notify.rc +++ b/tests/etc/notify.rc @@ -171,6 +171,26 @@ This upload has been ignored and the files removed. Regards, Wydawca The Project Submission Robot EOT; } + +notify-event { + event check-failure; + recipient user; + message <<EOT +Subject: ${triplet:dist} rejected + +Your upload of ${triplet:dist} has been rejected by the distribution +verification procedure with the following diagnostics: + +${check:diagn} +Please fix the tarball and resubmit. + +Regards, +Wydawca +The Project Submission Robot +EOT; +} + + diff --git a/tests/etc/wydawca.rcin b/tests/etc/wydawca.rcin index d012554..7e9f4ad 100644 --- a/tests/etc/wydawca.rcin +++ b/tests/etc/wydawca.rcin @@ -23,13 +23,12 @@ locking no; dictionary project-owner { type builtin; query "${project}"; params ("/exact", "proj", "proj-owner@localhost", "Project Admin"); } - dictionary project-uploader { type builtin; query "${project}"; params ("/exact", "proj", "gray", "Wydawca Test User", "gray@localhost", "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" @@ -63,15 +62,39 @@ dictionary project-uploader { "=gYgX\n" "-----END PGP PUBLIC KEY BLOCK-----\n"); } spool test { url ftp://wydawca.test; - source "@WD_SRC@"; + source "@WD_SRC@/test"; + destination "@WD_DST@"; + archive none; +} + +spool ckfail { + url ftp://wydawca.ckfail; + source "@WD_SRC@/fail"; + destination "@WD_DST@"; + archive none; + check-script <<EOT +echo WYDAWCA_SPOOL=$WYDAWCA_SPOOL +echo WYDAWCA_SOURCE=$WYDAWCA_SOURCE +echo WYDAWCA_DEST=$WYDAWCA_DEST +echo WYDAWCA_URL=$WYDAWCA_URL +echo WYDAWCA_TRIPLET_BASE=$WYDAWCA_TRIPLET_BASE +echo WYDAWCA_DIST_FILE=$WYDAWCA_DIST_FILE +exit 1 +EOT; +} + +spool ckok { + url ftp://wydawca.ckok; + source "@WD_SRC@/ok"; destination "@WD_DST@"; archive none; + check-script "exit 0"; } admin-address "root@localhost"; from-address "wydawca-noreply@localhost"; mailer "| @WD_CONFSRC@/nullmail @WD_DST@/mail.out -F ${sender} ${rcpt}"; diff --git a/tests/mailstats.at b/tests/mailstats.at index 7722bab..2b35d46 100644 --- a/tests/mailstats.at +++ b/tests/mailstats.at @@ -66,13 +66,13 @@ Wydawca ]) AT_CHECK([ wydawca_init_testdirs wydawca_config wydawca.rc cat $WD_CONFSRC/mailstats.rc >> wydawca.rc -wydawca_upload file file.directive.asc file.sig +wydawca_upload test file file.directive.asc file.sig wydawca_expandmeta errtmpl experr ulimit -c unlimited wydawca --no-preproc -c wydawca.rc || exit $? wydawca_cmp proj file file.sig cat $WD_DST/mail.out diff --git a/tests/notify-upl.at b/tests/notify-upl.at index 73283cc..d91a4d6 100644 --- a/tests/notify-upl.at +++ b/tests/notify-upl.at @@ -12,12 +12,13 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Wydawca. If not, see <http://www.gnu.org/licenses/>. AT_SETUP([Simple upload and notification]) +AT_KEYWORDS([notify]) AT_DATA([errtmpl], [wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started wydawca: [[NOTICE]] file.directive.asc: COMMENT: Gnupload for Wydawca testsuite wydawca: [[INFO]] errors: 0 wydawca: [[INFO]] warnings: 0 @@ -78,13 +79,13 @@ s,^-[[rwx-]]\{9\} @USER@.*file.sig$,listing of file.sig, AT_CHECK([ wydawca_init_testdirs wydawca_config wydawca.rc mv wydawca.rc simple.rc cat $WD_CONFSRC/notify.rc simple.rc > wydawca.rc -wydawca_upload file file.directive.asc file.sig +wydawca_upload test file file.directive.asc file.sig wydawca_expandmeta errtmpl experr wydawca_expandmeta outtmpl expout wydawca_expandmeta ls.sin ls.sed wydawca --no-preproc -c wydawca.rc || exit $? diff --git a/tests/testsuite.at b/tests/testsuite.at index 055e10a..1adc6db 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -24,6 +24,10 @@ AT_TESTED([wydawca]) m4_include([version.at]) m4_include([wordsplit.at]) m4_include([upload-dry.at]) m4_include([upload.at]) m4_include([notify-upl.at]) m4_include([mailstats.at]) + +m4_include([check-fail.at]) +m4_include([check-ok.at]) +m4_include([check-notify.at]) diff --git a/tests/upload-dry.at b/tests/upload-dry.at index 39772b3..8102df7 100644 --- a/tests/upload-dry.at +++ b/tests/upload-dry.at @@ -15,13 +15,15 @@ # along with Wydawca. If not, see <http://www.gnu.org/licenses/>. AT_SETUP([Dry-run upload]) AT_DATA([template], [wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started -wydawca: [[DEBUG]] @WD_SRC@ -> @WD_DST@ +wydawca: [[DEBUG]] @WD_SRC@/ok -> @WD_DST@ +wydawca: [[DEBUG]] @WD_SRC@/fail -> @WD_DST@ +wydawca: [[DEBUG]] @WD_SRC@/test -> @WD_DST@ wydawca: [[DEBUG]] found file file: distributive, stem: file wydawca: [[DEBUG]] found file file.directive.asc: signed upload directive, stem: file wydawca: [[DEBUG]] found file file.sig: detached signature, stem: file wydawca: [[DEBUG]] processing spool test (@WD_DST@) wydawca: [[DEBUG]] FILE file, DIST=file, SIG=file.sig, DIRECTIVE=file.directive.asc wydawca: [[NOTICE]] Good signature from Wydawca (Testsuite) <bug-wydawca@gnu.org.ua> @@ -48,13 +50,13 @@ wydawca: [[INFO]] check failures: 0 wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished ]) AT_CHECK([ wydawca_init_testdirs wydawca_config wydawca.rc -wydawca_upload file file.directive.asc file.sig +wydawca_upload test file file.directive.asc file.sig wydawca_expandmeta template experr wydawca --no-preproc --dry-run -c wydawca.rc ], [0], diff --git a/tests/upload.at b/tests/upload.at index 4bd9252..a7b14ee 100644 --- a/tests/upload.at +++ b/tests/upload.at @@ -36,13 +36,13 @@ wydawca: [[INFO]] check failures: 0 wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished ]) AT_CHECK([ wydawca_init_testdirs wydawca_config wydawca.rc -wydawca_upload file file.directive.asc file.sig +wydawca_upload test file file.directive.asc file.sig wydawca_expandmeta template experr wydawca --no-preproc -c wydawca.rc || exit $? wydawca_cmp proj file file.sig ], |