summaryrefslogtreecommitdiff
path: root/ext/POSIX
diff options
context:
space:
mode:
authorCraig A. Berry <craigberry@mac.com>2006-09-16 15:14:36 +0000
committerCraig A. Berry <craigberry@mac.com>2006-09-16 15:14:36 +0000
commit44abc943eb062867457a44655d95023ddfb75877 (patch)
tree7a3ba65be9ab1884527cff94b615aece58d08af5 /ext/POSIX
parent96d93ea327ba829c70f2d26609ef05d668364247 (diff)
downloadperl-44abc943eb062867457a44655d95023ddfb75877.tar.gz
return value of -1 without errno set is ok in
ext/POSIX/t/sysconf.t (it just means the feature is not implemented, not defined, or has no limit) p4raw-id: //depot/perl@28851
Diffstat (limited to 'ext/POSIX')
-rw-r--r--ext/POSIX/t/sysconf.t71
1 files changed, 33 insertions, 38 deletions
diff --git a/ext/POSIX/t/sysconf.t b/ext/POSIX/t/sysconf.t
index 68630fdef8..f19db68461 100644
--- a/ext/POSIX/t/sysconf.t
+++ b/ext/POSIX/t/sysconf.t
@@ -49,23 +49,35 @@ plan $tests
;
my $curdir = File::Spec->curdir;
+$curdir = VMS::Filespec::fileify($curdir) if $^O eq 'VMS';
my $r;
+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 "constant not implemented on $^O or no limit in effect", 1
+ if $success && !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;
for my $constant (@path_consts) {
- SKIP: {
- skip "_PC_CHOWN_RESTRICTED is unreliable on HP-UX", 3
- if $^O eq "hpux" && $constant eq "_PC_CHOWN_RESTRICTED";
+ $! = 0;
$r = eval { fpathconf( $fd, eval "$constant()" ) };
- is( $@, '', "calling fpathconf($fd, $constant) " );
- ok( defined $r, "\tchecking that the returned value is defined: $r" );
- ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
- }
+ _check_and_report( $@, $r, "calling fpathconf($fd, $constant) " );
}
POSIX::close($fd);
@@ -73,14 +85,9 @@ SKIP: {
# testing pathconf() on a non-terminal file
for my $constant (@path_consts) {
- SKIP: {
- skip "_PC_CHOWN_RESTRICTED is unreliable on HP-UX", 3
- if $^O eq "hpux" && $constant eq "_PC_CHOWN_RESTRICTED";
+ $! = 0;
$r = eval { pathconf( $curdir, eval "$constant()" ) };
- is( $@, '', qq[calling pathconf("$curdir", $constant)] );
- ok( defined $r, "\tchecking that the returned value is defined: $r" );
- ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
- }
+ _check_and_report( $@, $r, qq[calling pathconf("$curdir", $constant)] );
}
SKIP: {
@@ -99,19 +106,17 @@ SKIP: {
# testing fpathconf() on a terminal file
for my $constant (@path_consts_terminal) {
+ $! = 0;
$r = eval { fpathconf( $fd, eval "$constant()" ) };
- is( $@, '', qq[calling fpathconf($fd, $constant) ($TTY)] );
- ok( defined $r, "\tchecking that the returned value is defined: $r" );
- ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
+ _check_and_report( $@, $r, qq[calling fpathconf($fd, $constant) ($TTY)] );
}
close($fd);
# testing pathconf() on a terminal file
for my $constant (@path_consts_terminal) {
+ $! = 0;
$r = eval { pathconf( $TTY, eval "$constant()" ) };
- is( $@, '', qq[calling pathconf($TTY, $constant)] );
- ok( defined $r, "\tchecking that the returned value is defined: $r" );
- ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
+ _check_and_report( $@, $r, qq[calling pathconf($TTY, $constant)] );
}
}
@@ -126,23 +131,19 @@ SKIP: {
or skip("could not open $fifo ($!)", 3 * @path_consts_fifo);
for my $constant (@path_consts_fifo) {
+ $! = 0;
$r = eval { fpathconf( $fd, eval "$constant()" ) };
- is( $@, '', "calling fpathconf($fd, $constant) ($fifo)" );
- ok( defined $r, "\tchecking that the returned value is defined: $r" );
- ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
+ _check_and_report( $@, $r, "calling fpathconf($fd, $constant) ($fifo)" );
}
POSIX::close($fd);
}
- SKIP: {
- # testing pathconf() on a fifo file
- for my $constant (@path_consts_fifo) {
- $r = eval { pathconf( $fifo, eval "$constant()" ) };
- is( $@, '', qq[calling pathconf($fifo, $constant)] );
- ok( defined $r, "\tchecking that the returned value is defined: $r" );
- ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
- }
+ # testing pathconf() on a fifo file
+ for my $constant (@path_consts_fifo) {
+ $! = 0;
+ $r = eval { pathconf( $fifo, eval "$constant()" ) };
+ _check_and_report( $@, $r, qq[calling pathconf($fifo, $constant)] );
}
}
@@ -152,14 +153,8 @@ END {
# testing sysconf()
for my $constant (@sys_consts) {
- SKIP: {
$! = 0;
$r = eval { sysconf( eval "$constant()" ) };
- my $s = defined($r) || $! == 0;
- is( $@, '', "calling sysconf($constant)" );
- ok( $s, "\tchecking that the returned value is defined or that errno is clear: $r $!" );
- skip "$constant not implemented on $^O", 1 if $s && !defined($r);
- ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
- }
+ _check_and_report( $@, $r, "calling sysconf($constant)" );
}