From: Jarkko Hietaniemi Date: Sat, 8 Jul 2006 11:43:05 +0000 (+0300) Subject: POSIX test improvements on True64 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=220f811aaa08aaaa6e406d8ab7a058ca628c18d7;p=p5sagit%2Fp5-mst-13.2.git POSIX test improvements on True64 Subject: [PATCH] the new POSIX tests Message-ID: <44AF7019.3070509@iki.fi> p4raw-id: //depot/perl@28505 --- diff --git a/ext/POSIX/POSIX.pod b/ext/POSIX/POSIX.pod index 4374c9e..124d0bd 100644 --- a/ext/POSIX/POSIX.pod +++ b/ext/POSIX/POSIX.pod @@ -848,7 +848,8 @@ FIFO special files. if (mkfifo($path, $mode)) { .... Returns C on failure. The C<$mode> is similar to the -mode of C, see L. +mode of C, see L, though for C +you B specify the C<$mode>. =item mktime @@ -1840,6 +1841,7 @@ Get terminal control attributes. Obtain the attributes for stdin. + $termios->getattr( 0 ) # Recommended for clarity. $termios->getattr() Obtain the attributes for stdout. diff --git a/ext/POSIX/t/sysconf.t b/ext/POSIX/t/sysconf.t index cefaea1..0790f47 100644 --- a/ext/POSIX/t/sysconf.t +++ b/ext/POSIX/t/sysconf.t @@ -17,8 +17,16 @@ use POSIX; 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 @@ my @sys_consts = qw( _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()" ) }; diff --git a/ext/POSIX/t/termios.t b/ext/POSIX/t/termios.t index bd21232..ff04d20 100644 --- a/ext/POSIX/t/termios.t +++ b/ext/POSIX/t/termios.t @@ -27,9 +27,25 @@ ok( defined $termios, "\tchecking if the object is defined" ); 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" ); }