summaryrefslogtreecommitdiffstats
path: root/opttest.pl
diff options
context:
space:
mode:
authorEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 (GMT)
committerEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 (GMT)
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 0000000..85e3b49
--- /dev/null
+++ b/opttest.pl
@@ -0,0 +1,50 @@
1#!/usr/bin/perl -w
2use strict;
3use Test;
4
5use vars qw($dir $file $prog $idx $state $output %progs @dirs);
6
7my $tests = 0;
8
9@dirs = qw(plugins plugins-scripts);
10
11foreach $dir (@dirs) {
12 opendir(DIR, $dir) || die "can't opendir $dir: $!";
13 while ($file = readdir(DIR)) {
14 if (-x "$dir/$file" && -f "$dir/$file") {
15 $tests++;
16 $progs{"$dir/$file"} = $file;
17 }
18 }
19 closedir DIR;
20}
21
22plan tests => $tests;
23
24for $prog (keys %progs) {
25 $state = 0;
26 $file = `basename $prog`;
27
28 $idx = 1;
29 $output = `$prog -h 2>&1`;
30 if($?) {$state++;print "$prog failed test $idx\n";}
31 unless ($output =~ m/$progs{$prog}/ms) {
32 $idx++; $state++;print "$output\n$prog failed test $idx\n";
33 }
34
35 $idx++;
36 `$prog --help 2>&1 > /dev/null`;
37 if($?) {$state++;print "$prog failed test $idx\n";}
38
39 $idx++;
40 `$prog -V 2>&1 > /dev/null`;
41 if($?) {$state++;print "$prog failed test $idx\n";}
42
43 $idx++;
44 `$prog --version 2>&1 > /dev/null`;
45 if($?) {$state++;print "$prog failed test $idx\n";}
46
47 print "$prog ($idx tests) ";
48 ok $state,0;
49}
50