patch to report warnings on bogus filehandles passed to flock(),
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / pp_sys
CommitLineData
599cee73 1 pp_sys.c AOK
2
767a6a26 3 untie attempted while %d inner references still exist [pp_untie]
599cee73 4 sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
767a6a26 6 Filehandle %s opened only for input [pp_leavewrite]
599cee73 7 format STDIN =
8 .
9 write STDIN;
10
9a7dcd9c 11 write() on closed filehandle %s [pp_leavewrite]
599cee73 12 format STDIN =
13 .
14 close STDIN;
15 write STDIN ;
16
767a6a26 17 page overflow [pp_leavewrite]
599cee73 18
767a6a26 19 Filehandle %s never opened [pp_prtf]
599cee73 20 $a = "abc"; printf $a "fred"
21
767a6a26 22 Filehandle %s opened only for input [pp_prtf]
599cee73 23 $a = "abc";
24 printf $a "fred"
25
9a7dcd9c 26 printf() on closed filehandle %s [pp_prtf]
599cee73 27 close STDIN ;
28 printf STDIN "fred"
29
69282e91 30 syswrite() on closed filehandle %s [pp_send]
599cee73 31 close STDIN;
32 syswrite STDIN, "fred", 1;
33
69282e91 34 send() on closed socket %s [pp_send]
599cee73 35 close STDIN;
36 send STDIN, "fred", 1
37
69282e91 38 bind() on closed socket %s [pp_bind]
599cee73 39 close STDIN;
40 bind STDIN, "fred" ;
41
42
69282e91 43 connect() on closed socket %s [pp_connect]
599cee73 44 close STDIN;
45 connect STDIN, "fred" ;
46
69282e91 47 listen() on closed socket %s [pp_listen]
599cee73 48 close STDIN;
49 listen STDIN, 2;
50
69282e91 51 accept() on closed socket %s [pp_accept]
599cee73 52 close STDIN;
69282e91 53 accept "fred", STDIN ;
599cee73 54
69282e91 55 shutdown() on closed socket %s [pp_shutdown]
599cee73 56 close STDIN;
57 shutdown STDIN, 0;
58
69282e91 59 setsockopt() on closed socket %s [pp_ssockopt]
60 getsockopt() on closed socket %s [pp_ssockopt]
599cee73 61 close STDIN;
62 setsockopt STDIN, 1,2,3;
63 getsockopt STDIN, 1,2;
64
69282e91 65 getsockname() on closed socket %s [pp_getpeername]
66 getpeername() on closed socket %s [pp_getpeername]
599cee73 67 close STDIN;
68 getsockname STDIN;
69 getpeername STDIN;
70
69282e91 71 flock() on closed socket %s [pp_flock]
72 close STDIN;
73 flock STDIN, 8;
74
767a6a26 75 warn(warn_nl, "stat"); [pp_stat]
599cee73 76
77 Test on unopened file <%s>
78 close STDIN ; -T STDIN ;
79
767a6a26 80 warn(warn_nl, "open"); [pp_fttext]
599cee73 81 -T "abc\ndef" ;
82
767a6a26 83 Filehandle %s opened only for output [pp_sysread]
84 my $file = "./xcv" ;
85 open(F, ">$file") ;
86 my $a = sysread(F, $a,10) ;
87
599cee73 88
89
90__END__
767a6a26 91# pp_sys.c [pp_untie]
4438c4b7 92use warnings 'untie' ;
599cee73 93sub TIESCALAR { bless [] } ;
94$b = tie $a, 'main';
95untie $a ;
4438c4b7 96no warnings 'untie' ;
0453d815 97$c = tie $d, 'main';
98untie $d ;
599cee73 99EXPECT
100untie attempted while 1 inner references still exist at - line 5.
101########
767a6a26 102# pp_sys.c [pp_leavewrite]
4438c4b7 103use warnings 'io' ;
599cee73 104format STDIN =
105.
106write STDIN;
4438c4b7 107no warnings 'io' ;
0453d815 108write STDIN;
599cee73 109EXPECT
af8c498a 110Filehandle main::STDIN opened only for input at - line 5.
599cee73 111########
767a6a26 112# pp_sys.c [pp_leavewrite]
4438c4b7 113use warnings 'closed' ;
599cee73 114format STDIN =
115.
116close STDIN;
117write STDIN;
69282e91 118opendir STDIN, ".";
119write STDIN;
120closedir STDIN;
4438c4b7 121no warnings 'closed' ;
0453d815 122write STDIN;
69282e91 123opendir STDIN, ".";
124write STDIN;
599cee73 125EXPECT
9a7dcd9c 126write() on closed filehandle main::STDIN at - line 6.
69282e91 127write() on closed filehandle main::STDIN at - line 8.
128(Are you trying to call write() on dirhandle main::STDIN?)
599cee73 129########
767a6a26 130# pp_sys.c [pp_leavewrite]
4438c4b7 131use warnings 'io' ;
599cee73 132format STDOUT_TOP =
133abc
134.
135format STDOUT =
136def
137ghi
138.
139$= = 1 ;
140$- =1 ;
3eeba6fb 141open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73 142write ;
4438c4b7 143no warnings 'io' ;
0453d815 144write ;
599cee73 145EXPECT
146page overflow at - line 13.
147########
767a6a26 148# pp_sys.c [pp_prtf]
4438c4b7 149use warnings 'unopened' ;
599cee73 150$a = "abc";
0453d815 151printf $a "fred";
4438c4b7 152no warnings 'unopened' ;
0453d815 153printf $a "fred";
599cee73 154EXPECT
155Filehandle main::abc never opened at - line 4.
156########
767a6a26 157# pp_sys.c [pp_prtf]
4438c4b7 158use warnings 'closed' ;
599cee73 159close STDIN ;
0453d815 160printf STDIN "fred";
69282e91 161opendir STDIN, ".";
162printf STDIN "fred";
163closedir STDIN;
4438c4b7 164no warnings 'closed' ;
0453d815 165printf STDIN "fred";
69282e91 166opendir STDIN, ".";
167printf STDIN "fred";
599cee73 168EXPECT
9a7dcd9c 169printf() on closed filehandle main::STDIN at - line 4.
69282e91 170printf() on closed filehandle main::STDIN at - line 6.
171(Are you trying to call printf() on dirhandle main::STDIN?)
599cee73 172########
767a6a26 173# pp_sys.c [pp_prtf]
4438c4b7 174use warnings 'io' ;
0453d815 175printf STDIN "fred";
4438c4b7 176no warnings 'io' ;
0453d815 177printf STDIN "fred";
599cee73 178EXPECT
179Filehandle main::STDIN opened only for input at - line 3.
180########
767a6a26 181# pp_sys.c [pp_send]
4438c4b7 182use warnings 'closed' ;
599cee73 183close STDIN;
184syswrite STDIN, "fred", 1;
69282e91 185opendir STDIN, ".";
186syswrite STDIN, "fred", 1;
187closedir STDIN;
4438c4b7 188no warnings 'closed' ;
0453d815 189syswrite STDIN, "fred", 1;
69282e91 190opendir STDIN, ".";
191syswrite STDIN, "fred", 1;
599cee73 192EXPECT
69282e91 193syswrite() on closed filehandle main::STDIN at - line 4.
194syswrite() on closed filehandle main::STDIN at - line 6.
195(Are you trying to call syswrite() on dirhandle main::STDIN?)
196########
197# pp_sys.c [pp_flock]
198use warnings 'closed' ;
199close STDIN;
200flock STDIN, 8;
201opendir STDIN, ".";
202flock STDIN, 8;
203no warnings 'closed' ;
204flock STDIN, 8;
205opendir STDIN, ".";
206flock STDIN, 8;
207EXPECT
208flock() on closed filehandle main::STDIN at - line 4.
209flock() on closed filehandle main::STDIN at - line 6.
210(Are you trying to call flock() on dirhandle main::STDIN?)
599cee73 211########
767a6a26 212# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
4438c4b7 213use warnings 'io' ;
599cee73 214use Config;
215BEGIN {
216 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
217 print <<EOM ;
218SKIPPED
219# send not present
220# bind not present
221# connect not present
222# accept not present
223# shutdown not present
224# setsockopt not present
225# getsockopt not present
226# getsockname not present
227# getpeername not present
228EOM
229 exit ;
230 }
231}
232close STDIN;
233send STDIN, "fred", 1;
234bind STDIN, "fred" ;
235connect STDIN, "fred" ;
236listen STDIN, 2;
69282e91 237accept "fred", STDIN;
238shutdown STDIN, 0;
239setsockopt STDIN, 1,2,3;
240getsockopt STDIN, 1,2;
241getsockname STDIN;
242getpeername STDIN;
243opendir STDIN, ".";
244send STDIN, "fred", 1;
245bind STDIN, "fred" ;
246connect STDIN, "fred" ;
247listen STDIN, 2;
248accept "fred", STDIN;
599cee73 249shutdown STDIN, 0;
250setsockopt STDIN, 1,2,3;
251getsockopt STDIN, 1,2;
252getsockname STDIN;
253getpeername STDIN;
69282e91 254closedir STDIN;
4438c4b7 255no warnings 'io' ;
0453d815 256send STDIN, "fred", 1;
257bind STDIN, "fred" ;
258connect STDIN, "fred" ;
259listen STDIN, 2;
260accept STDIN, "fred" ;
261shutdown STDIN, 0;
262setsockopt STDIN, 1,2,3;
263getsockopt STDIN, 1,2;
264getsockname STDIN;
265getpeername STDIN;
69282e91 266opendir STDIN, ".";
267send STDIN, "fred", 1;
268bind STDIN, "fred" ;
269connect STDIN, "fred" ;
270listen STDIN, 2;
271accept "fred", STDIN;
272shutdown STDIN, 0;
273setsockopt STDIN, 1,2,3;
274getsockopt STDIN, 1,2;
275getsockname STDIN;
276getpeername STDIN;
599cee73 277EXPECT
69282e91 278send() on closed socket main::STDIN at - line 22.
279bind() on closed socket main::STDIN at - line 23.
280connect() on closed socket main::STDIN at - line 24.
281listen() on closed socket main::STDIN at - line 25.
282accept() on closed socket main::STDIN at - line 26.
283shutdown() on closed socket main::STDIN at - line 27.
284setsockopt() on closed socket main::STDIN at - line 28.
285getsockopt() on closed socket main::STDIN at - line 29.
286getsockname() on closed socket main::STDIN at - line 30.
287getpeername() on closed socket main::STDIN at - line 31.
288send() on closed socket main::STDIN at - line 33.
289(Are you trying to call send() on dirhandle main::STDIN?)
290bind() on closed socket main::STDIN at - line 34.
291(Are you trying to call bind() on dirhandle main::STDIN?)
292connect() on closed socket main::STDIN at - line 35.
293(Are you trying to call connect() on dirhandle main::STDIN?)
294listen() on closed socket main::STDIN at - line 36.
295(Are you trying to call listen() on dirhandle main::STDIN?)
296accept() on closed socket main::STDIN at - line 37.
297(Are you trying to call accept() on dirhandle main::STDIN?)
298shutdown() on closed socket main::STDIN at - line 38.
299(Are you trying to call shutdown() on dirhandle main::STDIN?)
300setsockopt() on closed socket main::STDIN at - line 39.
301(Are you trying to call setsockopt() on dirhandle main::STDIN?)
302getsockopt() on closed socket main::STDIN at - line 40.
303(Are you trying to call getsockopt() on dirhandle main::STDIN?)
304getsockname() on closed socket main::STDIN at - line 41.
305(Are you trying to call getsockname() on dirhandle main::STDIN?)
306getpeername() on closed socket main::STDIN at - line 42.
307(Are you trying to call getpeername() on dirhandle main::STDIN?)
599cee73 308########
767a6a26 309# pp_sys.c [pp_stat]
4438c4b7 310use warnings 'newline' ;
599cee73 311stat "abc\ndef";
4438c4b7 312no warnings 'newline' ;
0453d815 313stat "abc\ndef";
599cee73 314EXPECT
315Unsuccessful stat on filename containing newline at - line 3.
316########
767a6a26 317# pp_sys.c [pp_fttext]
4438c4b7 318use warnings 'unopened' ;
599cee73 319close STDIN ;
320-T STDIN ;
4438c4b7 321no warnings 'unopened' ;
0453d815 322-T STDIN ;
599cee73 323EXPECT
324Test on unopened file <STDIN> at - line 4.
325########
767a6a26 326# pp_sys.c [pp_fttext]
4438c4b7 327use warnings 'newline' ;
599cee73 328-T "abc\ndef" ;
4438c4b7 329no warnings 'newline' ;
0453d815 330-T "abc\ndef" ;
599cee73 331EXPECT
332Unsuccessful open on filename containing newline at - line 3.
767a6a26 333########
334# pp_sys.c [pp_sysread]
335use warnings 'io' ;
336my $file = "./xcv" ;
337open(F, ">$file") ;
338my $a = sysread(F, $a,10) ;
339no warnings 'io' ;
340my $a = sysread(F, $a,10) ;
341close F ;
342unlink $file ;
343EXPECT
344Filehandle main::F opened only for output at - line 5.