Module: monitoring-plugins
 Branch: master
 Commit: b982e12ecfee9db869d443d2a8524182b7d09b13
 Author: Lorenz Kästle <12514511+rincewinds...@users.noreply.github.com>
   Date: Wed Feb 19 19:43:40 2025 +0100
    URL: 
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b982e12e

Fix opttest script

---

 tools/opttest.pl | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/tools/opttest.pl b/tools/opttest.pl
index 96c4fb0a..56a5c88f 100755
--- a/tools/opttest.pl
+++ b/tools/opttest.pl
@@ -28,22 +28,41 @@ for my $prog (keys %progs) {
 
        $idx = 1;
        $output = `$prog -h 2>&1`;
-       if($?) {$state++;print "$prog failed test $idx\n";}
+       if(($? >> 8) != 3) {
+               $state++;
+               print "$prog failed test $idx (help exit code (short form))\n";
+               exit(1);
+       }
+
        unless ($output =~ m/$progs{$prog}/ms) {
-               $idx++; $state++;print "$output\n$prog failed test $idx\n";
+               $idx++;
+               $state++;
+               print "$output\n$prog failed test $idx\n";
        }
 
        $idx++;
        `$prog --help 2>&1 > /dev/null`;
-       if($?) {$state++;print "$prog failed test $idx\n";}
+       if(($? >> 8) != 3) {
+               $state++;
+               print "$prog failed test $idx (help exit code (long form))\n";
+               exit(1);
+       }
 
        $idx++;
-               `$prog -V 2>&1 > /dev/null`;
-       if($?) {$state++;print "$prog failed test $idx\n";}
+       `$prog -V 2>&1 > /dev/null`;
+       if(($? >> 8) != 3) {
+               $state++;
+               print "$prog failed test $idx (version exit code (short 
form))\n";
+               exit(1);
+       }
 
        $idx++;
        `$prog --version 2>&1 > /dev/null`;
-       if($?) {$state++;print "$prog failed test $idx\n";}
+       if(($? >> 8) != 3) {
+               $state++;
+               print "$prog failed test $idx (version exit code (long 
form))\n";
+               exit(1);
+       }
 
        print "$prog ($idx tests) ";
        ok $state,0;

Reply via email to