11 plan skip_all => "POSIX is unavailable" if $Config{'extensions'} !~ m!\bPOSIX\b!;
17 use Scalar::Util qw(looks_like_number);
20 _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_NAME_MAX
21 _PC_NO_TRUNC _PC_PATH_MAX
24 my @path_consts_terminal = qw(
25 _PC_MAX_CANON _PC_MAX_INPUT _PC_VDISABLE
28 my @path_consts_fifo = qw(
33 _SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL
34 _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_PAGESIZE _SC_SAVED_IDS
35 _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
38 plan tests => 2 * 3 * @path_consts +
39 3 * @path_consts_terminal +
40 2 * 3 * @path_consts_fifo +
43 my $curdir = File::Spec->curdir;
47 # testing fpathconf() on a non-terminal file
49 my $fd = POSIX::open($curdir, O_RDONLY)
50 or skip "could not open current directory ($!)", 3 * @path_consts;
52 for my $constant (@path_consts) {
53 $r = eval { fpathconf( $fd, eval "$constant()" ) };
54 is( $@, '', "calling fpathconf($fd, $constant) " );
55 ok( defined $r, "\tchecking that the returned value is defined: $r" );
56 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
62 # testing pathconf() on a non-terminal file
63 for my $constant (@path_consts) {
64 $r = eval { pathconf( $curdir, eval "$constant()" ) };
65 is( $@, '', qq[calling pathconf("$curdir", $constant)] );
66 ok( defined $r, "\tchecking that the returned value is defined: $r" );
67 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
72 or skip("/dev/tty not a character file", 3 * @path_consts_terminal);
74 # testing pathconf() on a terminal file
75 for my $constant (@path_consts_terminal) {
76 $r = eval { pathconf( "/dev/tty", eval "$constant()" ) };
77 is( $@, '', qq[calling pathconf("/dev/tty", $constant)] );
78 ok( defined $r, "\tchecking that the returned value is defined: $r" );
79 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
87 or skip("could not create fifo $fifo ($!)", 2 * 3 * @path_consts_fifo);
90 my $fd = POSIX::open($fifo, O_RDWR)
91 or skip("could not open $fifo ($!)", 3 * @path_consts_fifo);
93 for my $constant (@path_consts_fifo) {
94 $r = eval { fpathconf( $fd, eval "$constant()" ) };
95 is( $@, '', "calling fpathconf($fd, $constant) " );
96 ok( defined $r, "\tchecking that the returned value is defined: $r" );
97 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
104 # testing pathconf() on a fifo file
105 for my $constant (@path_consts_fifo) {
106 $r = eval { pathconf( $fifo, eval "$constant()" ) };
107 is( $@, '', qq[calling pathconf($fifo, $constant)] );
108 ok( defined $r, "\tchecking that the returned value is defined: $r" );
109 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
117 for my $constant (@sys_consts) {
118 $r = eval { sysconf( eval "$constant()" ) };
119 is( $@, '', "calling sysconf($constant)" );
120 ok( defined $r, "\tchecking that the returned value is defined: $r" );
121 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );