From 1b0a4de9fa73dd2453cbd2902c2cd4d000f4abe7 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sat, 2 Jan 2010 18:50:14 +0200 Subject: 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. --- src/directive.c | 8 ++--- tests/Makefile.am | 3 ++ tests/atlocal.in | 6 ++-- tests/check-fail.at | 56 ++++++++++++++++++++++++++++++++ tests/check-notify.at | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/check-ok.at | 56 ++++++++++++++++++++++++++++++++ tests/etc/notify.rc | 20 ++++++++++++ tests/etc/wydawca.rcin | 27 ++++++++++++++-- tests/mailstats.at | 2 +- tests/notify-upl.at | 3 +- tests/testsuite.at | 4 +++ tests/upload-dry.at | 6 ++-- tests/upload.at | 2 +- 13 files changed, 266 insertions(+), 13 deletions(-) create mode 100644 tests/check-fail.at create mode 100644 tests/check-notify.at create mode 100644 tests/check-ok.at diff --git a/src/directive.c b/src/directive.c index f648e07..3d70fa8 100644 --- a/src/directive.c +++ b/src/directive.c @@ -522,26 +522,26 @@ run_check_script (const char *script, struct file_triplet *trp, 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; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 7d8aead..3da497b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -40,6 +40,9 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac ## ------------ ## TESTSUITE_AT = \ + check-fail.at\ + check-notify.at\ + check-ok.at\ testsuite.at\ notify-upl.at\ mailstats.at\ diff --git a/tests/atlocal.in b/tests/atlocal.in index b3906f8..7f6e327 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -14,7 +14,7 @@ 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"/* @@ -37,9 +37,11 @@ wydawca_config() { } wydawca_upload() { + dir="$WD_SRC/$1" + shift for file in $@ do - cp "$WD_DISTDIR/$file" "$WD_SRC" + cp "$WD_DISTDIR/$file" "$dir" done } 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 . + +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 . + +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 . + +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 @@ -174,3 +174,23 @@ Wydawca The Project Submission Robot EOT; } + +notify-event { + event check-failure; + recipient user; + message <> 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 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 @@ -15,6 +15,7 @@ # along with Wydawca. If not, see . AT_SETUP([Simple upload and notification]) +AT_KEYWORDS([notify]) AT_DATA([errtmpl], [wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started @@ -81,7 +82,7 @@ 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 diff --git a/tests/testsuite.at b/tests/testsuite.at index 055e10a..1adc6db 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -27,3 +27,7 @@ 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 @@ -18,7 +18,9 @@ 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 @@ -51,7 +53,7 @@ wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) fini 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 diff --git a/tests/upload.at b/tests/upload.at index 4bd9252..a7b14ee 100644 --- a/tests/upload.at +++ b/tests/upload.at @@ -39,7 +39,7 @@ wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) fini 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 -- cgit v1.2.1