1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!./perl
# Test that various IO functions don't try to treat PVBMs as
# filehandles. Most of these will segfault perl if they fail.
BEGIN {
chdir 't' if -d 't';
@INC = qw(. ../lib);
require "./test.pl";
}
BEGIN { $| = 1 }
plan(28);
sub PVBM () { 'foo' }
{ my $dummy = index 'foo', PVBM }
{
my $which;
{
package Tie;
sub TIEHANDLE { $which = 'TIEHANDLE' }
sub TIESCALAR { $which = 'TIESCALAR' }
}
my $pvbm = PVBM;
tie $pvbm, 'Tie';
is ($which, 'TIESCALAR', 'PVBM gets TIESCALAR');
}
{
my $pvbm = PVBM;
ok (scalar eval { untie $pvbm; 1 }, 'untie(PVBM) doesn\'t segfault');
ok (scalar eval { tied $pvbm; 1 }, 'tied(PVBM) doesn\'t segfault');
}
{
my $pvbm = PVBM;
ok (scalar eval { pipe $pvbm, PIPE; }, 'pipe(PVBM, ) succeeds');
close foo;
close PIPE;
ok (scalar eval { pipe PIPE, $pvbm; }, 'pipe(, PVBM) succeeds');
close foo;
close PIPE;
ok (!eval { pipe \$pvbm, PIPE; }, 'pipe(PVBM ref, ) fails');
ok (!eval { pipe PIPE, \$pvbm; }, 'pipe(, PVBM ref) fails');
ok (!eval { truncate $pvbm, 0 }, 'truncate(PVBM) fails');
ok (!eval { truncate \$pvbm, 0}, 'truncate(PVBM ref) fails');
ok (!eval { stat $pvbm }, 'stat(PVBM) fails');
ok (!eval { stat \$pvbm }, 'stat(PVBM ref) fails');
ok (!eval { lstat $pvbm }, 'lstat(PVBM) fails');
ok (!eval { lstat \$pvbm }, 'lstat(PVBM ref) fails');
ok (!eval { chdir $pvbm }, 'chdir(PVBM) fails');
ok (!eval { chdir \$pvbm }, 'chdir(pvbm ref) fails');
ok (!eval { close $pvbm }, 'close(PVBM) fails');
ok (!eval { close $pvbm }, 'close(PVBM ref) fails');
ok (!eval { chmod 0600, $pvbm }, 'chmod(PVBM) fails');
ok (!eval { chmod 0600, \$pvbm }, 'chmod(PVBM ref) fails');
SKIP: {
skip('chown() not implemented on Win32', 2) if $^O eq 'MSWin32';
ok (!eval { chown 0, 0, $pvbm }, 'chown(PVBM) fails');
ok (!eval { chown 0, 0, \$pvbm }, 'chown(PVBM ref) fails');
}
ok (!eval { utime 0, 0, $pvbm }, 'utime(PVBM) fails');
ok (!eval { utime 0, 0, \$pvbm }, 'utime(PVBM ref) fails');
ok (!eval { <$pvbm> }, '<PVBM> fails');
ok (!eval { readline $pvbm }, 'readline(PVBM) fails');
ok (!eval { readline \$pvbm }, 'readline(PVBM ref) fails');
ok (!eval { open $pvbm, '<', 'none.such' }, 'open(PVBM) fails');
ok (!eval { open \$pvbm, '<', 'none.such', }, 'open(PVBM ref) fails');
}
|