summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/opttest.pl51
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
2use strict;
3use warnings;
4use Test;
5
6use vars qw($dir $file $prog $idx $state $output %progs @dirs);
7
8my $tests = 0;
9
10@dirs = qw(plugins plugins-scripts);
11
12foreach 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
23plan tests => $tests;
24
25for 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