diff --git a/tests/bozo/bos-man-t b/tests/bozo/bos-man-t index fedcf5863d..32001c169e 100755 --- a/tests/bozo/bos-man-t +++ b/tests/bozo/bos-man-t @@ -2,24 +2,7 @@ use strict; use warnings; -use File::Basename; -use lib "./tests-lib/perl5"; +use lib $ENV{SOURCE} . "/tests-lib/perl5"; use mancheck_utils; -# Set this to the bare command to test -my $command = 'bos'; -my $builddir = $ENV{BUILD}; -if (!$builddir) { - $builddir = dirname($0) . "/.."; -} -$builddir .= "/.."; -# Set this to the directory holding $command -my $srcdir = "$builddir/src/bozo"; - -#--------------------------------------------------------------------- - -my @sub_commands = lookup_sub_commands($srcdir, $command); -plan tests => scalar @sub_commands; - -test_command_man_pages($builddir, $command, @sub_commands); - +run_manpage_tests("src/bozo", "bos"); diff --git a/tests/bucoord/backup-man-t b/tests/bucoord/backup-man-t index d8df2c823b..d062a80301 100755 --- a/tests/bucoord/backup-man-t +++ b/tests/bucoord/backup-man-t @@ -2,24 +2,7 @@ use strict; use warnings; -use File::Basename; -use lib "./tests-lib/perl5"; +use lib $ENV{SOURCE} . "/tests-lib/perl5"; use mancheck_utils; -# Set this to the bare command to test -my $command = 'backup'; -my $builddir = $ENV{BUILD}; -if (!$builddir) { - $builddir = dirname($0) . "/.."; -} -$builddir .= "/.."; -# Set this to the directory holding $command -my $srcdir = "$builddir/src/bucoord"; - -#--------------------------------------------------------------------- - -my @sub_commands = lookup_sub_commands($srcdir, $command); -plan tests => scalar @sub_commands; - -test_command_man_pages($builddir, $command, @sub_commands); - +run_manpage_tests("src/bucoord", "backup"); diff --git a/tests/kauth/kas-man-t b/tests/kauth/kas-man-t index 1629588964..fb6b8cd75b 100755 --- a/tests/kauth/kas-man-t +++ b/tests/kauth/kas-man-t @@ -2,24 +2,7 @@ use strict; use warnings; -use File::Basename; -use lib "./tests-lib/perl5"; +use lib $ENV{SOURCE} . "/tests-lib/perl5"; use mancheck_utils; -# Set this to the bare command to test -my $command = 'kas'; -my $builddir = $ENV{BUILD}; -if (!$builddir) { - $builddir = dirname($0) . "/.."; -} -$builddir .= "/.."; -# Set this to the directory holding $command -my $srcdir = "$builddir/src/kauth"; - -#--------------------------------------------------------------------- - -my @sub_commands = lookup_sub_commands($srcdir, $command); -plan tests => scalar @sub_commands; - -test_command_man_pages($builddir, $command, @sub_commands); - +run_manpage_tests("src/kauth", "kas"); diff --git a/tests/ptserver/pts-man-t b/tests/ptserver/pts-man-t index 60645ea2bf..0c32dc91a8 100755 --- a/tests/ptserver/pts-man-t +++ b/tests/ptserver/pts-man-t @@ -2,24 +2,7 @@ use strict; use warnings; -use File::Basename; -use lib "./tests-lib/perl5"; +use lib $ENV{SOURCE} . "/tests-lib/perl5"; use mancheck_utils; -# Set this to the bare command to test -my $command = 'pts'; -my $builddir = $ENV{BUILD}; -if (!$builddir) { - $builddir = dirname($0) . "/.."; -} -$builddir .= "/.."; -# Set this to the directory holding $command -my $srcdir = "$builddir/src/ptserver"; - -#--------------------------------------------------------------------- - -my @sub_commands = lookup_sub_commands($srcdir, $command); -plan tests => scalar @sub_commands; - -test_command_man_pages($builddir, $command, @sub_commands); - +run_manpage_tests("src/ptserver", "pts"); diff --git a/tests/tests-lib/perl5/mancheck_utils.pm b/tests/tests-lib/perl5/mancheck_utils.pm index edfa8fc3da..90a9e0a89c 100644 --- a/tests/tests-lib/perl5/mancheck_utils.pm +++ b/tests/tests-lib/perl5/mancheck_utils.pm @@ -52,7 +52,7 @@ sub lookup_sub_commands { # # Arguments: # -# builddir : A path to the OpenAFS build directory, +# srcdir : A path to the OpenAFS source directory, # such as /tmp/1.4.14 # # command : the name of the command (e.g. vos) @@ -60,7 +60,7 @@ sub lookup_sub_commands { # subcommlist : a list of sub-commands for command # sub test_command_man_pages { - my ($builddir, $command, @subcommlist) = @_; + my ($srcdir, $command, @subcommlist) = @_; # The following is because File::Find makes no sense to me # for this purpose, and actually seems totally misnamed @@ -69,9 +69,9 @@ sub test_command_man_pages { my $frex = ""; # Since we don't know what man section it might be in, # search all existing man page files for a filename match - my @mandirglob = glob("$builddir/doc/man-pages/man[1-8]/*"); + my @mandirglob = glob("$srcdir/doc/man-pages/man[1-8]/*"); # For every subcommand, see if command_subcommand.[1-8] exists - # in our man page build dir. + # in our man page source dir. foreach (@subcommlist) { my $subcommand = $_; $found = 0; @@ -89,4 +89,28 @@ sub test_command_man_pages { ok($found eq 1, "existence of man page for $command" . "_$subcommand"); } } + +# +# Setup the test plan and run all of the tests for the given command suite. +# +# Call like so: +# run_manpage_tests("src/ptserver", "pts"); +# +sub run_manpage_tests($$) { + my ($subdir, $command) = @_; + + # When run from 'runtests', our cwd will be TOP_OBJDIR/tests. $SOURCE is + # set to TOP_SRCDIR/tests, and $BUILD is set to TOP_OBJDIR/tests. We want + # the top-level src and obj dirs, in order to find the relevant binaries + # and manpages. + my $srcdir = $ENV{SOURCE} . "/.."; + my $objdir = $ENV{BUILD} . "/.."; + + my @sub_commands = lookup_sub_commands("$objdir/$subdir", $command); + die("No subcommands found in $objdir/$subdir/$command?") unless(@sub_commands); + + plan tests => scalar @sub_commands; + + test_command_man_pages($srcdir, $command, @sub_commands); +} 1; diff --git a/tests/venus/fs-man-t b/tests/venus/fs-man-t index 3267b5ddd8..2f3e644a50 100755 --- a/tests/venus/fs-man-t +++ b/tests/venus/fs-man-t @@ -2,24 +2,7 @@ use strict; use warnings; -use File::Basename; -use lib "./tests-lib/perl5"; +use lib $ENV{SOURCE} . "/tests-lib/perl5"; use mancheck_utils; -# Set this to the bare command to test -my $command = 'fs'; -my $builddir = $ENV{BUILD}; -if (!$builddir) { - $builddir = dirname($0) . "/.."; -} -$builddir .= "/.."; -# Set this to the directory holding $command -my $srcdir = "$builddir/src/venus"; - -#--------------------------------------------------------------------- - -my @sub_commands = lookup_sub_commands($srcdir, $command); -plan tests => scalar @sub_commands; - -test_command_man_pages($builddir, $command, @sub_commands); - +run_manpage_tests("src/venus", "fs"); diff --git a/tests/volser/vos-man-t b/tests/volser/vos-man-t index 2e2cc3560c..90770b2570 100755 --- a/tests/volser/vos-man-t +++ b/tests/volser/vos-man-t @@ -2,24 +2,8 @@ use strict; use warnings; -use File::Basename; -use lib "./tests-lib/perl5"; +use lib $ENV{SOURCE} . "/tests-lib/perl5"; use mancheck_utils; -# Set this to the bare command to test -my $command = 'vos'; -my $builddir = $ENV{BUILD}; -if (!$builddir) { - $builddir = dirname($0) . "/.."; -} -$builddir .= "/.."; -# Set this to the directory holding $command -my $srcdir = "$builddir/src/volser"; - -#--------------------------------------------------------------------- - -my @sub_commands = lookup_sub_commands($srcdir, $command); -plan tests => scalar @sub_commands; - -test_command_man_pages($builddir, $command, @sub_commands); +run_manpage_tests("src/volser", "vos");