#!perl -T
BEGIN {
- if ($ENV{PERL_CORE}) {
- chdir 't';
- @INC = '../lib';
- }
-
use Config;
use Test::More;
plan skip_all => "POSIX is unavailable" if $Config{'extensions'} !~ m!\bPOSIX\b!;
: (skip_all => "No tests to run on this OS")
;
-my $curdir = File::Spec->curdir;
-$curdir = VMS::Filespec::fileify($curdir) if $^O eq 'VMS';
+# Don't test on "." as it can be networked storage which returns EINVAL
+# Testing on "/" may not be portable to non-Unix as it may not be readable
+# "/tmp" should be readable and likely also local.
+my $testdir = File::Spec->tmpdir;
+$testdir = VMS::Filespec::fileify($testdir) if $^O eq 'VMS';
my $r;
+my $TTY = "/dev/tty";
+
sub _check_and_report {
my ($eval_status, $return_val, $description) = @_;
my $success = defined($return_val) || $! == 0;
is( $eval_status, '', $description );
- ok( $success, "\tchecking that the returned value is defined ("
- . (defined($return_val) ? "yes, it's $return_val)" : "it isn't)"
- . " or that errno is clear ("
- . (!($!+0) ? "it is)" : "it isn't, it's $!)"))
- );
+ SKIP: {
+ skip "terminal constants set errno on QNX", 1
+ if $^O eq 'nto' and $description =~ $TTY;
+ ok( $success, "\tchecking that the returned value is defined ("
+ . (defined($return_val) ? "yes, it's $return_val)" : "it isn't)"
+ . " or that errno is clear ("
+ . (!($!+0) ? "it is)" : "it isn't, it's $!)"))
+ );
+ }
SKIP: {
skip "constant not implemented on $^O or no limit in effect", 1
- if $success && !defined($return_val);
+ if !defined($return_val);
ok( looks_like_number($return_val), "\tchecking that the returned value looks like a number" );
}
}
# testing fpathconf() on a non-terminal file
SKIP: {
- my $fd = POSIX::open($curdir, O_RDONLY)
- or skip "could not open current directory ($!)", 3 * @path_consts;
+ my $fd = POSIX::open($testdir, O_RDONLY)
+ or skip "could not open test directory '$testdir' ($!)",
+ 3 * @path_consts;
for my $constant (@path_consts) {
$! = 0;
# testing pathconf() on a non-terminal file
for my $constant (@path_consts) {
$! = 0;
- $r = eval { pathconf( $curdir, eval "$constant()" ) };
- _check_and_report( $@, $r, qq[calling pathconf("$curdir", $constant)] );
+ $r = eval { pathconf( $testdir, eval "$constant()" ) };
+ _check_and_report( $@, $r, qq[calling pathconf("$testdir", $constant)] );
}
SKIP: {
- my $TTY = "/dev/tty";
-
my $n = 2 * 3 * @path_consts_terminal;
-c $TTY