diff options
author | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 +0000 |
---|---|---|
committer | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 +0000 |
commit | 44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch) | |
tree | a1a4d9f7b92412a17ab08f34f04eec45433048b7 /opttest.pl | |
parent | 54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff) | |
download | monitoring-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-x | opttest.pl | 50 |
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 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | use strict; | ||
3 | use Test; | ||
4 | |||
5 | use vars qw($dir $file $prog $idx $state $output %progs @dirs); | ||
6 | |||
7 | my $tests = 0; | ||
8 | |||
9 | @dirs = qw(plugins plugins-scripts); | ||
10 | |||
11 | foreach $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 | |||
22 | plan tests => $tests; | ||
23 | |||
24 | for $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 | |||