chip@tct.com (Chip Salzenberg) (06/11/91)
Some time ago, I had some trouble with readdir() under SCO UNIX. Since I wanted to avoid having that trouble in future, I added a "readdir" test to my Perl test suite. I sent it to Larry, but busy beaver that he is, op.readdir fell through the cracks. Well, op.readdir is now op/readdir.t, and it's still useful. In the hope that it will save someone else a bit of detective work, here it is. Shar and enjoy. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: t/op/readdir.t # Wrapped by chip@count on Mon Jun 10 15:50:40 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 't/op/readdir.t' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'t/op/readdir.t'\" else echo shar: Extracting \"'t/op/readdir.t'\" \(473 characters\) sed "s/^X//" >'t/op/readdir.t' <<'END_OF_FILE' X#!./perl X Xeval 'opendir(NOSUCH, "no/such/directory");'; Xif ($@) { print "1..0\n"; exit; } X Xprint "1..3\n"; X Xif (opendir(OP, "op")) { print "ok 1\n"; } else { print "not ok 1\n"; } X@D = grep(/^[^\.]/, readdir(OP)); Xclosedir(OP); X Xif (@D > 20 && @D < 100) { print "ok 2\n"; } else { print "not ok 2\n"; } X X@R = sort @D; X@G = <op/*>; Xwhile (@R && @G && "op/".$R[0] eq $G[0]) { X shift(@R); X shift(@G); X} Xif (@R == 0 && @G == 0) { print "ok 3\n"; } else { print "not ok 3\n"; } END_OF_FILE if test 473 -ne `wc -c <'t/op/readdir.t'`; then echo shar: \"'t/op/readdir.t'\" unpacked with wrong size! fi # end of 't/op/readdir.t' fi echo shar: End of shell archive. exit 0