This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
memcpy has n o in it, as pinted ut by Sarathy.
[perl5.git] / t / pragma / warn / pp_sys
CommitLineData
599cee73
PM
1 pp_sys.c AOK
2
767a6a26 3 untie attempted while %d inner references still exist [pp_untie]
599cee73
PM
4 sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
767a6a26 6 Filehandle %s opened only for input [pp_leavewrite]
599cee73
PM
7 format STDIN =
8 .
9 write STDIN;
10
9a7dcd9c 11 write() on closed filehandle %s [pp_leavewrite]
599cee73
PM
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
PM
20 $a = "abc"; printf $a "fred"
21
767a6a26 22 Filehandle %s opened only for input [pp_prtf]
599cee73
PM
23 $a = "abc";
24 printf $a "fred"
25
9a7dcd9c 26 printf() on closed filehandle %s [pp_prtf]
599cee73
PM
27 close STDIN ;
28 printf STDIN "fred"
29
69282e91 30 syswrite() on closed filehandle %s [pp_send]
599cee73
PM
31 close STDIN;
32 syswrite STDIN, "fred", 1;
33
69282e91 34 send() on closed socket %s [pp_send]
599cee73
PM
35 close STDIN;
36 send STDIN, "fred", 1
37
69282e91 38 bind() on closed socket %s [pp_bind]
599cee73
PM
39 close STDIN;
40 bind STDIN, "fred" ;
41
42
69282e91 43 connect() on closed socket %s [pp_connect]
599cee73
PM
44 close STDIN;
45 connect STDIN, "fred" ;
46
69282e91 47 listen() on closed socket %s [pp_listen]
599cee73
PM
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
PM
56 close STDIN;
57 shutdown STDIN, 0;
58
69282e91
GS
59 setsockopt() on closed socket %s [pp_ssockopt]
60 getsockopt() on closed socket %s [pp_ssockopt]
599cee73
PM
61 close STDIN;
62 setsockopt STDIN, 1,2,3;
63 getsockopt STDIN, 1,2;
64
69282e91
GS
65 getsockname() on closed socket %s [pp_getpeername]
66 getpeername() on closed socket %s [pp_getpeername]
599cee73
PM
67 close STDIN;
68 getsockname STDIN;
69 getpeername STDIN;
70
69282e91
GS
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
PM
76
77 Test on unopened file <%s>
78 close STDIN ; -T STDIN ;
79
767a6a26 80 warn(warn_nl, "open"); [pp_fttext]
599cee73
PM
81 -T "abc\ndef" ;
82
767a6a26
PM
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
PM
88
89
90__END__
767a6a26 91# pp_sys.c [pp_untie]
4438c4b7 92use warnings 'untie' ;
599cee73
PM
93sub TIESCALAR { bless [] } ;
94$b = tie $a, 'main';
95untie $a ;
4438c4b7 96no warnings 'untie' ;
0453d815
PM
97$c = tie $d, 'main';
98untie $d ;
599cee73
PM
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
PM
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
PM
114format STDIN =
115.
116close STDIN;
117write STDIN;
69282e91
GS
118opendir STDIN, ".";
119write STDIN;
120closedir STDIN;
4438c4b7 121no warnings 'closed' ;
0453d815 122write STDIN;
69282e91
GS
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.
cc507455 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
PM
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
PM
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
PM
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
GS
161opendir STDIN, ".";
162printf STDIN "fred";
163closedir STDIN;
4438c4b7 164no warnings 'closed' ;
0453d815 165printf STDIN "fred";
69282e91
GS
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.
cc507455 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
PM
178EXPECT
179Filehandle main::STDIN opened only for input at - line 3.
180########
767a6a26 181# pp_sys.c [pp_send]
4438c4b7 182use warnings 'closed' ;
599cee73
PM
183close STDIN;
184syswrite STDIN, "fred", 1;
69282e91
GS
185opendir STDIN, ".";
186syswrite STDIN, "fred", 1;
187closedir STDIN;
4438c4b7 188no warnings 'closed' ;
0453d815 189syswrite STDIN, "fred", 1;
69282e91
GS
190opendir STDIN, ".";
191syswrite STDIN, "fred", 1;
599cee73 192EXPECT
69282e91
GS
193syswrite() on closed filehandle main::STDIN at - line 4.
194syswrite() on closed filehandle main::STDIN at - line 6.
cc507455 195 (Are you trying to call syswrite() on dirhandle main::STDIN?)
69282e91
GS
196########
197# pp_sys.c [pp_flock]
f0963acb
GS
198use Config;
199BEGIN {
200 if ( $^O eq 'VMS' and ! $Config{d_flock}) {
201 print <<EOM ;
202SKIPPED
203# flock not present
204EOM
205 exit ;
206 }
207}
69282e91
GS
208use warnings 'closed' ;
209close STDIN;
210flock STDIN, 8;
211opendir STDIN, ".";
212flock STDIN, 8;
213no warnings 'closed' ;
214flock STDIN, 8;
215opendir STDIN, ".";
216flock STDIN, 8;
217EXPECT
48e87789
GS
218flock() on closed filehandle main::STDIN at - line 14.
219flock() on closed filehandle main::STDIN at - line 16.
cc507455 220 (Are you trying to call flock() on dirhandle main::STDIN?)
599cee73 221########
767a6a26 222# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
4438c4b7 223use warnings 'io' ;
599cee73
PM
224use Config;
225BEGIN {
226 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
227 print <<EOM ;
228SKIPPED
229# send not present
230# bind not present
231# connect not present
232# accept not present
233# shutdown not present
234# setsockopt not present
235# getsockopt not present
236# getsockname not present
237# getpeername not present
238EOM
239 exit ;
240 }
241}
242close STDIN;
243send STDIN, "fred", 1;
244bind STDIN, "fred" ;
245connect STDIN, "fred" ;
246listen STDIN, 2;
69282e91
GS
247accept "fred", STDIN;
248shutdown STDIN, 0;
249setsockopt STDIN, 1,2,3;
250getsockopt STDIN, 1,2;
251getsockname STDIN;
252getpeername STDIN;
253opendir STDIN, ".";
254send STDIN, "fred", 1;
255bind STDIN, "fred" ;
256connect STDIN, "fred" ;
257listen STDIN, 2;
258accept "fred", STDIN;
599cee73
PM
259shutdown STDIN, 0;
260setsockopt STDIN, 1,2,3;
261getsockopt STDIN, 1,2;
262getsockname STDIN;
263getpeername STDIN;
69282e91 264closedir STDIN;
4438c4b7 265no warnings 'io' ;
0453d815
PM
266send STDIN, "fred", 1;
267bind STDIN, "fred" ;
268connect STDIN, "fred" ;
269listen STDIN, 2;
270accept STDIN, "fred" ;
271shutdown STDIN, 0;
272setsockopt STDIN, 1,2,3;
273getsockopt STDIN, 1,2;
274getsockname STDIN;
275getpeername STDIN;
69282e91
GS
276opendir STDIN, ".";
277send STDIN, "fred", 1;
278bind STDIN, "fred" ;
279connect STDIN, "fred" ;
280listen STDIN, 2;
281accept "fred", STDIN;
282shutdown STDIN, 0;
283setsockopt STDIN, 1,2,3;
284getsockopt STDIN, 1,2;
285getsockname STDIN;
286getpeername STDIN;
599cee73 287EXPECT
69282e91
GS
288send() on closed socket main::STDIN at - line 22.
289bind() on closed socket main::STDIN at - line 23.
290connect() on closed socket main::STDIN at - line 24.
291listen() on closed socket main::STDIN at - line 25.
292accept() on closed socket main::STDIN at - line 26.
293shutdown() on closed socket main::STDIN at - line 27.
294setsockopt() on closed socket main::STDIN at - line 28.
295getsockopt() on closed socket main::STDIN at - line 29.
296getsockname() on closed socket main::STDIN at - line 30.
297getpeername() on closed socket main::STDIN at - line 31.
298send() on closed socket main::STDIN at - line 33.
cc507455 299 (Are you trying to call send() on dirhandle main::STDIN?)
69282e91 300bind() on closed socket main::STDIN at - line 34.
cc507455 301 (Are you trying to call bind() on dirhandle main::STDIN?)
69282e91 302connect() on closed socket main::STDIN at - line 35.
cc507455 303 (Are you trying to call connect() on dirhandle main::STDIN?)
69282e91 304listen() on closed socket main::STDIN at - line 36.
cc507455 305 (Are you trying to call listen() on dirhandle main::STDIN?)
69282e91 306accept() on closed socket main::STDIN at - line 37.
cc507455 307 (Are you trying to call accept() on dirhandle main::STDIN?)
69282e91 308shutdown() on closed socket main::STDIN at - line 38.
cc507455 309 (Are you trying to call shutdown() on dirhandle main::STDIN?)
69282e91 310setsockopt() on closed socket main::STDIN at - line 39.
cc507455 311 (Are you trying to call setsockopt() on dirhandle main::STDIN?)
69282e91 312getsockopt() on closed socket main::STDIN at - line 40.
cc507455 313 (Are you trying to call getsockopt() on dirhandle main::STDIN?)
69282e91 314getsockname() on closed socket main::STDIN at - line 41.
cc507455 315 (Are you trying to call getsockname() on dirhandle main::STDIN?)
69282e91 316getpeername() on closed socket main::STDIN at - line 42.
cc507455 317 (Are you trying to call getpeername() on dirhandle main::STDIN?)
599cee73 318########
767a6a26 319# pp_sys.c [pp_stat]
4438c4b7 320use warnings 'newline' ;
599cee73 321stat "abc\ndef";
4438c4b7 322no warnings 'newline' ;
0453d815 323stat "abc\ndef";
599cee73
PM
324EXPECT
325Unsuccessful stat on filename containing newline at - line 3.
326########
767a6a26 327# pp_sys.c [pp_fttext]
4438c4b7 328use warnings 'unopened' ;
599cee73
PM
329close STDIN ;
330-T STDIN ;
4438c4b7 331no warnings 'unopened' ;
0453d815 332-T STDIN ;
599cee73
PM
333EXPECT
334Test on unopened file <STDIN> at - line 4.
335########
767a6a26 336# pp_sys.c [pp_fttext]
4438c4b7 337use warnings 'newline' ;
599cee73 338-T "abc\ndef" ;
4438c4b7 339no warnings 'newline' ;
0453d815 340-T "abc\ndef" ;
599cee73
PM
341EXPECT
342Unsuccessful open on filename containing newline at - line 3.
767a6a26
PM
343########
344# pp_sys.c [pp_sysread]
345use warnings 'io' ;
346my $file = "./xcv" ;
347open(F, ">$file") ;
348my $a = sysread(F, $a,10) ;
349no warnings 'io' ;
350my $a = sysread(F, $a,10) ;
351close F ;
352unlink $file ;
353EXPECT
354Filehandle main::F opened only for output at - line 5.