Change 28505 by [EMAIL PROTECTED] on 2006/07/08 09:04:56
POSIX test improvements on True64
Subject: [PATCH] the new POSIX tests
From: Jarkko Hietaniemi <[EMAIL PROTECTED]>
Date: Sat, 08 Jul 2006 11:43:05 +0300
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/ext/POSIX/POSIX.pod#47 edit
... //depot/perl/ext/POSIX/t/sysconf.t#2 edit
... //depot/perl/ext/POSIX/t/termios.t#2 edit
Differences ...
==== //depot/perl/ext/POSIX/POSIX.pod#47 (text) ====
Index: perl/ext/POSIX/POSIX.pod
--- perl/ext/POSIX/POSIX.pod#46~25253~ 2005-08-01 01:13:10.000000000 -0700
+++ perl/ext/POSIX/POSIX.pod 2006-07-08 02:04:56.000000000 -0700
@@ -848,7 +848,8 @@
if (mkfifo($path, $mode)) { ....
Returns C<undef> on failure. The C<$mode> is similar to the
-mode of C<mkdir()>, see L<perlfunc/mkdir>.
+mode of C<mkdir()>, see L<perlfunc/mkdir>, though for C<mkfifo>
+you B<must> specify the C<$mode>.
=item mktime
@@ -1840,6 +1841,7 @@
Obtain the attributes for stdin.
+ $termios->getattr( 0 ) # Recommended for clarity.
$termios->getattr()
Obtain the attributes for stdout.
==== //depot/perl/ext/POSIX/t/sysconf.t#2 (text) ====
Index: perl/ext/POSIX/t/sysconf.t
--- perl/ext/POSIX/t/sysconf.t#1~28503~ 2006-07-07 11:38:01.000000000 -0700
+++ perl/ext/POSIX/t/sysconf.t 2006-07-08 02:04:56.000000000 -0700
@@ -17,8 +17,16 @@
use Scalar::Util qw(looks_like_number);
my @path_consts = qw(
- _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON _PC_MAX_INPUT
- _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX _PC_PIPE_BUF _PC_VDISABLE
+ _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_NAME_MAX
+ _PC_NO_TRUNC _PC_PATH_MAX
+);
+
+my @path_consts_terminal = qw(
+ _PC_MAX_CANON _PC_MAX_INPUT _PC_VDISABLE
+);
+
+my @path_consts_fifo = qw(
+ _PC_PIPE_BUF
);
my @sys_consts = qw(
@@ -27,31 +35,84 @@
_SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
);
-plan tests => 2 * 3 * @path_consts + 3 * @sys_consts;
+plan tests => 2 * 3 * @path_consts +
+ 3 * @path_consts_terminal +
+ 2 * 3 * @path_consts_fifo +
+ 3 * @sys_consts;
+
+my $curdir = File::Spec->curdir;
my $r;
-# testing fpathconf()
+# testing fpathconf() on a non-terminal file
SKIP: {
- my $fd = POSIX::open(File::Spec->curdir, O_RDONLY)
- or skip "can't open current directory", 3 * @path_consts;
+ my $fd = POSIX::open($curdir, O_RDONLY)
+ or skip "could not open current directory ($!)", 3 * @path_consts;
for my $constant (@path_consts) {
- $r = eval { pathconf( File::Spec->curdir, eval "$constant()" ) };
- is( $@, '', "calling pathconf($constant)" );
+ $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" );
}
+
+ POSIX::close($fd);
}
-# testing pathconf()
+# testing pathconf() on a non-terminal file
for my $constant (@path_consts) {
- $r = eval { pathconf( File::Spec->rootdir, eval "$constant()" ) };
- is( $@, '', "calling pathconf($constant)" );
+ $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" );
}
+SKIP: {
+ -c "/dev/tty"
+ or skip("/dev/tty not a character file", 3 * @path_consts_terminal);
+
+ # testing pathconf() on a terminal file
+ for my $constant (@path_consts_terminal) {
+ $r = eval { pathconf( "/dev/tty", eval "$constant()" ) };
+ is( $@, '', qq[calling pathconf("/dev/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" );
+ }
+}
+
+my $fifo = "fifo$$";
+
+SKIP: {
+ mkfifo($fifo, 0666)
+ or skip("could not create fifo $fifo ($!)", 2 * 3 * @path_consts_fifo);
+
+ SKIP: {
+ my $fd = POSIX::open($fifo, O_RDWR)
+ or skip("could not open $fifo ($!)", 3 * @path_consts_fifo);
+
+ for my $constant (@path_consts_fifo) {
+ $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" );
+ }
+
+ 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" );
+ }
+ }
+}
+
+unlink($fifo);
+
# testing sysconf()
for my $constant (@sys_consts) {
$r = eval { sysconf( eval "$constant()" ) };
==== //depot/perl/ext/POSIX/t/termios.t#2 (text) ====
Index: perl/ext/POSIX/t/termios.t
--- perl/ext/POSIX/t/termios.t#1~28503~ 2006-07-07 11:38:01.000000000 -0700
+++ perl/ext/POSIX/t/termios.t 2006-07-08 02:04:56.000000000 -0700
@@ -27,9 +27,25 @@
isa_ok( $termios, "POSIX::Termios", "\tchecking the type of the object" );
# testing getattr()
-for my $i (0..2) {
- $r = eval { $termios->getattr($i) };
- is( $@, '', "calling getattr($i)" );
+
+SKIP: {
+ -t STDIN or skip("STDIN not a tty", 2);
+ $r = eval { $termios->getattr(0) };
+ is( $@, '', "calling getattr(0)" );
+ ok( defined $r, "\tchecking if the returned value is defined: $r" );
+}
+
+SKIP: {
+ -t STDOUT or skip("STDOUT not a tty", 2);
+ $r = eval { $termios->getattr(1) };
+ is( $@, '', "calling getattr(1)" );
+ ok( defined $r, "\tchecking if the returned value is defined: $r" );
+}
+
+SKIP: {
+ -t STDERR or skip("STDERR not a tty", 2);
+ $r = eval { $termios->getattr(2) };
+ is( $@, '', "calling getattr(2)" );
ok( defined $r, "\tchecking if the returned value is defined: $r" );
}
End of Patch.