popen.c: clang-format
[monitoring-plugins.git] / opttest.pl
blob85e3b49425484389e99b9ed81a833e9b934173a0
1 #!/usr/bin/perl -w
2 use strict;
3 use Test;
5 use vars qw($dir $file $prog $idx $state $output %progs @dirs);
7 my $tests = 0;
9 @dirs = qw(plugins plugins-scripts);
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;
19 closedir DIR;
22 plan tests => $tests;
24 for $prog (keys %progs) {
25 $state = 0;
26 $file = `basename $prog`;
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";
35 $idx++;
36 `$prog --help 2>&1 > /dev/null`;
37 if($?) {$state++;print "$prog failed test $idx\n";}
39 $idx++;
40 `$prog -V 2>&1 > /dev/null`;
41 if($?) {$state++;print "$prog failed test $idx\n";}
43 $idx++;
44 `$prog --version 2>&1 > /dev/null`;
45 if($?) {$state++;print "$prog failed test $idx\n";}
47 print "$prog ($idx tests) ";
48 ok $state,0;