11 plan skip_all => "POSIX is unavailable" if $Config{'extensions'} !~ m!\bPOSIX\b!;
17 use Scalar::Util qw(looks_like_number);
20 grep { eval "&$_;1" or $@!~/vendor has not defined POSIX macro/ } @_
23 my @path_consts = check qw(
24 _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_NAME_MAX
25 _PC_NO_TRUNC _PC_PATH_MAX
28 my @path_consts_terminal = check qw(
29 _PC_MAX_CANON _PC_MAX_INPUT _PC_VDISABLE
32 my @path_consts_fifo = check qw(
36 my @sys_consts = check qw(
37 _SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL
38 _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_PAGESIZE _SC_SAVED_IDS
39 _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
41 my $tests=2 * 3 * @path_consts +
42 3 * @path_consts_terminal +
43 2 * 3 * @path_consts_fifo +
47 : (skip_all => "No tests to run on this OS")
50 my $curdir = File::Spec->curdir;
54 # testing fpathconf() on a non-terminal file
56 my $fd = POSIX::open($curdir, O_RDONLY)
57 or skip "could not open current directory ($!)", 3 * @path_consts;
59 for my $constant (@path_consts) {
60 $r = eval { fpathconf( $fd, eval "$constant()" ) };
61 is( $@, '', "calling fpathconf($fd, $constant) " );
62 ok( defined $r, "\tchecking that the returned value is defined: $r" );
63 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
69 # testing pathconf() on a non-terminal file
70 for my $constant (@path_consts) {
71 $r = eval { pathconf( $curdir, eval "$constant()" ) };
72 is( $@, '', qq[calling pathconf("$curdir", $constant)] );
73 ok( defined $r, "\tchecking that the returned value is defined: $r" );
74 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
79 or skip("/dev/tty not a character file", 3 * @path_consts_terminal);
81 # testing pathconf() on a terminal file
82 for my $constant (@path_consts_terminal) {
83 $r = eval { pathconf( "/dev/tty", eval "$constant()" ) };
84 is( $@, '', qq[calling pathconf("/dev/tty", $constant)] );
85 ok( defined $r, "\tchecking that the returned value is defined: $r" );
86 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
93 eval { mkfifo($fifo, 0666) }
94 or skip("could not create fifo $fifo ($!)", 2 * 3 * @path_consts_fifo);
97 my $fd = POSIX::open($fifo, O_RDWR)
98 or skip("could not open $fifo ($!)", 3 * @path_consts_fifo);
100 for my $constant (@path_consts_fifo) {
101 $r = eval { fpathconf( $fd, eval "$constant()" ) };
102 is( $@, '', "calling fpathconf($fd, $constant) " );
103 ok( defined $r, "\tchecking that the returned value is defined: $r" );
104 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
111 # testing pathconf() on a fifo file
112 for my $constant (@path_consts_fifo) {
113 $r = eval { pathconf( $fifo, eval "$constant()" ) };
114 is( $@, '', qq[calling pathconf($fifo, $constant)] );
115 ok( defined $r, "\tchecking that the returned value is defined: $r" );
116 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );
124 for my $constant (@sys_consts) {
126 skip "Saved IDs broken on Mac OS X (Perl #24122)", 3
127 if $^O eq 'darwin' && $constant eq '_SC_SAVED_IDS';
128 $r = eval { sysconf( eval "$constant()" ) };
129 is( $@, '', "calling sysconf($constant)" );
130 ok( defined $r, "\tchecking that the returned value is defined: $r" );
131 ok( looks_like_number($r), "\tchecking that the returned value looks like a number" );