mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 23:10:58 +00:00
e07768aaf7
Create a perl module for some generic common code for our tests written in perl: afstest.pm. With this commit, the module just contains a couple of functions to calculate paths in our src and obj trees (src_path(), obj_path()), analogous to afstest_src_path and afstest_obj_path in our C helper library, libafstest_common.la. Convert all existing perl test code that uses C_TAP_SOURCE/C_TAP_BUILD to use these new functions. Change-Id: I5e4d45e3d2d59449bbfc426476cb29b710c73bc1 Reviewed-on: https://gerrit.openafs.org/14800 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: Benjamin Kaduk <kaduk@mit.edu>
40 lines
912 B
Perl
Executable File
40 lines
912 B
Perl
Executable File
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
|
|
|
|
use afstest qw(src_path obj_path);
|
|
use Test::More;
|
|
use File::Temp qw/tempdir/;
|
|
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 = obj_path("tests/auth/writekeyfile");
|
|
$cmd = abs_path($cmd);
|
|
|
|
my $keyfile = src_path("tests/auth/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");
|