openafs/tests/auth/writeoldkey-t
Michael Meffie 624219a1b2 tests: Accommodate c-tap-harness 4.7
The SOURCE and BUILD environment variables have been changed to
C_TAP_SOURCE and C_TAP_BUILD in the new version of c-tap-harness.  The
runtests command syntax has changed as well.

Convert all of the old SOURCE and BUILD environment variables to the new
C_TAP_SOURCE and C_TAP_BUILD names.

Add the required -l command line option to specify the test list.

Add the new runtests -v option to run the tests in verbose mode to make
it easier to see which tests failed.

Change-Id: I209a6dc13d6cd1507519234fce1564fc4641e70b
Reviewed-on: https://gerrit.openafs.org/14295
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2020-08-20 22:36:56 -04:00

48 lines
1.0 KiB
Perl
Executable File

#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use File::Temp qw/tempdir/;
use FindBin qw($Bin);
use Cwd qw/abs_path/;
use File::Compare;
use Sys::Hostname;
use Socket;
# Run tests/auth/writekeyfile, and check that the KeyFile that it generates
# matches what we expect.
if (!defined(gethostbyname(hostname()))) {
# writekeyfile needs a hostname to generate a config dir
plan skip_all => 'Cannot resolve hostname';
}
plan tests => 1;
my $cmd;
if (defined($ENV{C_TAP_BUILD})) {
$cmd = $ENV{C_TAP_BUILD} . "/auth/writekeyfile";
} else {
$cmd = $Bin . "/writekeyfile";
}
$cmd = abs_path($cmd);
my $keyfile;
if (defined($ENV{C_TAP_SOURCE})) {
$keyfile = $ENV{C_TAP_SOURCE} . "/auth/KeyFile.short";
} else {
$keyfile = $Bin . "/KeyFile.short";
}
$keyfile = abs_path($keyfile);
my $dir = tempdir('afs_XXXXXX', CLEANUP => 1);
chdir($dir)
or die("chdir $dir failed: $?");
system($cmd) == 0
or die("$cmd failed: $?");
ok(compare("KeyFile", $keyfile) == 0,
"writekeyfile generates expected KeyFile");