forked from monitoring-plugins/monitoring-plugins
-
Notifications
You must be signed in to change notification settings - Fork 2
/
opttest.pl
executable file
·50 lines (38 loc) · 1012 Bytes
/
opttest.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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;
}