tests: Fix manpage tests for objdir builds

The manpage tests have a couple of problems when running for objdir
builds:

- We try to specify './tests-lib/perl5' as a directory to find our
  helper library. However, the cwd when we're running the tests is in
  an objdir build, where the helper library is in the srcdir. Fix this
  by using the SOURCE env var specified by the tests wrapper.

- All of these tests specify the directory in which to find the man
  pages in a subdir of BUILD, but our manpages are located in the src
  dir (since they are built by regen.sh, not by configure/make). Fix
  this by specifying a SOURCE-based directory instead.

To avoid needing to make the same change for each of these tests, also
refactor the manpage tests so each test only needs to specify the
subdirectory and command name, and get rid of some of the common
boilerplate.

Change-Id: I96be199b1dec8db0545ae3cf19d2595c4afe4cdd
Reviewed-on: https://gerrit.openafs.org/13940
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Andrew Deason 2019-11-11 20:34:27 -06:00 committed by Benjamin Kaduk
parent 63fd13bf9e
commit 0b8b6683fb
7 changed files with 40 additions and 117 deletions

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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;

View File

@ -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");

View File

@ -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");