2 # This is probably horrific code to any Perl coder. I'm sorry,
3 # I'm not one. It runs.
5 # Proposed Coding Standard:
7 # * Subroutines starting with test_ should be TAP tests
8 # utilizing ok(), is(), etc... and return the number
9 # of tests run if they get that far (could exit early
15 sub check_command_binary {
18 BAIL_OUT("Cannot find $c");
23 # Run the command help to determine the list of sub-commands.
25 sub lookup_sub_commands {
26 my ($srcdir, $command) = @_;
28 my $fullpathcommand = "$srcdir/$command";
29 check_command_binary($fullpathcommand);
31 # build up our list of available commands from the help output
32 open(HELPOUT, "$fullpathcommand help 2>&1 |") or BAIL_OUT("can't fork: $!");
36 # Skip the header thingy
37 next if /Commands are/;
39 push(@subcommlist, $comm[0]);
42 @subcommlist = sort(@subcommlist);
46 # TAP test: test_command_man_pages
48 # Test if a man page exists for each command sub-command.
49 # Runs one test per sub-command.
53 # builddir : A path to the OpenAFS build directory,
56 # command : the name of the command (e.g. vos)
58 # subcommlist : a list of sub-commands for command
60 sub test_command_man_pages {
61 my ($builddir, $command, @subcommlist) = @_;
63 # The following is because File::Find makes no sense to me
64 # for this purpose, and actually seems totally misnamed
68 # Since we don't know what man section it might be in,
69 # search all existing man page files for a filename match
70 my @mandirglob = glob("$builddir/doc/man-pages/man[1-8]/*");
71 # For every subcommand, see if command_subcommand.[1-8] exists
72 # in our man page build dir.
73 foreach (@subcommlist) {
76 my $frex = $command . '_' . $subcommand . '.[1-8]';
77 # diag("Looking for $frex");
78 foreach my $x (@mandirglob) {
87 ok($found eq 1, "existence of man page for $command" . "_$subcommand");