diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2006-07-08 14:43:05 +0300 |
---|---|---|
committer | H.Merijn Brand <h.m.brand@xs4all.nl> | 2006-07-08 09:04:56 +0000 |
commit | 220f811aaa08aaaa6e406d8ab7a058ca628c18d7 (patch) | |
tree | c333fbea361981a3195d590361aa102ee57f874a /ext/POSIX | |
parent | 6309fe6dc6b6c6b27fa13966a4505c44ca8a8c9b (diff) | |
download | perl-220f811aaa08aaaa6e406d8ab7a058ca628c18d7.tar.gz |
POSIX test improvements on True64
Subject: [PATCH] the new POSIX tests
Message-ID: <44AF7019.3070509@iki.fi>
p4raw-id: //depot/perl@28505
Diffstat (limited to 'ext/POSIX')
-rw-r--r-- | ext/POSIX/POSIX.pod | 4 | ||||
-rw-r--r-- | ext/POSIX/t/sysconf.t | 83 | ||||
-rw-r--r-- | ext/POSIX/t/termios.t | 22 |
3 files changed, 94 insertions, 15 deletions
diff --git a/ext/POSIX/POSIX.pod b/ext/POSIX/POSIX.pod index 4374c9efd3..124d0bd8da 100644 --- a/ext/POSIX/POSIX.pod +++ b/ext/POSIX/POSIX.pod @@ -848,7 +848,8 @@ FIFO special files. 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 @@ 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 cefaea1103..0790f47c53 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 bd21232b1e..ff04d207f6 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" ); } |