diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/opttest.pl | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/opttest.pl b/tools/opttest.pl new file mode 100755 index 00000000..96c4fb0a --- /dev/null +++ b/tools/opttest.pl | |||
@@ -0,0 +1,51 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | use strict; | ||
3 | use warnings; | ||
4 | use Test; | ||
5 | |||
6 | use vars qw($dir $file $prog $idx $state $output %progs @dirs); | ||
7 | |||
8 | my $tests = 0; | ||
9 | |||
10 | @dirs = qw(plugins plugins-scripts); | ||
11 | |||
12 | foreach my $dir (@dirs) { | ||
13 | opendir(DIR, $dir) || die "can't opendir $dir: $!"; | ||
14 | while ($file = readdir(DIR)) { | ||
15 | if (-x "$dir/$file" && -f "$dir/$file") { | ||
16 | $tests++; | ||
17 | $progs{"$dir/$file"} = $file; | ||
18 | } | ||
19 | } | ||
20 | closedir DIR; | ||
21 | } | ||
22 | |||
23 | plan tests => $tests; | ||
24 | |||
25 | for my $prog (keys %progs) { | ||
26 | $state = 0; | ||
27 | $file = `basename $prog`; | ||
28 | |||
29 | $idx = 1; | ||
30 | $output = `$prog -h 2>&1`; | ||
31 | if($?) {$state++;print "$prog failed test $idx\n";} | ||
32 | unless ($output =~ m/$progs{$prog}/ms) { | ||
33 | $idx++; $state++;print "$output\n$prog failed test $idx\n"; | ||
34 | } | ||
35 | |||
36 | $idx++; | ||
37 | `$prog --help 2>&1 > /dev/null`; | ||
38 | if($?) {$state++;print "$prog failed test $idx\n";} | ||
39 | |||
40 | $idx++; | ||
41 | `$prog -V 2>&1 > /dev/null`; | ||
42 | if($?) {$state++;print "$prog failed test $idx\n";} | ||
43 | |||
44 | $idx++; | ||
45 | `$prog --version 2>&1 > /dev/null`; | ||
46 | if($?) {$state++;print "$prog failed test $idx\n";} | ||
47 | |||
48 | print "$prog ($idx tests) "; | ||
49 | ok $state,0; | ||
50 | } | ||
51 | |||