summaryrefslogtreecommitdiff
path: root/t/pragma/warn/pp_sys
blob: bf64a940e180069505d37800d301e93a77741ff6 (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
  pp_sys.c 	AOK

  untie attempted while %d inner references still exist
    sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;

  Filehandle %s opened only for input
    format STDIN =
    .
    write STDIN;

  Write on closed filehandle %s
    format STDIN =
    .
    close STDIN;
    write STDIN ;

  page overflow	

  Filehandle %s never opened
    $a = "abc"; printf $a "fred"

  Filehandle %s opened only for input
    $a = "abc"; 
    printf $a "fred"

  printf on closed filehandle %s
    close STDIN ;
    printf STDIN "fred"

  Syswrite on closed filehandle
    close STDIN; 
    syswrite STDIN, "fred", 1;

  Send on closed socket
    close STDIN; 
    send STDIN, "fred", 1

  bind() on closed fd
    close STDIN; 
    bind STDIN, "fred" ;


  connect() on closed fd
    close STDIN; 
    connect STDIN, "fred" ;

  listen() on closed fd
    close STDIN; 
    listen STDIN, 2;

  accept() on closed fd
    close STDIN; 
    accept STDIN, "fred" ;

  shutdown() on closed fd
    close STDIN; 
    shutdown STDIN, 0;

  [gs]etsockopt() on closed fd
    close STDIN; 
    setsockopt STDIN, 1,2,3;
    getsockopt STDIN, 1,2;

  get{sock, peer}name() on closed fd
    close STDIN; 
    getsockname STDIN;
    getpeername STDIN;

  warn(warn_nl, "stat");

  Test on unopened file <%s>
	close STDIN ; -T STDIN ;

  warn(warn_nl, "open");
    -T "abc\ndef" ;

  

__END__
# pp_sys.c
use warning 'untie' ;
sub TIESCALAR { bless [] } ; 
$b = tie $a, 'main'; 
untie $a ;
no warning 'untie' ;
$c = tie $d, 'main'; 
untie $d ;
EXPECT
untie attempted while 1 inner references still exist at - line 5.
########
# pp_sys.c
use warning 'io' ;
format STDIN =
.
write STDIN;
no warning 'io' ;
write STDIN;
EXPECT
Filehandle main::STDIN opened only for input at - line 5.
########
# pp_sys.c
use warning 'closed' ;
format STDIN =
.
close STDIN;
write STDIN;
no warning 'closed' ;
write STDIN;
EXPECT
Write on closed filehandle main::STDIN at - line 6.
########
# pp_sys.c
use warning 'io' ;
format STDOUT_TOP =
abc
.
format STDOUT =
def
ghi
.
$= = 1 ;
$- =1 ;
open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
write ;
no warning 'io' ;
write ;
EXPECT
page overflow at - line 13.
########
# pp_sys.c
use warning 'unopened' ;
$a = "abc"; 
printf $a "fred";
no warning 'unopened' ;
printf $a "fred";
EXPECT
Filehandle main::abc never opened at - line 4.
########
# pp_sys.c
use warning 'closed' ;
close STDIN ;
printf STDIN "fred";
no warning 'closed' ;
printf STDIN "fred";
EXPECT
printf on closed filehandle main::STDIN at - line 4.
########
# pp_sys.c
use warning 'io' ;
printf STDIN "fred";
no warning 'io' ;
printf STDIN "fred";
EXPECT
Filehandle main::STDIN opened only for input at - line 3.
########
# pp_sys.c
use warning 'closed' ;
close STDIN; 
syswrite STDIN, "fred", 1;
no warning 'closed' ;
syswrite STDIN, "fred", 1;
EXPECT
Syswrite on closed filehandle at - line 4.
########
# pp_sys.c
use warning 'io' ;
use Config; 
BEGIN { 
  if ( $^O ne 'VMS' and ! $Config{d_socket}) {
    print <<EOM ;
SKIPPED
# send not present
# bind not present
# connect not present
# accept not present
# shutdown not present
# setsockopt not present
# getsockopt not present
# getsockname not present
# getpeername not present
EOM
    exit ;
  } 
}
close STDIN; 
send STDIN, "fred", 1;
bind STDIN, "fred" ;
connect STDIN, "fred" ;
listen STDIN, 2;
accept STDIN, "fred" ;
shutdown STDIN, 0;
setsockopt STDIN, 1,2,3;
getsockopt STDIN, 1,2;
getsockname STDIN;
getpeername STDIN;
no warning 'io' ;
send STDIN, "fred", 1;
bind STDIN, "fred" ;
connect STDIN, "fred" ;
listen STDIN, 2;
accept STDIN, "fred" ;
shutdown STDIN, 0;
setsockopt STDIN, 1,2,3;
getsockopt STDIN, 1,2;
getsockname STDIN;
getpeername STDIN;
EXPECT
Send on closed socket at - line 22.
bind() on closed fd at - line 23.
connect() on closed fd at - line 24.
listen() on closed fd at - line 25.
accept() on closed fd at - line 26.
shutdown() on closed fd at - line 27.
[gs]etsockopt() on closed fd at - line 28.
[gs]etsockopt() on closed fd at - line 29.
get{sock, peer}name() on closed fd at - line 30.
get{sock, peer}name() on closed fd at - line 31.
########
# pp_sys.c
use warning 'newline' ;
stat "abc\ndef";
no warning 'newline' ;
stat "abc\ndef";
EXPECT
Unsuccessful stat on filename containing newline at - line 3.
########
# pp_sys.c
use warning 'unopened' ;
close STDIN ; 
-T STDIN ;
no warning 'unopened' ;
-T STDIN ;
EXPECT
Test on unopened file <STDIN> at - line 4.
########
# pp_sys.c
use warning 'newline' ;
-T "abc\ndef" ;
no warning 'newline' ;
-T "abc\ndef" ;
EXPECT
Unsuccessful open on filename containing newline at - line 3.