diff options
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 | |||
