xref: /openbsd-src/gnu/usr.bin/perl/t/op/filetest_t.t (revision 5759b3d249badf144a6240f7eec4dcf9df003e6b)
1b39c5158Smillert#!./perl
2b39c5158Smillert
3b39c5158SmillertBEGIN {
4b39c5158Smillert    chdir 't' if -d 't';
5b39c5158Smillert    require './test.pl';
6*5759b3d2Safresh1    set_up_inc('../lib');
7b39c5158Smillert}
8b39c5158Smillert
9b39c5158Smillertuse strict;
10b39c5158Smillert
11898184e3Ssthenplan 7;
12b39c5158Smillert
13b39c5158Smillertmy($dev_tty, $dev_null) = qw(/dev/tty /dev/null);
14b39c5158Smillert  ($dev_tty, $dev_null) = qw(con      nul      ) if $^O =~ /^(MSWin32|os2)$/;
15b39c5158Smillert  ($dev_tty, $dev_null) = qw(TT:      _NLA0:   ) if $^O eq "VMS";
16b39c5158Smillert
17b39c5158SmillertSKIP: {
18b39c5158Smillert    open(my $tty, "<", $dev_tty)
19898184e3Ssthen	or skip("Can't open terminal '$dev_tty': $!", 4);
20b39c5158Smillert    if ($^O eq 'VMS') {
21b39c5158Smillert        # TT might be a mailbox or other non-terminal device
22b39c5158Smillert        my $tt_dev = VMS::Filespec::vmspath('TT');
23898184e3Ssthen        skip("'$tt_dev' is probably not a terminal", 4) if $tt_dev !~ m/^_(tt|ft|rt)/i;
24b39c5158Smillert    }
25b39c5158Smillert    ok(-t $tty, "'$dev_tty' is a TTY");
26898184e3Ssthen    ok(-t -e $tty, "'$dev_tty' is a TTY (with -t -e)");
27898184e3Ssthen    -e 'mehyparchonarcheion'; # clear last stat buffer
28898184e3Ssthen    ok(-e -t $tty, "'$dev_tty' is a TTY (with -e -t)");
29898184e3Ssthen    -e 'mehyparchonarcheion';
30898184e3Ssthen    ok(-e -t -t $tty, "'$dev_tty' is a TTY (with -e -t -t)");
31b39c5158Smillert}
32b39c5158SmillertSKIP: {
33b39c5158Smillert    open(my $null, "<", $dev_null)
34898184e3Ssthen	or skip("Can't open null device '$dev_null': $!", 3);
35b39c5158Smillert    ok(!-t $null, "'$dev_null' is not a TTY");
36898184e3Ssthen    ok(!-t -e $null, "'$dev_null' is not a TTY (with -t -e)");
37898184e3Ssthen    ok(!-e -t $null, "'$dev_null' is not a TTY (with -e -t)");
38b39c5158Smillert}
39