From 42ed39da5af85552a35626348bb77e5576e18aa4 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 6 Mar 2022 14:25:13 +0000 Subject: Utilities: fix exiqgrep perl syntax, add testcases. Bug 2821 Broken-by: df618101a5 --- test/README | 6 +++++ test/runtest | 15 +++++++++-- test/scripts/0000-Basic/0611 | 6 +++++ test/stdout/0611 | 62 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 test/stdout/0611 (limited to 'test') diff --git a/test/README b/test/README index bca17eb18..ab9fb6496 100644 --- a/test/README +++ b/test/README @@ -747,6 +747,12 @@ This command runs the exigrep utility with the given data (the search pattern) on the current mainlog file. + exiqgrep + +This command runs the exiqgrep utility with the given options +on the current spool directory. + + gnutls This command is present at the start of all but one of the tests that use diff --git a/test/runtest b/test/runtest index 2ac6198eb..f0fc25f75 100755 --- a/test/runtest +++ b/test/runtest @@ -2416,6 +2416,17 @@ if (/^exigrep\s+(.*)/) } +# The "exiqgrep" command runs exiqgrep on the current spool + +if (/^exiqgrep(\s+.*)?/) + { + run_system("(./eximdir/exiqgrep -E ./eximdir/exim -C $parm_cwd/test-config" . ($1 || '') . ";" . + "echo exiqgrep exit code = \$?)" . + ">>test-stdout"); + return 1; + } + + # The "eximstats" command runs eximstats on the current mainlog if (/^eximstats\s+(.*)/) @@ -3798,7 +3809,7 @@ if (defined $parm_lookups{dbm} && not cp("$parm_exim_dir/exim_dbmbuild", "eximdi $dbm_build_deleted = 1; } -foreach my $tool (qw(exim_dumpdb exim_lock exinext exigrep eximstats)) { +foreach my $tool (qw(exim_dumpdb exim_lock exinext exigrep eximstats exiqgrep)) { cp("$parm_exim_dir/$tool" => "eximdir/$tool") or tests_exit(-1, "Failed to make a copy of $tool: $!"); } @@ -3806,7 +3817,7 @@ foreach my $tool (qw(exim_dumpdb exim_lock exinext exigrep eximstats)) { # Collect some version information print '-' x 78, "\n"; print "Perl version for runtest: $]\n"; -foreach (map { "./eximdir/$_" } qw(exigrep exinext eximstats)) { +foreach (map { "./eximdir/$_" } qw(exigrep exinext eximstats exiqgrep)) { # fold (or unfold?) multiline output into a one-liner print join(', ', map { chomp; $_ } `$_ --version`), "\n"; } diff --git a/test/scripts/0000-Basic/0611 b/test/scripts/0000-Basic/0611 index c35284147..40d08fcf1 100644 --- a/test/scripts/0000-Basic/0611 +++ b/test/scripts/0000-Basic/0611 @@ -6,6 +6,12 @@ need_ipv4 exim -odq a b c . **** +# Check that exiqgrep does not fall over, refuses no selectors, and can count. +exiqgrep -h +exiqgrep -r '[bc]' +exiqgrep +exiqgrep -c -r a +exiqgrep -c # # a slow server as a test target exim -DSERVER=server -bd -oX PORT_D diff --git a/test/stdout/0611 b/test/stdout/0611 new file mode 100644 index 000000000..11867c03a --- /dev/null +++ b/test/stdout/0611 @@ -0,0 +1,62 @@ +Exim message queue display utility. + + -h This help message. + -C Specify which exim.conf to use. + -E Specify exim binary to use. + +Selection criteria: + -f Match sender address sender (field is "< >" wrapped) + -r Match recipient address + -s Match against the size field from long output + -y Message younger than + -o Message older than + -z Frozen messages only (exclude non-frozen) + -x Non-frozen messages only (exclude frozen) + -G Match in given queue only + +[ NB: for regexps, provided string sits in // ] + +Display options: + -c Display match count + -l Long Format [Default] + -i Message IDs only + -b Brief Format + -R Reverse order + -a All recipients (including delivered) +exiqgrep exit code = 0 + 0m sss 10HmaX-0005vi-00 + a@test.ex + b@test.ex + c@test.ex + +exiqgrep exit code = 0 +Exim message queue display utility. + + -h This help message. + -C Specify which exim.conf to use. + -E Specify exim binary to use. + +Selection criteria: + -f Match sender address sender (field is "< >" wrapped) + -r Match recipient address + -s Match against the size field from long output + -y Message younger than + -o Message older than + -z Frozen messages only (exclude non-frozen) + -x Non-frozen messages only (exclude frozen) + -G Match in given queue only + +[ NB: for regexps, provided string sits in // ] + +Display options: + -c Display match count + -l Long Format [Default] + -i Message IDs only + -b Brief Format + -R Reverse order + -a All recipients (including delivered) +exiqgrep exit code = 1 +1 matches out of 1 messages +exiqgrep exit code = 0 +1 matches out of 1 messages +exiqgrep exit code = 0 -- cgit v1.2.3