diff options
Diffstat (limited to 'tests')
61 files changed, 2797 insertions, 930 deletions
diff --git a/tests/.gitignore b/tests/.gitignore index 4fa16bb..6a471f2 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -4,9 +4,10 @@ package.m4 testsuite testsuite.dir testsuite.log -source -dest -pushck bkupname nullmail cwdrepl +wyasync +wyclt +wyinit +chargen diff --git a/tests/Makefile.am b/tests/Makefile.am index edf7b08..c9b5e8e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,5 @@ # This file is part of Wydawca -# Copyright (C) 2009-2013, 2017, 2019-2020 Sergey Poznyakoff +# Copyright (C) 2009-2013, 2017, 2019-2022 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 @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with Wydawca. If not, see <http://www.gnu.org/licenses/>. -EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 dist +EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 DISTCLEANFILES = atconfig $(check_SCRIPTS) MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) SUBDIRS = etc @@ -40,22 +40,39 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac ## ------------ ## TESTSUITE_AT = \ + testsuite.at\ backup00.at\ backup01.at\ backup02.at\ backup03.at\ + dry_run00.at\ + dry_run01.at\ + dry_run02.at\ + upload00.at\ + upload01.at\ + upload02.at\ + upload03.at\ + upload04.at\ + upload05.at\ + verify.at\ + spoolsrc.at\ + symlink00.at\ + symlink01.at\ + rmsymlink00.at\ + mailnotify.at\ + mailstats.at\ + check-ok.at\ check-fail.at\ check-notify.at\ - check-ok.at\ - notify-upl.at\ - mailstats.at\ - pushdir.at\ - testsuite.at\ - upload.at\ - upload-dry.at\ - upl11.at\ - upl12f.at\ - upl12t.at\ + inotify-ok.at\ + inotify-symlink.at\ + inotify-rmsymlink.at\ + inotify-unatt00.at\ + inotify-unatt01.at\ + unp00.at\ + unp01.at\ + unp02.at\ + unp-idle.at\ version.at TESTSUITE = $(srcdir)/testsuite @@ -79,15 +96,15 @@ check-local: atconfig atlocal $(TESTSUITE) #installcheck-local: # $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin -check_PROGRAMS = pushck bkupname cwdrepl +check_PROGRAMS = bkupname cwdrepl wyinit wyasync wyclt chargen AM_CPPFLAGS = \ @GRECS_INCLUDES@ \ -I$(top_srcdir)/include\ -I$(top_srcdir)/src LDADD=@GRECS_LDADD@ -pushck_LDADD=../src/pushd.o bkupname_LDADD=../src/backup.o @GRECS_LDADD@ +wyinit_LDADD=@GRECS_LDADD@ if COND_MAILUTILS check_PROGRAMS += nullmail diff --git a/tests/atlocal.in b/tests/atlocal.in index d0a9899..e74149a 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -1,85 +1,149 @@ # @configure_input@ -*- shell-script -*- # Configurable variable values for Wydawca test suite. -# Copyright (C) 2009-2012, 2017, 2019-2020 Sergey Poznyakoff +# Copyright (C) 2009-2012, 2017, 2019-2023 Sergey Poznyakoff PATH=@abs_builddir@:@abs_top_builddir@/src:@abs_top_srcdir@/build-aux:$top_srcdir:$srcdir:$PATH XFAILFILE=$abs_builddir/.badversion -trap "cleanup; test -r $XFAILFILE && cat $XFAILFILE; exit $?" 1 2 13 15 +trap "test -r $XFAILFILE && cat $XFAILFILE; exit $?" 1 2 13 15 -WY_CONFSRC=@abs_top_srcdir@/tests/etc -WY_DISTDIR=@abs_top_srcdir@/tests/dist -WY_SRC=@abs_top_builddir@/tests/source -WY_DST=@abs_top_builddir@/tests/dest WY_TESTDIR=@abs_top_builddir@/tests +WY_CONFSRC=@abs_top_srcdir@/tests/etc +WY_CONFDST=$WY_TESTDIR/etc +WY_PROJECTDB=$WY_CONFSRC/project WY_MAILUTILS=@WY_MAILUTILS@ -MKDIR_P="@MKDIR_P@" +WY_INOTIFY=@WY_INOTIFY@ +WY_MODDIR=@abs_top_builddir@/modules/mailutils/.libs -if test -w /; then - WY_FORCE=--force -else - WY_FORCE= +GPG="@GPG@" +if [ -n "$GPG" ]; then + GPG="$GPG --quiet --no-permission-warning --batch " fi +GNUPGHOME=$WY_CONFDST/gnupg +export GNUPGHOME ulimit -c unlimited -wydawca_init_testdirs() { - for dir in "$WY_SRC" "$WY_SRC/test" "${WY_SRC}/fail" "${WY_SRC}/ok" "$WY_DST" - do - if test -d "$dir"; then - rm -rf "$dir"/* - else - mkdir "$dir" - fi - done -} +# ##################################### +# Utility functions +# ##################################### -wydawca_clean_testdirs() { - rm -rf "$WY_SRC" "$WY_DST" +# wy_project_lookup PROJECT WHAT +wy_project_lookup() { + test $# -eq 2 || echo >&2 "wy_project_lookup: bad number of arguments" + local n + case $2 in + PROJECT_NAME) n=1;; + REAL_NAME) n=2;; + EMAIL) n=3;; + COMMENT) n=4;; + esac + grep "^$1:" $WY_PROJECTDB | cut -d: -f$n } -wydawca_expandmeta() { - sed -e "s/@USER@/$USER/g" \ - -e "s,@WY_SRC@,$WY_SRC,g" \ - -e "s,@WY_DST@,$WY_DST,g" \ - -e "s,@WY_CONFSRC@,$WY_CONFSRC,g" \ - -e "s,@WY_TESTDIR@,$WY_TESTDIR,g" \ - -e "s,@WY_MODDIR@,@abs_top_builddir@/modules/mailutils,g" $1 > $2 -} +# wy_create_directive [-c] [-v X.Y] [-u USER] FILENAME PROJECT [DIRECTIVE: VALUE ...] +wy_create_directive() { + local clear version user + while [ $# -ne 0 ] + do + case $1 in + -c) clear=1 + shift;; + -v) version=$2 + shift 2;; + -u) user=$2 + shift 2;; + --) shift + break;; + *) break + esac + done -wydawca_config() { - wydawca_expandmeta $WY_CONFSRC/${1}in $1 + if test -z "$clear"; then + : ${version:=1.2} + fi + + local filename="$1.directive" project=$2 + shift 2 + if [ $(( $# % 2 )) -ne 0 ]; then + echo >&2 "wy_create_directive: odd number of arguments" + exit 1 + fi + (if test -n "$version"; then + echo "version: $version" + fi + if test -z "$clear"; then + echo "directory: $project" + fi + + while [ $# -gt 0 ] + do + echo "$1 $2" + shift 2 + done) > $filename + rm -f $filename.asc + : ${user:=$(wy_project_lookup $project REAL_NAME)} + rm -f $filename.asc + $GPG --clearsign -u "$user" -o $filename.asc $filename + rm $filename } -wydawca_upload() { - dir="$WY_SRC/$1" - shift - file=$1 - shift - cp "$WY_DISTDIR/$file" "$dir" - cp "$WY_DISTDIR/$file.sig" "$dir" - if test -n "$1"; then - cp "$WY_DISTDIR/$1" "$dir/$file.directive.asc" - else - cp "$WY_DISTDIR/$file.directive.asc" "$dir" - fi +# wy_genfile [-u USER] [-l SIZE] PROJECT NAME +wy_genfile() { + local length user + while [ $# -ne 0 ] + do + case $1 in + -l) length="-l $2" + shift 2;; + -u) user=$2 + shift 2;; + --) shift + break;; + *) break + esac + done + + local project=$1 filename=$2 + chargen $length > $filename + + : ${user:=$(wy_project_lookup $project REAL_NAME)} + rm -f $filename.sig + $GPG -ba -o $filename.sig $filename } -wydawca_cmp() { - p=$1 - shift - for file in $@ - do - cmp "$WY_DISTDIR/$file" "$WY_DST/$p/$file" || exit 1 - done +# wy_create_upload [-u USER] [-l SIZE] PROJECT NAME [DIRECTIVE: VALUE...] +wy_create_upload() { + local length_option user_option + while [ $# -ne 0 ] + do + case $1 in + -l) + length_option="$1 $2" + shift 2;; + -u) + user_option="$1 $2" + shift 2;; + --) shift + break;; + *) break + esac + done + local project=$1 filename=$2 + shift 2 + wy_genfile $length_option $user_option $project $filename + wy_create_directive $user_option $filename $project\ + filename: $(basename $filename)\ + "$@" } -wydawca_cmparc() { - p=$1 - shift - for file in $@ - do - cmp "$WY_DISTDIR/$file" "$WY_DST/$p/archive/$file" || exit 1 - done +wy_config_head() { + cat <<EOF +pidfile $PWD/wydawca.pid; +statistics all; +umask 022; +create-directories yes; +#include "$WY_CONFDST/database.cf" +EOF } diff --git a/tests/backup00.at b/tests/backup00.at index fa6c63d..16dd6be 100644 --- a/tests/backup00.at +++ b/tests/backup00.at @@ -1,5 +1,5 @@ # This file is part of wydawca testsuite -*- Autotest -*- -# Copyright (C) 2009-2010, 2017, 2019-2020 Sergey Poznyakoff +# Copyright (C) 2009-2010, 2017, 2019-2022 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 diff --git a/tests/backup01.at b/tests/backup01.at index 8c160a0..8dd8c41 100644 --- a/tests/backup01.at +++ b/tests/backup01.at @@ -1,5 +1,5 @@ # This file is part of wydawca testsuite -*- Autotest -*- -# Copyright (C) 2009-2011, 2017, 2019-2020 Sergey Poznyakoff +# Copyright (C) 2009-2011, 2017, 2019-2022 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 diff --git a/tests/backup02.at b/tests/backup02.at index 070ce20..025a2c3 100644 --- a/tests/backup02.at +++ b/tests/backup02.at @@ -1,5 +1,5 @@ # This file is part of wydawca testsuite -*- Autotest -*- -# Copyright (C) 2009-2011, 2017, 2019-2020 Sergey Poznyakoff +# Copyright (C) 2009-2011, 2017, 2019-2022 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 diff --git a/tests/backup03.at b/tests/backup03.at index ec89e28..b8760fe 100644 --- a/tests/backup03.at +++ b/tests/backup03.at @@ -1,5 +1,5 @@ # This file is part of wydawca testsuite -*- Autotest -*- -# Copyright (C) 2009-2011, 2017, 2019-2020 Sergey Poznyakoff +# Copyright (C) 2009-2011, 2017, 2019-2022 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 diff --git a/tests/bkupname.c b/tests/bkupname.c index d1de3a0..9f95f75 100644 --- a/tests/bkupname.c +++ b/tests/bkupname.c @@ -1,5 +1,5 @@ /* wordsplit - a word splitter - Copyright (C) 2009-2011, 2017, 2019-2020 Sergey Poznyakoff + Copyright (C) 2009-2011, 2017, 2019-2022 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -20,60 +20,56 @@ char *progname; void -usage (int code) +usage(int code) { - FILE *fp = code ? stderr : stdout; + FILE *fp = code ? stderr : stdout; - fprintf (fp, "usage: %s [-no] [-simple] [-existing] [-numbered] [-suffix=S] FILE\n", - progname); - exit (code); + fprintf(fp, + "usage: %s [-no] [-simple] [-existing] [-numbered] [-suffix=S] FILE\n", + progname); + exit(code); } int -main (int argc, char **argv) +main(int argc, char **argv) { - enum backup_type type = numbered_backups; - char *file = NULL; - char *backup; - - progname = argv[0]; - while (--argc) - { - char *arg = *++argv; - if (strcmp (arg, "-no") == 0) - type = no_backups; - else if (strcmp (arg, "-simple") == 0) - type = simple_backups; - else if (strcmp (arg, "-existing") == 0) - type = numbered_existing_backups; - else if (strcmp (arg, "-numbered") == 0) - type = numbered_backups; - else if (strncmp (arg, "-suffix=", 8) == 0) - simple_backup_suffix = arg + 8; - else if (arg[0] == '-') - usage (2); - else - { - if (argc != 1) - usage (2); - file = arg; + enum backup_type type = numbered_backups; + char *file = NULL; + char *backup; + + progname = argv[0]; + while (--argc) { + char *arg = *++argv; + if (strcmp(arg, "-no") == 0) + type = no_backups; + else if (strcmp(arg, "-simple") == 0) + type = simple_backups; + else if (strcmp(arg, "-existing") == 0) + type = numbered_existing_backups; + else if (strcmp(arg, "-numbered") == 0) + type = numbered_backups; + else if (strncmp(arg, "-suffix=", 8) == 0) + simple_backup_suffix = arg + 8; + else if (arg[0] == '-') + usage(2); + else { + if (argc != 1) + usage(2); + file = arg; } } - if (!file) - usage (2); - backup = find_backup_file_name (file, type); - if (!backup) - { - if (errno) - { - perror (file); - exit (1); + if (!file) + usage(2); + backup = find_backup_file_name(AT_FDCWD, file, type); + if (!backup) { + if (errno) { + perror(file); + exit(1); } - printf ("no backup\n"); - } - else - printf ("%s\n", backup); - free (backup); - exit (0); + printf("no backup\n"); + } else + printf("%s\n", backup); + free(backup); + exit(0); } diff --git a/tests/chargen.c b/tests/chargen.c new file mode 100644 index 0000000..42cf9ee --- /dev/null +++ b/tests/chargen.c @@ -0,0 +1,96 @@ +/* + NAME + chargen - generate a stream of characters + + SYNOPSIS + chargen [-c C] [-l LEN] [-p] [-s N] + + DESCRIPTION + Produces on standard output a stream of characters. The stream consists + of all 256 characters repeated cyclically until total number of characters + reaches 4096 (or LEN). + + OPTIONS + -c C Start from ASCII character C + + -l LEN + Stop when LEN characters have been generated. + + -p Produce only printable characters + + -s N Start from character with ordinal number N + + LICENSE + Copyright (C) 2020-2022 Sergey Poznyakoff + + This program 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 of the License, or (at your + option) any later version. + + This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +*/ +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <unistd.h> +#include <errno.h> +#include <ctype.h> + +int +main(int argc, char **argv) +{ + int c; + int start = 0; + int mod = UCHAR_MAX; + size_t i, len = 4096; + int printable = 0; + char *p; + + while ((c = getopt(argc, argv, "cl:ps:")) != EOF) { + switch (c) { + case 'c': + start = optarg[0]; + break; + case 'p': + printable = 1; + break; + case 's': + start = atoi(optarg) % UCHAR_MAX; + break; + case 'l': + errno = 0; + len = strtoul(optarg, &p, 10); + if (*p) { + fprintf(stderr, "bad length (near %s)", p); + exit(1); + } else if (errno) { + perror("bad length"); + exit(1); + } + break; + default: + exit(2); + } + } + + if (printable && !isprint(start)) + do { + start = (start + 1) % mod; + } while (printable && !isprint(start)); + + for (i = 0; i < len; i++) { + putchar(start); + do { + start = (start + 1) % mod; + } while (printable && !isprint(start)); + } + return 0; +} diff --git a/tests/check-fail.at b/tests/check-fail.at index 630889c..7e0e8ac 100644 --- a/tests/check-fail.at +++ b/tests/check-fail.at @@ -1,5 +1,5 @@ # Check distribution verification tests - failure -*- Autotest -*- -# Copyright (C) 2010-2012, 2017, 2019-2020 Sergey Poznyakoff +# Copyright (C) 2010-2012, 2017, 2019-2022 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 @@ -16,15 +16,28 @@ AT_SETUP([Verification test failure]) AT_KEYWORDS([uploads check-test check-fail]) - -AT_DATA([template], +AT_CHECK_UPLOAD([ +spool test { + url "ftp://wydawca.test"; + source "$PWD/upload"; + destination "$PWD/dest"; + check-script "exit 1"; +} +], +[wy_create_upload conversion upload/conversion-1.1.tar +cp -a upload orig +set -e +wydawca --no-preproc -c wydawca.cf 2>err +cat err | cwdrepl >&2 +], +[0], +[], [wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started -wydawca: [[NOTICE]] file.directive.asc: VERSION: 1.1 -wydawca: [[NOTICE]] file.directive.asc: COMMENT: Gnupload for Wydawca testsuite -wydawca: [[ERR]] spool check script for file@ckfail returned 1 -wydawca: [[NOTICE]] removing file -wydawca: [[NOTICE]] removing file.sig -wydawca: [[NOTICE]] removing file.directive.asc +wydawca: [[NOTICE]] conversion-1.1.tar.directive.asc: VERSION: 1.2 +wydawca: [[ERR]] spool check script for conversion-1.1.tar@test returned 1 +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar.sig +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar.directive.asc wydawca: [[INFO]] errors: 1 wydawca: [[INFO]] warnings: 0 wydawca: [[INFO]] bad signatures: 0 @@ -41,20 +54,4 @@ 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 - -wydawca_expandmeta template experr - -wydawca $WY_FORCE --no-preproc -c wydawca.rc -], -[0], -[], -[experr]) - -wydawca_clean_testdirs - AT_CLEANUP diff --git a/tests/check-notify.at b/tests/check-notify.at index ed2b140..11539a7 100644 --- a/tests/check-notify.at +++ b/tests/check-notify.at @@ -1,5 +1,5 @@ # Check distribution verification tests - failure notification -*- Autotest -*- -# Copyright (C) 2010-2012, 2017, 2019-2020 Sergey Poznyakoff +# Copyright (C) 2010-2012, 2017, 2019-2023 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 @@ -17,14 +17,67 @@ AT_SETUP([Verification test failure notification]) AT_KEYWORDS([uploads check-test check-fail check-fail-notify notify]) -AT_DATA([template], +AT_CHECK_UPLOAD([ +module-prepend-load-path "$WY_MODDIR"; +module mailutils mod_mailutils.so; +module-init mailutils { + admin-address "root@localhost"; + from-address "wydawca-noreply@localhost"; + mailer "| $WY_TESTDIR/nullmail -o $PWD/mail.out -F \${sender} \${rcpt}"; +} + +#include "$WY_CONFSRC/notify.cf" + +spool test { + url "ftp://wydawca.test"; + source "$PWD/upload"; + destination "$PWD/dest"; + 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; +} +], +[wy_create_upload conversion upload/conversion-1.1.tar +cp -a upload orig +set -e +wydawca --no-preproc -c wydawca.cf 2>err +cat err | cwdrepl >&2 +cat mail.out | cwdrepl +], +[0], +[From wydawca-noreply@localhost +From: wydawca-noreply@localhost +To: "Wydawca tester for the Conversion project" <jeannot@example.com> +Subject: conversion-1.1.tar rejected + +Your upload of conversion-1.1.tar has been rejected by the distribution +verification procedure with the following diagnostics: + +WYDAWCA_SPOOL=test +WYDAWCA_SOURCE=./upload +WYDAWCA_DEST=./dest +WYDAWCA_URL=ftp://wydawca.test +WYDAWCA_TRIPLET_BASE=conversion-1.1.tar +WYDAWCA_DIST_FILE=conversion-1.1.tar + +Please fix the tarball and resubmit. + +Regards, +Wydawca +T |