xref: /openbsd-src/gnu/usr.bin/perl/t/lib/warnings/pp_sys (revision 46035553bfdd96e63c94e32da0210227ec2e3cf1)
1  pp_sys.c 	AOK
2
3  untie attempted while %d inner references still exist	[pp_untie]
4    sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
6  fileno() on unopened filehandle abc		[pp_fileno]
7    $a = "abc"; fileno($a)
8
9  binmode() on unopened filehandle abc		[pp_binmode]
10    $a = "abc"; fileno($a)
11
12  printf() on unopened filehandle abc		[pp_prtf]
13    $a = "abc"; printf $a "fred"
14
15  Filehandle %s opened only for input		[pp_leavewrite]
16    format STDIN =
17    .
18    write STDIN;
19
20  write() on closed filehandle %s		[pp_leavewrite]
21    format STDIN =
22    .
23    close STDIN;
24    write STDIN ;
25
26  page overflow	 				[pp_leavewrite]
27
28  printf() on unopened filehandle abc		[pp_prtf]
29    $a = "abc"; printf $a "fred"
30
31  Filehandle %s opened only for input		[pp_prtf]
32    $a = "abc";
33    printf $a "fred"
34
35  printf() on closed filehandle %s		[pp_prtf]
36    close STDIN ;
37    printf STDIN "fred"
38
39  syswrite() on closed filehandle %s		[pp_send]
40    close STDIN;
41    syswrite STDIN, "fred", 1;
42
43  send() on closed socket %s			[pp_send]
44    close STDIN;
45    send STDIN, "fred", 1
46
47  bind() on closed socket %s			[pp_bind]
48    close STDIN;
49    bind STDIN, "fred" ;
50
51
52  connect() on closed socket %s			[pp_connect]
53    close STDIN;
54    connect STDIN, "fred" ;
55
56  listen() on closed socket %s			[pp_listen]
57    close STDIN;
58    listen STDIN, 2;
59
60  accept() on closed socket %s			[pp_accept]
61    close STDIN;
62    accept "fred", STDIN ;
63
64  shutdown() on closed socket %s		[pp_shutdown]
65    close STDIN;
66    shutdown STDIN, 0;
67
68  setsockopt() on closed socket %s		[pp_ssockopt]
69  getsockopt() on closed socket	%s		[pp_ssockopt]
70    close STDIN;
71    setsockopt STDIN, 1,2,3;
72    getsockopt STDIN, 1,2;
73
74  getsockname() on closed socket %s		[pp_getpeername]
75  getpeername() on closed socket %s		[pp_getpeername]
76    close STDIN;
77    getsockname STDIN;
78    getpeername STDIN;
79
80  flock() on closed socket %s			[pp_flock]
81  flock() on closed socket			[pp_flock]
82    close STDIN;
83    flock STDIN, 8;
84    flock $a, 8;
85
86  warn(warn_nl, "stat");			[pp_stat]
87
88  -T on closed filehandle %s
89  stat() on closed filehandle %s
90	close STDIN ; -T STDIN ; stat(STDIN) ;
91
92  warn(warn_nl, "open");			[pp_fttext]
93    -T "abc\ndef" ;
94
95  Filehandle %s opened only for output		[pp_sysread]
96	my $file = "./xcv" ;
97	open(F, ">$file") ;
98	my $a = sysread(F, $a,10) ;
99
100  lstat on filehandle %s			[pp_lstat]
101
102  getc() on unopened filehandle			[pp_getc]
103
104  getc() on closed filehandle			[pp_getc]
105
106  Non-string passed as bitmask			[pp_sselect]
107
108  %s too large					[pp_gmtime]
109
110  %s failed					[pp_gmtime]
111
112__END__
113# pp_sys.c [pp_untie]
114use warnings 'untie' ;
115sub TIESCALAR { bless [] } ;
116$b = tie $a, 'main';
117untie $a ;
118no warnings 'untie' ;
119$c = tie $d, 'main';
120untie $d ;
121EXPECT
122untie attempted while 1 inner references still exist at - line 5.
123########
124# pp_sys.c [pp_leavewrite]
125use warnings 'io' ;
126format STDIN =
127.
128write STDIN;
129no warnings 'io' ;
130write STDIN;
131EXPECT
132Filehandle STDIN opened only for input at - line 5.
133########
134# pp_sys.c [pp_leavewrite]
135use warnings 'closed' ;
136format STDIN =
137.
138format FOO =
139.
140close STDIN;
141write STDIN;
142write FOO;
143opendir STDIN, ".";
144write STDIN;
145closedir STDIN;
146opendir FOO, ".";
147write FOO;
148closedir FOO;
149no warnings 'closed' ;
150write STDIN;
151write FOO;
152opendir STDIN, ".";
153opendir FOO, ".";
154write STDIN;
155write FOO;
156EXPECT
157write() on closed filehandle STDIN at - line 8.
158write() on closed filehandle STDIN at - line 11.
159	(Are you trying to call write() on dirhandle STDIN?)
160########
161# pp_sys.c [pp_leavewrite]
162use warnings 'unopened';
163format STDIN =
164.
165format FOO =
166.
167close STDIN;
168write STDIN;
169write FOO;
170opendir STDIN, ".";
171write STDIN;
172closedir STDIN;
173opendir FOO, ".";
174write FOO;
175closedir FOO;
176no warnings 'unopened';
177write STDIN;
178write FOO;
179opendir STDIN, ".";
180opendir FOO, ".";
181write STDIN;
182write FOO;
183EXPECT
184write() on unopened filehandle FOO at - line 9.
185write() on unopened filehandle FOO at - line 14.
186	(Are you trying to call write() on dirhandle FOO?)
187########
188# pp_sys.c [pp_leavewrite]
189use warnings 'io' ;
190format STDOUT_TOP =
191abc
192.
193format STDOUT =
194def
195ghi
196.
197$= = 1 ;
198$- =1 ;
199open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
200write ;
201no warnings 'io' ;
202write ;
203EXPECT
204page overflow at - line 13.
205########
206# pp_sys.c [pp_prtf]
207use warnings 'unopened' ;
208$a = "abc";
209printf $a "fred";
210no warnings 'unopened' ;
211printf $a "fred";
212EXPECT
213printf() on unopened filehandle abc at - line 4.
214########
215# pp_sys.c [pp_prtf]
216use warnings 'closed' ;
217close STDIN ;
218printf STDIN "fred";
219opendir STDIN, ".";
220printf STDIN "fred";
221closedir STDIN;
222no warnings 'closed' ;
223printf STDIN "fred";
224opendir STDIN, ".";
225printf STDIN "fred";
226EXPECT
227printf() on closed filehandle STDIN at - line 4.
228printf() on closed filehandle STDIN at - line 6.
229	(Are you trying to call printf() on dirhandle STDIN?)
230########
231# pp_sys.c [pp_prtf]
232use warnings 'io' ;
233printf STDIN "fred";
234no warnings 'io' ;
235printf STDIN "fred";
236EXPECT
237Filehandle STDIN opened only for input at - line 3.
238########
239# pp_sys.c [pp_send]
240use warnings 'io' ;
241syswrite STDIN, "fred";
242no warnings 'io' ;
243syswrite STDIN, "fred";
244EXPECT
245Filehandle STDIN opened only for input at - line 3.
246########
247# pp_sys.c [pp_send]
248use warnings 'closed' ;
249close STDIN;
250syswrite STDIN, "fred", 1;
251opendir STDIN, ".";
252syswrite STDIN, "fred", 1;
253closedir STDIN;
254no warnings 'closed' ;
255syswrite STDIN, "fred", 1;
256opendir STDIN, ".";
257syswrite STDIN, "fred", 1;
258EXPECT
259syswrite() on closed filehandle STDIN at - line 4.
260syswrite() on closed filehandle STDIN at - line 6.
261	(Are you trying to call syswrite() on dirhandle STDIN?)
262########
263# pp_sys.c [pp_flock]
264use Config;
265BEGIN {
266  if ( !$Config{d_flock} &&
267       !$Config{d_fcntl_can_lock} &&
268       !$Config{d_lockf} ) {
269    print <<EOM ;
270SKIPPED
271# flock not present
272EOM
273    exit ;
274  }
275}
276use warnings qw(unopened closed);
277close STDIN;
278flock STDIN, 8;
279opendir STDIN, ".";
280flock STDIN, 8;
281flock FOO, 8;
282flock $a, 8;
283no warnings qw(unopened closed);
284flock STDIN, 8;
285opendir STDIN, ".";
286flock STDIN, 8;
287flock FOO, 8;
288flock $a, 8;
289EXPECT
290flock() on closed filehandle STDIN at - line 16.
291flock() on closed filehandle STDIN at - line 18.
292	(Are you trying to call flock() on dirhandle STDIN?)
293flock() on unopened filehandle FOO at - line 19.
294flock() on unopened filehandle at - line 20.
295########
296# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
297use warnings 'closed';
298use Config;
299BEGIN {
300  if ( $^O ne 'VMS' and ! $Config{d_socket}) {
301    print <<EOM ;
302SKIPPED
303# send not present
304# bind not present
305# connect not present
306# accept not present
307# shutdown not present
308# setsockopt not present
309# getsockopt not present
310# getsockname not present
311# getpeername not present
312EOM
313    exit ;
314  }
315}
316close STDIN;
317send STDIN, "fred", 1;
318bind STDIN, "fred" ;
319connect STDIN, "fred" ;
320listen STDIN, 2;
321accept "fred", STDIN;
322shutdown STDIN, 0;
323setsockopt STDIN, 1,2,3;
324getsockopt STDIN, 1,2;
325getsockname STDIN;
326getpeername STDIN;
327opendir STDIN, ".";
328send STDIN, "fred", 1;
329bind STDIN, "fred" ;
330connect STDIN, "fred" ;
331listen STDIN, 2;
332accept "fred", STDIN;
333shutdown STDIN, 0;
334setsockopt STDIN, 1,2,3;
335getsockopt STDIN, 1,2;
336getsockname STDIN;
337getpeername STDIN;
338closedir STDIN;
339send FOO, "fred", 1;
340bind FOO, "fred" ;
341connect FOO, "fred" ;
342listen FOO, 2;
343accept "fred", FOO;
344shutdown FOO, 0;
345setsockopt FOO, 1,2,3;
346getsockopt FOO, 1,2;
347getsockname FOO;
348getpeername FOO;
349opendir FOO, ".";
350send FOO, "fred", 1;
351bind FOO, "fred" ;
352connect FOO, "fred" ;
353listen FOO, 2;
354accept "fred", FOO;
355shutdown FOO, 0;
356setsockopt FOO, 1,2,3;
357getsockopt FOO, 1,2;
358getsockname FOO;
359getpeername FOO;
360closedir FOO;
361no warnings 'closed';
362send STDIN, "fred", 1;
363bind STDIN, "fred" ;
364connect STDIN, "fred" ;
365listen STDIN, 2;
366accept STDIN, "fred" ;
367shutdown STDIN, 0;
368setsockopt STDIN, 1,2,3;
369getsockopt STDIN, 1,2;
370getsockname STDIN;
371getpeername STDIN;
372opendir STDIN, ".";
373send STDIN, "fred", 1;
374bind STDIN, "fred" ;
375connect STDIN, "fred" ;
376listen STDIN, 2;
377accept "fred", STDIN;
378shutdown STDIN, 0;
379setsockopt STDIN, 1,2,3;
380getsockopt STDIN, 1,2;
381getsockname STDIN;
382getpeername STDIN;
383send FOO, "fred", 1;
384bind FOO, "fred" ;
385connect FOO, "fred" ;
386listen FOO, 2;
387accept FOO, "fred" ;
388shutdown FOO, 0;
389setsockopt FOO, 1,2,3;
390getsockopt FOO, 1,2;
391getsockname FOO;
392getpeername FOO;
393opendir FOO, ".";
394send FOO, "fred", 1;
395bind FOO, "fred" ;
396connect FOO, "fred" ;
397listen FOO, 2;
398accept "fred", FOO;
399shutdown FOO, 0;
400setsockopt FOO, 1,2,3;
401getsockopt FOO, 1,2;
402getsockname FOO;
403getpeername FOO;
404EXPECT
405send() on closed socket STDIN at - line 22.
406bind() on closed socket STDIN at - line 23.
407connect() on closed socket STDIN at - line 24.
408listen() on closed socket STDIN at - line 25.
409accept() on closed socket STDIN at - line 26.
410shutdown() on closed socket STDIN at - line 27.
411setsockopt() on closed socket STDIN at - line 28.
412getsockopt() on closed socket STDIN at - line 29.
413getsockname() on closed socket STDIN at - line 30.
414getpeername() on closed socket STDIN at - line 31.
415send() on closed socket STDIN at - line 33.
416	(Are you trying to call send() on dirhandle STDIN?)
417bind() on closed socket STDIN at - line 34.
418	(Are you trying to call bind() on dirhandle STDIN?)
419connect() on closed socket STDIN at - line 35.
420	(Are you trying to call connect() on dirhandle STDIN?)
421listen() on closed socket STDIN at - line 36.
422	(Are you trying to call listen() on dirhandle STDIN?)
423accept() on closed socket STDIN at - line 37.
424	(Are you trying to call accept() on dirhandle STDIN?)
425shutdown() on closed socket STDIN at - line 38.
426	(Are you trying to call shutdown() on dirhandle STDIN?)
427setsockopt() on closed socket STDIN at - line 39.
428	(Are you trying to call setsockopt() on dirhandle STDIN?)
429getsockopt() on closed socket STDIN at - line 40.
430	(Are you trying to call getsockopt() on dirhandle STDIN?)
431getsockname() on closed socket STDIN at - line 41.
432	(Are you trying to call getsockname() on dirhandle STDIN?)
433getpeername() on closed socket STDIN at - line 42.
434	(Are you trying to call getpeername() on dirhandle STDIN?)
435########
436# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
437use warnings 'unopened';
438use Config;
439BEGIN {
440  if ( $^O ne 'VMS' and ! $Config{d_socket}) {
441    print <<EOM ;
442SKIPPED
443# send not present
444# bind not present
445# connect not present
446# accept not present
447# shutdown not present
448# setsockopt not present
449# getsockopt not present
450# getsockname not present
451# getpeername not present
452EOM
453    exit ;
454  }
455}
456close STDIN;
457send STDIN, "fred", 1;
458bind STDIN, "fred" ;
459connect STDIN, "fred" ;
460listen STDIN, 2;
461accept "fred", STDIN;
462shutdown STDIN, 0;
463setsockopt STDIN, 1,2,3;
464getsockopt STDIN, 1,2;
465getsockname STDIN;
466getpeername STDIN;
467opendir STDIN, ".";
468send STDIN, "fred", 1;
469bind STDIN, "fred" ;
470connect STDIN, "fred" ;
471listen STDIN, 2;
472accept "fred", STDIN;
473shutdown STDIN, 0;
474setsockopt STDIN, 1,2,3;
475getsockopt STDIN, 1,2;
476getsockname STDIN;
477getpeername STDIN;
478closedir STDIN;
479send FOO, "fred", 1;
480bind FOO, "fred" ;
481connect FOO, "fred" ;
482listen FOO, 2;
483accept "fred", FOO;
484shutdown FOO, 0;
485setsockopt FOO, 1,2,3;
486getsockopt FOO, 1,2;
487getsockname FOO;
488getpeername FOO;
489opendir FOO, ".";
490send FOO, "fred", 1;
491bind FOO, "fred" ;
492connect FOO, "fred" ;
493listen FOO, 2;
494accept "fred", FOO;
495shutdown FOO, 0;
496setsockopt FOO, 1,2,3;
497getsockopt FOO, 1,2;
498getsockname FOO;
499getpeername FOO;
500closedir FOO;
501no warnings 'unopened';
502send STDIN, "fred", 1;
503bind STDIN, "fred" ;
504connect STDIN, "fred" ;
505listen STDIN, 2;
506accept STDIN, "fred" ;
507shutdown STDIN, 0;
508setsockopt STDIN, 1,2,3;
509getsockopt STDIN, 1,2;
510getsockname STDIN;
511getpeername STDIN;
512opendir STDIN, ".";
513send STDIN, "fred", 1;
514bind STDIN, "fred" ;
515connect STDIN, "fred" ;
516listen STDIN, 2;
517accept "fred", STDIN;
518shutdown STDIN, 0;
519setsockopt STDIN, 1,2,3;
520getsockopt STDIN, 1,2;
521getsockname STDIN;
522getpeername STDIN;
523send FOO, "fred", 1;
524bind FOO, "fred" ;
525connect FOO, "fred" ;
526listen FOO, 2;
527accept FOO, "fred" ;
528shutdown FOO, 0;
529setsockopt FOO, 1,2,3;
530getsockopt FOO, 1,2;
531getsockname FOO;
532getpeername FOO;
533opendir FOO, ".";
534send FOO, "fred", 1;
535bind FOO, "fred" ;
536connect FOO, "fred" ;
537listen FOO, 2;
538accept "fred", FOO;
539shutdown FOO, 0;
540setsockopt FOO, 1,2,3;
541getsockopt FOO, 1,2;
542getsockname FOO;
543getpeername FOO;
544EXPECT
545send() on unopened socket FOO at - line 44.
546bind() on unopened socket FOO at - line 45.
547connect() on unopened socket FOO at - line 46.
548listen() on unopened socket FOO at - line 47.
549accept() on unopened socket FOO at - line 48.
550shutdown() on unopened socket FOO at - line 49.
551setsockopt() on unopened socket FOO at - line 50.
552getsockopt() on unopened socket FOO at - line 51.
553getsockname() on unopened socket FOO at - line 52.
554getpeername() on unopened socket FOO at - line 53.
555send() on unopened socket FOO at - line 55.
556	(Are you trying to call send() on dirhandle FOO?)
557bind() on unopened socket FOO at - line 56.
558	(Are you trying to call bind() on dirhandle FOO?)
559connect() on unopened socket FOO at - line 57.
560	(Are you trying to call connect() on dirhandle FOO?)
561listen() on unopened socket FOO at - line 58.
562	(Are you trying to call listen() on dirhandle FOO?)
563accept() on unopened socket FOO at - line 59.
564	(Are you trying to call accept() on dirhandle FOO?)
565shutdown() on unopened socket FOO at - line 60.
566	(Are you trying to call shutdown() on dirhandle FOO?)
567setsockopt() on unopened socket FOO at - line 61.
568	(Are you trying to call setsockopt() on dirhandle FOO?)
569getsockopt() on unopened socket FOO at - line 62.
570	(Are you trying to call getsockopt() on dirhandle FOO?)
571getsockname() on unopened socket FOO at - line 63.
572	(Are you trying to call getsockname() on dirhandle FOO?)
573getpeername() on unopened socket FOO at - line 64.
574	(Are you trying to call getpeername() on dirhandle FOO?)
575########
576# pp_sys.c [pp_stat]
577use warnings 'newline' ;
578stat "abc\ndef";
579stat "abcdef\n";
580stat "abcdef\n\0";
581no warnings 'newline' ;
582stat "abc\ndef";
583stat "abcdef\n";
584stat "abcdef\n\0";
585EXPECT
586Unsuccessful stat on filename containing newline at - line 4.
587Unsuccessful stat on filename containing newline at - line 5.
588########
589# pp_sys.c [pp_fttext]
590use warnings qw(unopened closed) ;
591close STDIN ;
592-T STDIN ;
593stat(STDIN) ;
594-T HOCUS;
595stat(POCUS);
596stat "../test.pl";
597stat *foo;
598no warnings qw(unopened closed) ;
599-T STDIN ;
600stat(STDIN);
601-T HOCUS;
602stat(POCUS);
603stat "../test.pl";
604stat *foo;
605EXPECT
606-T on closed filehandle STDIN at - line 4.
607stat() on closed filehandle STDIN at - line 5.
608-T on unopened filehandle HOCUS at - line 6.
609stat() on unopened filehandle POCUS at - line 7.
610stat() on unopened filehandle foo at - line 9.
611########
612# pp_sys.c [pp_fttext]
613use warnings 'newline' ;
614-T "abc\ndef" ;
615-T "abcdef\n" ;
616-T "abcdef\n\0" ;
617no warnings 'newline' ;
618-T "abc\ndef" ;
619-T "abcdef\n" ;
620-T "abcdef\n\0" ;
621EXPECT
622Unsuccessful open on filename containing newline at - line 4.
623Unsuccessful open on filename containing newline at - line 5.
624########
625# pp_sys.c [pp_sysread]
626use warnings 'io' ;
627if ($^O eq 'dos') {
628    print <<EOM ;
629SKIPPED
630# skipped on dos
631EOM
632    exit ;
633}
634my $file = "./xcv" ;
635open(F, ">$file") ;
636binmode F;
637my $a = sysread(F, $a,10) ;
638no warnings 'io' ;
639my $a = sysread(F, $a,10) ;
640close F ;
641use warnings 'io' ;
642sysread(F, $a, 10);
643read(F, $a, 10);
644sysread(NONEXISTENT, $a, 10);
645read(NONEXISTENT, $a, 10);
646unlink $file ;
647EXPECT
648Filehandle F opened only for output at - line 13.
649sysread() on closed filehandle F at - line 18.
650read() on closed filehandle F at - line 19.
651sysread() on unopened filehandle NONEXISTENT at - line 20.
652read() on unopened filehandle NONEXISTENT at - line 21.
653########
654# pp_sys.c [pp_binmode]
655use warnings 'unopened' ;
656binmode(BLARG);
657$a = "BLERG";binmode($a);
658EXPECT
659binmode() on unopened filehandle BLARG at - line 3.
660binmode() on unopened filehandle at - line 4.
661########
662# pp_sys.c [pp_lstat]
663use warnings 'io';
664open FH, "../harness" or die "# $!";
665lstat FH;
666lstat *FH;
667lstat \*FH;
668open my $fh, $0 or die "# $!";
669lstat $fh;
670lstat *FH{IO};
671no warnings 'io';
672lstat FH;
673lstat $fh;
674close FH;
675close $fh;
676EXPECT
677lstat() on filehandle FH at - line 4.
678lstat() on filehandle FH at - line 5.
679lstat() on filehandle FH at - line 6.
680lstat() on filehandle $fh at - line 8.
681lstat() on filehandle at - line 9.
682########
683
684# pp_sys.c [pp_lstat]
685use warnings 'io';
686use utf8;
687use open qw( :utf8 :std );
688open ᶠḨ, "../harness" or die "# $!";
689lstat ᶠḨ;
690open my $fᚺ, $0 or die "# $!";
691lstat $fᚺ;
692no warnings 'io';
693lstat ᶠḨ;
694lstat $fᚺ;
695close ᶠḨ;
696close $fᚺ;
697EXPECT
698lstat() on filehandle ᶠḨ at - line 7.
699lstat() on filehandle $fᚺ at - line 9.
700########
701# pp_sys.c [pp_getc]
702use warnings qw(unopened closed) ;
703getc FOO;
704close STDIN;
705getc STDIN;
706# Create an empty file
707$file = 'getcwarn.tmp';
708open FH1, ">$file" or die "# $!"; close FH1;
709open FH2, $file    or die "# $!";
710getc FH2; # Should not warn at EOF
711close FH2;
712getc FH2; # Warns, now
713unlink $file;
714no warnings qw(unopened closed) ;
715getc FOO;
716getc STDIN;
717getc FH2;
718EXPECT
719getc() on unopened filehandle FOO at - line 3.
720getc() on closed filehandle STDIN at - line 5.
721getc() on closed filehandle FH2 at - line 12.
722########
723# pp_sys.c [pp_sselect]
724use warnings 'misc';
725$x = 1;
726select $x, undef, undef, 1;
727sub TIESCALAR{bless[]} sub FETCH {"hello"} sub STORE{}
728tie $y, "";
729select $y, undef, undef, 1;
730no warnings 'misc';
731select $x, undef, undef, 1;
732EXPECT
733Non-string passed as bitmask at - line 4.
734########
735use Config;
736BEGIN {
737    if (!$Config{d_fchdir}) {
738	print <<EOM;
739SKIPPED
740# fchdir not present
741EOM
742	exit;
743    }
744}
745opendir FOO, '.'; closedir FOO;
746open BAR, '.'; close BAR;
747opendir $dh, '.'; closedir $dh;
748open $fh, '.'; close $fh;
749chdir FOO;
750chdir BAR;
751chdir $dh;
752chdir $fh;
753use warnings qw(unopened closed) ;
754chdir FOO;
755chdir BAR;
756chdir $dh;
757chdir $fh;
758EXPECT
759chdir() on unopened filehandle FOO at - line 20.
760chdir() on closed filehandle BAR at - line 21.
761chdir() on unopened filehandle $dh at - line 22.
762chdir() on closed filehandle $fh at - line 23.
763########
764# pp_sys.c [pp_*dir]
765use Config ;
766BEGIN {
767    if ( ! $Config{d_telldir}) {
768        print <<EOM ;
769SKIPPED
770# telldir not present
771EOM
772        exit
773    }
774}
775#line 2
776use warnings 'io';
777opendir FOO, ".";
778opendir $foo, ".";
779closedir FOO;
780closedir $foo;
781
782readdir(FOO);
783telldir(FOO);
784seekdir(FOO, 0);
785rewinddir(FOO);
786closedir(FOO);
787
788readdir($foo);
789telldir($foo);
790seekdir($foo, 0);
791rewinddir($foo);
792closedir($foo);
793
794EXPECT
795readdir() attempted on invalid dirhandle FOO at - line 8.
796telldir() attempted on invalid dirhandle FOO at - line 9.
797seekdir() attempted on invalid dirhandle FOO at - line 10.
798rewinddir() attempted on invalid dirhandle FOO at - line 11.
799closedir() attempted on invalid dirhandle FOO at - line 12.
800readdir() attempted on invalid dirhandle $foo at - line 14.
801telldir() attempted on invalid dirhandle $foo at - line 15.
802seekdir() attempted on invalid dirhandle $foo at - line 16.
803rewinddir() attempted on invalid dirhandle $foo at - line 17.
804closedir() attempted on invalid dirhandle $foo at - line 18.
805########
806
807# pp_sys.c [pp_*dir]
808use Config ;
809BEGIN {
810    if ( ! $Config{d_telldir}) {
811        print <<EOM ;
812SKIPPED
813# telldir not present
814EOM
815        exit
816    }
817}
818#line 3
819use utf8;
820use open qw( :utf8 :std );
821use warnings 'io';
822opendir FOO, ".";
823opendir $foo, ".";
824opendir FOO, ".";
825opendir $foo, ".";
826closedir FOO;
827closedir $foo;
828
829readdir(FOO);
830telldir(FOO);
831seekdir(FOO, 0);
832rewinddir(FOO);
833closedir(FOO);
834
835readdir($foo);
836telldir($foo);
837seekdir($foo, 0);
838rewinddir($foo);
839closedir($foo);
840
841EXPECT
842readdir() attempted on invalid dirhandle FOO at - line 13.
843telldir() attempted on invalid dirhandle FOO at - line 14.
844seekdir() attempted on invalid dirhandle FOO at - line 15.
845rewinddir() attempted on invalid dirhandle FOO at - line 16.
846closedir() attempted on invalid dirhandle FOO at - line 17.
847readdir() attempted on invalid dirhandle $foo at - line 19.
848telldir() attempted on invalid dirhandle $foo at - line 20.
849seekdir() attempted on invalid dirhandle $foo at - line 21.
850rewinddir() attempted on invalid dirhandle $foo at - line 22.
851closedir() attempted on invalid dirhandle $foo at - line 23.
852########
853
854# pp_sys.c [pp_gmtime]
855use Config;
856unless ($Config{d_double_has_nan}) {
857    print <<EOM ;
858SKIPPED
859# No nan support
860EOM
861    exit ;
862}
863gmtime("NaN");
864localtime("NaN");
865use warnings "overflow";
866gmtime("NaN");
867localtime("NaN");
868
869EXPECT
870gmtime(NaN) too large at - line 14.
871gmtime(NaN) failed at - line 14.
872localtime(NaN) too large at - line 15.
873localtime(NaN) failed at - line 15.
874
875########
876# pp_sys.c [pp_alarm]
877alarm(-1);
878no warnings "misc";
879alarm(-1);
880
881EXPECT
882alarm() with negative argument at - line 2.
883
884########
885# pp_sys.c [pp_sleep]
886sleep(-1);
887no warnings "misc";
888sleep(-1);
889
890EXPECT
891sleep() with negative argument at - line 2.
892########
893# NAME stat on name with \0
894use warnings;
895my @x = stat("./\0-");
896my @y = lstat("./\0-");
897-T ".\0-";
898-x ".\0-";
899-l ".\0-";
900EXPECT
901Invalid \0 character in pathname for stat: ./\0- at - line 2.
902Invalid \0 character in pathname for lstat: ./\0- at - line 3.
903Invalid \0 character in pathname for fttext: .\0- at - line 4.
904Invalid \0 character in pathname for fteexec: .\0- at - line 5.
905Invalid \0 character in pathname for ftlink: .\0- at - line 6.
906