aboutsummaryrefslogtreecommitdiff
path: root/opttest.pl
diff options
context:
space:
mode:
authorGravatar Ethan Galstad <egalstad@users.sourceforge.net> 2002-02-28 06:42:51 +0000
committerGravatar Ethan Galstad <egalstad@users.sourceforge.net> 2002-02-28 06:42:51 +0000
commit44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch)
treea1a4d9f7b92412a17ab08f34f04eec45433048b7 /opttest.pl
parent54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff)
downloadmonitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'opttest.pl')
-rwxr-xr-xopttest.pl50
1 files changed, 50 insertions, 0 deletions
diff --git a/opttest.pl b/opttest.pl
new file mode 100755
index 00000000..85e3b494
--- /dev/null
+++ b/opttest.pl
@@ -0,0 +1,50 @@
+#!/usr/bin/perl -w
+use strict;
+use Test;
+
+use vars qw($dir $file $prog $idx $state $output %progs @dirs);
+
+my $tests = 0;
+
+@dirs = qw(plugins plugins-scripts);
+
+foreach $dir (@dirs) {
+ opendir(DIR, $dir) || die "can't opendir $dir: $!";
+ while ($file = readdir(DIR)) {
+ if (-x "$dir/$file" && -f "$dir/$file") {
+ $tests++;
+ $progs{"$dir/$file"} = $file;
+ }
+ }
+ closedir DIR;
+}
+
+plan tests => $tests;
+
+for $prog (keys %progs) {
+ $state = 0;
+ $file = `basename $prog`;
+
+ $idx = 1;
+ $output = `$prog -h 2>&1`;
+ if($?) {$state++;print "$prog failed test $idx\n";}
+ unless ($output =~ m/$progs{$prog}/ms) {
+ $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";}
+
+ $idx++;
+ `$prog -V 2>&1 > /dev/null`;
+ if($?) {$state++;print "$prog failed test $idx\n";}
+
+ $idx++;
+ `$prog --version 2>&1 > /dev/null`;
+ if($?) {$state++;print "$prog failed test $idx\n";}
+
+ print "$prog ($idx tests) ";
+ ok $state,0;
+}
+