Utilities: fix exiqgrep perl syntax, add testcases. Bug 2821
authorJeremy Harris <jgh146exb@wizmail.org>
Sun, 6 Mar 2022 14:25:13 +0000 (14:25 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Sun, 6 Mar 2022 16:45:03 +0000 (16:45 +0000)
Broken-by: df618101a5
doc/doc-docbook/spec.xfpt
src/src/exiqgrep.src
test/README
test/runtest
test/scripts/0000-Basic/0611
test/stdout/0611 [new file with mode: 0644]

index bfadeb10a97c26a1f64cd807ec52024a1d877b12..a7625630ef099207d06216d0b6d5a202be56c168 100644 (file)
@@ -39422,9 +39422,6 @@ or (in case &*-a*& switch is specified)
 .code
 exim -bp
 .endd
 .code
 exim -bp
 .endd
-The &*-C*& option is used to specify an alternate &_exim.conf_& which might
-contain alternate exim configuration the queue management might be using.
-
 to obtain a queue listing, and then greps the output to select messages
 that match given criteria. The following selection options are available:
 
 to obtain a queue listing, and then greps the output to select messages
 that match given criteria. The following selection options are available:
 
@@ -39481,7 +39478,22 @@ Display messages in reverse order.
 Include delivered recipients in queue listing.
 .endlist
 
 Include delivered recipients in queue listing.
 .endlist
 
+The following options give alternates for configuration:
+
+.vlist
+.vitem &*-C*&&~<&'config file'&>
+is used to specify an alternate &_exim.conf_& which might
+contain alternate exim configuration the queue management might be using.
+
+.vitem &*-E*&&~<&'path'&>
+can be used to specify a path for the exim binary,
+overriding the built-in one.
+.endlist
+
 There is one more option, &%-h%&, which outputs a list of options.
 There is one more option, &%-h%&, which outputs a list of options.
+.new
+At least one selection option, or either the &*-c*& or &*-h*& option, must be given.
+.wen
 
 
 
 
 
 
index 9fee423e421c69581d2eaaf4abc073b614273fe4..9dfa2c735d7ec7c293c764e4be6c7676ba71bba2 100644 (file)
@@ -55,12 +55,14 @@ if ($ARGV[0] eq '--version') {
         exit 0;
 }
 
         exit 0;
 }
 
-if (!getopts('hf:r:y:o:s:C:zxlibRcaG:',\%opt) { &help; exit;}
-if ($ARGV[0]) { &help; exit;}
-if ($opt{h}) { &help; exit;}
+if (!getopts('hf:r:y:o:s:C:zxlibRcaG:E:',\%opt)) { &help; exit; }
+if ($opt{h}) { &help; exit; }
+if ($ARGV[0] || !($opt{f} || $opt{r} || $opt{s} || $opt{y} || $opt{o} || $opt{z} || $opt{x} || $opt{c}))
+   { &help; exit(1); }
 if ($opt{a}) { $eargs = '-bp'; }
 if ($opt{C} && -e $opt{C} && -f $opt{C} && -R $opt{C}) { $eargs .= ' -C '.$opt{C}; }
 if ($opt{G}) { $eargs .= ' -qG'.$opt{G}; }
 if ($opt{a}) { $eargs = '-bp'; }
 if ($opt{C} && -e $opt{C} && -f $opt{C} && -R $opt{C}) { $eargs .= ' -C '.$opt{C}; }
 if ($opt{G}) { $eargs .= ' -qG'.$opt{G}; }
+if ($opt{E}) { $exim = $opt{E}; }
 
 # Read message queue output into hash
 &collect();
 
 # Read message queue output into hash
 &collect();
@@ -77,6 +79,7 @@ Exim message queue display utility.
 
        -h              This help message.
        -C              Specify which exim.conf to use.
 
        -h              This help message.
        -C              Specify which exim.conf to use.
+       -E              Specify exim binary to use.
 
 Selection criteria:
        -f <regexp>     Match sender address sender (field is "< >" wrapped)
 
 Selection criteria:
        -f <regexp>     Match sender address sender (field is "< >" wrapped)
index bca17eb18c4abe9fb7d0765068558ad742c92297..ab9fb64966bba9a50757dd9d56d15f680de96a06 100644 (file)
@@ -747,6 +747,12 @@ This command runs the exigrep utility with the given data (the search pattern)
 on the current mainlog file.
 
 
 on the current mainlog file.
 
 
+  exiqgrep <data>
+
+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
   gnutls
 
 This command is present at the start of all but one of the tests that use
index 2ac6198eb3f23a8b475b2e96ffba42fb7dd20e7b..f0fc25f75e5ad74e85e2e9d924f574a866e4eca7 100755 (executable)
@@ -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+(.*)/)
 # 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;
   }
 
   $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: $!");
 }
   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";
 # 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";
 }
   # fold (or unfold?) multiline output into a one-liner
   print join(', ', map { chomp; $_ } `$_ --version`), "\n";
 }
index c35284147031adc0a19c1bdd2f01b1e6d758cc0c..40d08fcf18458995c0e97bbd9aaed55cde4dc303 100644 (file)
@@ -6,6 +6,12 @@ need_ipv4
 exim -odq a b c
 .
 ****
 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
 #
 # 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 (file)
index 0000000..11867c0
--- /dev/null
@@ -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 <regexp>     Match sender address sender (field is "< >" wrapped)
+       -r <regexp>     Match recipient address
+       -s <regexp>     Match against the size field from long output
+       -y <seconds>    Message younger than
+       -o <seconds>    Message older than
+       -z              Frozen messages only (exclude non-frozen)
+       -x              Non-frozen messages only (exclude frozen)
+       -G <queuename>  Match in given queue only
+
+[ NB: for regexps, provided string sits in /<string>/ ]
+
+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 <CALLER@test.ex>
+         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 <regexp>     Match sender address sender (field is "< >" wrapped)
+       -r <regexp>     Match recipient address
+       -s <regexp>     Match against the size field from long output
+       -y <seconds>    Message younger than
+       -o <seconds>    Message older than
+       -z              Frozen messages only (exclude non-frozen)
+       -x              Non-frozen messages only (exclude frozen)
+       -G <queuename>  Match in given queue only
+
+[ NB: for regexps, provided string sits in /<string>/ ]
+
+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