4 # Modification history:
5 # Written 91-12-02 through 92-01-01 by Stephen McGee.
6 # Modified 92-02-11 through 92-02-22 by Chris Arthur to further generalize.
8 # Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
9 # 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
11 # This file is part of GNU Make.
13 # GNU Make is free software; you can redistribute it and/or modify it under
14 # the terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 3 of the License, or (at your option) any later
18 # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 # You should have received a copy of the GNU General Public License along with
24 # this program. If not, see <http://www.gnu.org/licenses/>.
27 # Test driver routines used by a number of test suites, including
28 # those for SCS, make, roll_dir, and scan_deps (?).
30 # this routine controls the whole mess; each test suite sets up a few
31 # variables and then calls &toplevel, which does all the real work.
33 # $Id: test_driver.pl,v 1.27 2009/10/25 18:56:46 psmith Exp $
36 # The number of test categories we've run
38 # The number of test categroies that have passed
39 $categories_passed = 0;
40 # The total number of individual tests that have been run
42 # The total number of individual tests that have passed
43 $total_tests_passed = 0;
44 # The number of tests in this category that have been run
46 # The number of tests in this category that have passed
50 # Yeesh. This whole test environment is such a hack!
54 # Timeout in seconds. If the test takes longer than this we'll fail it.
58 # %makeENV is the cleaned-out environment.
61 # %extraENV are any extra environment variables the tests might want to set.
62 # These are RESET AFTER EVERY TEST!
65 # %origENV is the caller's original environment
70 # We used to say "%ENV = ();" but this doesn't work in Perl 5.000
71 # through Perl 5.004. It was fixed in Perl 5.004_01, but we don't
72 # want to require that here, so just delete each one individually.
73 foreach $v (keys %ENV) {
78 foreach $v (keys %extraENV) {
79 $ENV{$v} = $extraENV{$v};
86 # Pull in benign variables from the user's environment
88 foreach (# UNIX-specific things
89 'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
92 # Windows NT-specific stuff
94 # DJGPP-specific stuff
95 'DJDIR', 'DJGPP', 'SHELL', 'COMSPEC', 'HOSTNAME', 'LFN',
96 'FNCASE', '387', 'EMU387', 'GROUP'
98 $makeENV{$_} = $ENV{$_} if $ENV{$_};
101 # Make sure our compares are not foiled by locale differences
103 $makeENV{LC_ALL
} = 'C';
105 # Replace the environment with the new one
111 $| = 1; # unbuffered output
113 $debug = 0; # debug flag
114 $profile = 0; # profiling flag
115 $verbose = 0; # verbose mode flag
116 $detail = 0; # detailed verbosity
117 $keep = 0; # keep temp files around
118 $workdir = "work"; # The directory where the test will start running
119 $scriptdir = "scripts"; # The directory where we find the test scripts
120 $tmpfilesuffix = "t"; # the suffix used on tmpfiles
121 $default_output_stack_level = 0; # used by attach_default_output, etc.
122 $default_input_stack_level = 0; # used by attach_default_input, etc.
123 $cwd = "."; # don't we wish we knew
124 $cwdslash = ""; # $cwd . $pathsep, but "" rather than "./"
126 &get_osname
; # sets $osname, $vos, $pathsep, and $short_filenames
128 &set_defaults
; # suite-defined
130 &parse_command_line
(@ARGV);
132 print "OS name = `$osname'\n" if $debug;
134 $workpath = "$cwdslash$workdir";
135 $scriptpath = "$cwdslash$scriptdir";
137 &set_more_defaults
; # suite-defined
143 print "Clearing $workpath...\n";
144 &remove_directory_tree
("$workpath/")
145 || &error
("Couldn't wipe out $workpath\n");
149 mkdir ($workpath, 0777) || &error
("Couldn't mkdir $workpath: $!\n");
154 &error
("Failed to find $scriptpath containing perl test scripts.\n");
159 print "Making work dirs...\n";
160 foreach $test (@TESTS)
162 if ($test =~ /^([^\/]+)\
//)
165 push (@rmdirs, $dir);
167 || mkdir ("$workpath/$dir", 0777)
168 || &error
("Couldn't mkdir $workpath/$dir: $!\n");
174 print "Finding tests...\n";
175 opendir (SCRIPTDIR
, $scriptpath)
176 || &error
("Couldn't opendir $scriptpath: $!\n");
177 @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR
) );
178 closedir (SCRIPTDIR
);
181 next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d
"$scriptpath/$dir");
182 push (@rmdirs, $dir);
183 mkdir ("$workpath/$dir", 0777)
184 || &error
("Couldn't mkdir $workpath/$dir: $!\n");
185 opendir (SCRIPTDIR
, "$scriptpath/$dir")
186 || &error
("Couldn't opendir $scriptpath/$dir: $!\n");
187 @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR
) );
188 closedir (SCRIPTDIR
);
189 foreach $test (@files)
192 push (@TESTS, "$dir/$test");
199 &error
("\nNo tests in $scriptpath, and none were specified.\n");
206 foreach $dir (@rmdirs)
208 rmdir ("$workpath/$dir");
213 $categories_failed = $categories_run - $categories_passed;
214 $total_tests_failed = $total_tests_run - $total_tests_passed;
216 if ($total_tests_failed)
218 print "\n$total_tests_failed Test";
219 print "s" unless $total_tests_failed == 1;
220 print " in $categories_failed Categor";
221 print ($categories_failed == 1 ?
"y" : "ies");
222 print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n";
227 print "\n$total_tests_passed Test";
228 print "s" unless $total_tests_passed == 1;
229 print " in $categories_passed Categor";
230 print ($categories_passed == 1 ?
"y" : "ies");
231 print " Complete ... No Failures :-)\n\n";
238 # Set up an initial value. In perl5 we can do it the easy way.
240 $osname = defined($^O
) ?
$^O
: '';
242 # See if the filesystem supports long file names with multiple
244 $short_filenames = 0;
245 (open (TOUCHFD
, "> fancy.file.name") && close (TOUCHFD
))
246 || ($short_filenames = 1);
247 unlink ("fancy.file.name") || ($short_filenames = 1);
249 if (! $short_filenames) {
250 # Thanks go to meyering@cs.utexas.edu (Jim Meyering) for suggesting a
251 # better way of doing this. (We used to test for existence of a /mnt
252 # dir, but that apparently fails on an SGI Indigo (whatever that is).)
253 # Because perl on VOS translates /'s to >'s, we need to test for
254 # VOSness rather than testing for Unixness (ie, try > instead of /).
256 mkdir (".ostest", 0777) || &error
("Couldn't create .ostest: $!\n", 1);
257 open (TOUCHFD
, "> .ostest>ick") && close (TOUCHFD
);
258 chdir (".ostest") || &error
("Couldn't chdir to .ostest: $!\n", 1);
261 if (! $short_filenames && -f
"ick")
269 # the following is regrettably knarly, but it seems to be the only way
270 # to not get ugly error messages if uname can't be found.
271 # Hmmm, BSD/OS 2.0's uname -a is excessively verbose. Let's try it
272 # with switches first.
273 eval "chop (\$osname = `sh -c 'uname -nmsr 2>&1'`)";
274 if ($osname =~ /not found/i)
276 $osname = "(something unixy with no uname)";
278 elsif ($@
ne "" || $?
)
280 eval "chop (\$osname = `sh -c 'uname -a 2>&1'`)";
283 $osname = "(something unixy)";
290 if (! $short_filenames) {
291 chdir ("..") || &error
("Couldn't chdir to ..: $!\n", 1);
292 unlink (".ostest>ick");
293 rmdir (".ostest") || &error
("Couldn't rmdir .ostest: $!\n", 1);
297 sub parse_command_line
301 # use @ARGV if no args were passed in
308 # look at each option; if we don't recognize it, maybe the suite-specific
309 # command line parsing code will...
313 $option = shift @argv;
314 if ($option =~ /^-debug$/i)
316 print "\nDEBUG ON\n";
319 elsif ($option =~ /^-usage$/i)
324 elsif ($option =~ /^-(h|help)$/i)
329 elsif ($option =~ /^-profile$/i)
333 elsif ($option =~ /^-verbose$/i)
337 elsif ($option =~ /^-detail$/i)
342 elsif ($option =~ /^-keep$/i)
346 elsif (&valid_option
($option))
348 # The suite-defined subroutine takes care of the option
350 elsif ($option =~ /^-/)
352 print "Invalid option: $option\n";
356 else # must be the name of a test
358 $option =~ s/\.pl$//;
359 push(@TESTS,$option);
366 local($num) = shift @_;
383 local($width, $string) = @_;
386 if (length ($string))
388 $pad = " " x
( ($width - length ($string) + 1) / 2);
399 $info = "Running tests for $testee on $osname\n"; # $testee is suite-defined
400 $len = &max
(length ($line), length ($testee_version),
401 length ($banner_info), 73) + 5;
402 $line = ("-" x
$len) . "\n";
408 &print_centered
($len, $line);
409 &print_centered
($len, $info);
410 &print_centered
($len, $testee_version); # suite-defined
411 &print_centered
($len, $banner_info); # suite-defined
412 &print_centered
($len, $line);
420 foreach $testname (sort @TESTS)
423 $suite_passed = 1; # reset by test on failure
424 $num_of_logfiles = 0;
425 $num_of_tmpfiles = 0;
428 $old_makefile = undef;
429 $testname =~ s/^$scriptpath$pathsep//;
430 $perl_testname = "$scriptpath$pathsep$testname";
431 $testname =~ s/(\.pl|\.perl)$//;
432 $testpath = "$workpath$pathsep$testname";
433 # Leave enough space in the extensions to append a number, even
434 # though it needs to fit into 8+3 limits.
435 if ($short_filenames) {
448 $log_filename = "$testpath.$logext";
449 $diff_filename = "$testpath.$diffext";
450 $base_filename = "$testpath.$baseext";
451 $run_filename = "$testpath.$runext";
452 $tmp_filename = "$testpath.$tmpfilesuffix";
454 &setup_for_test
; # suite-defined
456 $output = "........................................................ ";
458 substr($output,0,length($testname)) = "$testname ";
462 # Run the actual test!
466 $code = do $perl_testname;
468 $total_tests_run += $tests_run;
469 $total_tests_passed += $tests_passed;
476 warn "\n*** Test died ($testname): $@\n";
478 warn "\n*** Couldn't run $perl_testname\n";
481 elsif ($code == -1) {
484 elsif ($code != 1 && $code != -1) {
486 warn "\n*** Test returned $code\n";
490 ++$categories_passed;
491 $status = "ok ($tests_passed passed)";
492 for ($i = $num_of_tmpfiles; $i; $i--)
494 &rmfiles
($tmp_filename . &num_suffix
($i) );
497 for ($i = $num_of_logfiles ?
$num_of_logfiles : 1; $i; $i--)
499 &rmfiles
($log_filename . &num_suffix
($i) );
500 &rmfiles
($base_filename . &num_suffix
($i) );
503 elsif (!defined $code || $code > 0) {
504 $status = "FAILED ($tests_passed/$tests_run passed)";
511 # If the verbose option has been specified, then a short description
512 # of each test is printed before displaying the results of each test
513 # describing WHAT is being tested.
519 print "\nWHAT IS BEING TESTED\n";
520 print "--------------------";
522 print "\n\n$description\n\n";
525 # If the detail option has been specified, then the details of HOW
526 # the test is testing what it says it is testing in the verbose output
527 # will be displayed here before the results of the test are displayed.
531 print "\nHOW IT IS TESTED\n";
532 print "----------------";
533 print "\n\n$details\n\n";
540 # If the keep flag is not set, this subroutine deletes all filenames that
549 return (unlink @files);
555 sub print_standard_usage
557 local($plname,@moreusage) = @_;
560 print "usage:\t$plname [testname] [-verbose] [-detail] [-keep]\n";
561 print "\t\t\t[-profile] [-usage] [-help] [-debug]\n";
562 foreach (@moreusage) {
567 sub print_standard_help
569 local(@morehelp) = @_;
574 $line = "Test Driver For $testee";
576 $line = "=" x
length ($line);
582 . "${t}You may, if you wish, run only ONE test if you know the name\n"
583 . "${t}of that test and specify this name anywhere on the command\n"
584 . "${t}line. Otherwise ALL existing tests in the scripts directory\n"
585 . "${t}will be run.\n"
587 . "${t}If this option is given, a description of every test is\n"
588 . "${t}displayed before the test is run. (Not all tests may have\n"
589 . "${t}descriptions at this time)\n"
591 . "${t}If this option is given, a detailed description of every\n"
592 . "${t}test is displayed before the test is run. (Not all tests\n"
593 . "${t}have descriptions at this time)\n"
595 . "${t}If this option is given, then the profile file\n"
596 . "${t}is added to other profiles every time $testee is run.\n"
597 . "${t}This option only works on VOS at this time.\n"
599 . "${t}You may give this option if you DO NOT want ANY\n"
600 . "${t}of the files generated by the tests to be deleted. \n"
601 . "${t}Without this option, all files generated by the test will\n"
602 . "${t}be deleted IF THE TEST PASSES.\n"
604 . "${t}Use this option if you would like to see all of the system\n"
605 . "${t}calls issued and their return status while running the tests\n"
606 . "${t}This can be helpful if you're having a problem adding a test\n"
607 . "${t}to the suite, or if the test fails!\n";
609 foreach $line (@morehelp)
612 if (substr ($tline, 0, 1) eq "\t")
614 substr ($tline, 0, 1) = $t;
620 #######################################################################
621 ########### Generic Test Driver Subroutines ###########
622 #######################################################################
631 $depth = defined ($_[0]) ?
$_[0] : 1;
632 ($package, $filename, $linenum) = caller ($depth + 1);
633 return "$filename: $linenum";
638 local($message) = $_[0];
639 local($caller) = &get_caller
(1);
643 $caller = &get_caller
($_[1] + 1) . " -> $caller";
646 die "$caller: $message";
651 local($answer,$logfile) = @_;
652 local($slurp, $answer_matched) = ('', 0);
654 print "Comparing Output ........ " if $debug;
656 $slurp = &read_file_into_string
($logfile);
658 # For make, get rid of any time skew error before comparing--too bad this
659 # has to go into the "generic" driver code :-/
660 $slurp =~ s/^.*modification time .*in the future.*\n//gm;
661 $slurp =~ s/^.*Clock skew detected.*\n//gm;
665 if ($slurp eq $answer) {
668 # See if it is a slash or CRLF problem
669 local ($answer_mod, $slurp_mod) = ($answer, $slurp);
671 $answer_mod =~ tr
,\\,/,;
672 $answer_mod =~ s
,\r\n,\n,gs
;
674 $slurp_mod =~ tr
,\\,/,;
675 $slurp_mod =~ s
,\r\n,\n,gs
;
677 $answer_matched = ($slurp_mod eq $answer_mod);
679 # If it still doesn't match, see if the answer might be a regex.
680 if (!$answer_matched && $answer =~ m
,^/(.+)/$,) {
681 $answer_matched = ($slurp =~ /$1/);
682 if (!$answer_matched && $answer_mod =~ m
,^/(.+)/$,) {
683 $answer_matched = ($slurp_mod =~ /$1/);
688 if ($answer_matched && $test_passed)
690 print "ok\n" if $debug;
695 if (! $answer_matched) {
696 print "DIFFERENT OUTPUT\n" if $debug;
698 &create_file
(&get_basefile
, $answer);
699 &create_file
(&get_runfile
, $command_string);
701 print "\nCreating Difference File ...\n" if $debug;
703 # Create the difference file
705 local($command) = "diff -c " . &get_basefile
. " " . $logfile;
706 &run_command_with_output
(&get_difffile
,$command);
715 sub read_file_into_string
717 local($filename) = @_;
718 local($oldslash) = $/;
722 open (RFISFILE
, $filename) || return "";
723 local ($slurp) = <RFISFILE
>;
731 sub attach_default_output
733 local ($filename) = @_;
738 $code = system "++attach_default_output_hack $filename";
739 $code == -2 || &error
("adoh death\n", 1);
743 open ("SAVEDOS" . $default_output_stack_level . "out", ">&STDOUT")
744 || &error
("ado: $! duping STDOUT\n", 1);
745 open ("SAVEDOS" . $default_output_stack_level . "err", ">&STDERR")
746 || &error
("ado: $! duping STDERR\n", 1);
748 open (STDOUT
, "> " . $filename)
749 || &error
("ado: $filename: $!\n", 1);
750 open (STDERR
, ">&STDOUT")
751 || &error
("ado: $filename: $!\n", 1);
753 $default_output_stack_level++;
756 # close the current stdout/stderr, and restore the previous ones from
759 sub detach_default_output
765 $code = system "++detach_default_output_hack";
766 $code == -2 || &error
("ddoh death\n", 1);
770 if (--$default_output_stack_level < 0)
772 &error
("default output stack has flown under!\n", 1);
778 open (STDOUT
, ">&SAVEDOS" . $default_output_stack_level . "out")
779 || &error
("ddo: $! duping STDOUT\n", 1);
780 open (STDERR
, ">&SAVEDOS" . $default_output_stack_level . "err")
781 || &error
("ddo: $! duping STDERR\n", 1);
783 close ("SAVEDOS" . $default_output_stack_level . "out")
784 || &error
("ddo: $! closing SCSDOSout\n", 1);
785 close ("SAVEDOS" . $default_output_stack_level . "err")
786 || &error
("ddo: $! closing SAVEDOSerr\n", 1);
789 # This runs a command without any debugging info.
794 # We reset this before every invocation. On Windows I think there is only
795 # one environment, not one per process, so I think that variables set in
796 # test scripts might leak into subsequent tests if this isn't reset--???
800 local $SIG{ALRM
} = sub { die "timeout\n"; };
806 # The eval failed. If it wasn't SIGALRM then die.
807 $@
eq "timeout\n" or die;
809 # Timed out. Resend the alarm to our process group to kill the children.
810 $SIG{ALRM
} = 'IGNORE';
818 # run one command (passed as a list of arg 0 - n), returning 0 on success
819 # and nonzero on failure.
823 print "\nrun_command: @_\n" if $debug;
824 my $code = _run_command
(@_);
825 print "run_command returned $code.\n" if $debug;
830 # run one command (passed as a list of arg 0 - n, with arg 0 being the
831 # second arg to this routine), returning 0 on success and non-zero on failure.
832 # The first arg to this routine is a filename to connect to the stdout
833 # & stderr of the child process.
835 sub run_command_with_output
837 my $filename = shift;
839 print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
840 &attach_default_output
($filename);
841 my $code = _run_command
(@_);
842 &detach_default_output
;
843 print "run_command_with_output returned $code.\n" if $debug;
848 # performs the equivalent of an "rm -rf" on the first argument. Like
849 # rm, if the path ends in /, leaves the (now empty) directory; otherwise
852 sub remove_directory_tree
854 local ($targetdir) = @_;
855 local ($nuketop) = 1;
858 $ch = substr ($targetdir, length ($targetdir) - 1);
859 if ($ch eq "/" || $ch eq $pathsep)
861 $targetdir = substr ($targetdir, 0, length ($targetdir) - 1);
870 &remove_directory_tree_inner
("RDT00", $targetdir) || return 0;
873 rmdir $targetdir || return 0;
879 sub remove_directory_tree_inner
881 local ($dirhandle, $targetdir) = @_;
883 local ($subdirhandle);
885 opendir ($dirhandle, $targetdir) || return 0;
886 $subdirhandle = $dirhandle;
888 while ($object = readdir ($dirhandle))
890 if ($object =~ /^(\.\.?|CVS|RCS)$/)
895 $object = "$targetdir$pathsep$object";
898 if (-d _
&& &remove_directory_tree_inner
($subdirhandle, $object))
900 rmdir $object || return 0;
904 unlink $object || return 0;
907 closedir ($dirhandle);
911 # We used to use this behavior for this function:
915 # local (@filenames) = @_;
916 # local ($now) = time;
919 # foreach $file (@filenames)
921 # utime ($now, $now, $file)
922 # || (open (TOUCHFD, ">> $file") && close (TOUCHFD))
923 # || &error ("Couldn't touch $file: $!\n", 1);
928 # But this behaves badly on networked filesystems where the time is
929 # skewed, because it sets the time of the file based on the _local_
930 # host. Normally when you modify a file, it's the _remote_ host that
931 # determines the modtime, based on _its_ clock. So, instead, now we open
932 # the file and write something into it to force the remote host to set
933 # the modtime correctly according to its clock.
941 (open(T
, ">> $file") && print(T
"\n") && close(T
))
942 || &error
("Couldn't touch $file: $!\n", 1);
946 # Touch with a time offset. To DTRT, call touch() then use stat() to get the
947 # access/mod time for each file and apply the offset.
951 local ($off) = shift;
956 local (@s) = stat($_[0]);
958 utime($s[8]+$off, $s[9]+$off, @_);
961 # open a file, write some stuff to it, and close it.
965 local ($filename, @lines) = @_;
967 open (CF
, "> $filename") || &error
("Couldn't open $filename: $!\n", 1);
968 foreach $line (@lines)
975 # create a directory tree described by an associative array, wherein each
976 # key is a relative pathname (using slashes) and its associated value is
978 # DIR indicates a directory
979 # FILE:contents indicates a file, which should contain contents +\n
980 # LINK:target indicates a symlink, pointing to $basedir/target
981 # The first argument is the dir under which the structure will be created
982 # (the dir will be made and/or cleaned if necessary); the second argument
983 # is the associative array.
987 local ($basedir, %dirtree) = @_;
990 &remove_directory_tree
("$basedir");
991 mkdir ($basedir, 0777) || &error
("Couldn't mkdir $basedir: $!\n", 1);
993 foreach $path (sort keys (%dirtree))
995 if ($dirtree {$path} =~ /^DIR$/)
997 mkdir ("$basedir/$path", 0777)
998 || &error
("Couldn't mkdir $basedir/$path: $!\n", 1);
1000 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1002 &create_file
("$basedir/$path", $1 . "\n");
1004 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1006 symlink ("$basedir/$1", "$basedir/$path")
1007 || &error
("Couldn't symlink $basedir/$path -> $basedir/$1: $!\n", 1);
1011 &error
("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1014 if ($just_setup_tree)
1016 die "Tree is setup...\n";
1020 # compare a directory tree with an associative array in the format used
1021 # by create_dir_tree, above.
1022 # The first argument is the dir under which the structure should be found;
1023 # the second argument is the associative array.
1025 sub compare_dir_tree
1027 local ($basedir, %dirtree) = @_;
1033 local ($fulltarget);
1038 opendir (DIR
, $basedir) || &error
("Couldn't open $basedir: $!\n", 1);
1039 @allfiles = grep (!/^(\.\.?|CVS|RCS)$/, readdir (DIR
) );
1043 print "dirtree: (%dirtree)\n$basedir: (@allfiles)\n";
1046 foreach $path (sort keys (%dirtree))
1050 print "Checking $path ($dirtree{$path}).\n";
1054 foreach $i (0 .. $#allfiles)
1056 if ($allfiles[$i] eq $path)
1058 splice (@allfiles, $i, 1); # delete it
1061 print " Zapped $path; files now (@allfiles).\n";
1063 lstat ("$basedir/$path");
1071 print "compare_dir_tree: $path does not exist.\n";
1076 if ($dirtree {$path} =~ /^DIR$/)
1078 if (-d _
&& opendir (DIR
, "$basedir/$path") )
1080 @files = readdir (DIR
);
1082 @files = grep (!/^(\.\.?|CVS|RCS)$/ && ($_ = "$path/$_"), @files);
1083 push (@allfiles, @files);
1086 print " Read in $path; new files (@files).\n";
1091 print "compare_dir_tree: $path is not a dir.\n";
1095 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1099 print "compare_dir_tree: $path is not a file.\n";
1106 $contents = &read_file_into_string
("$basedir/$path");
1107 if ($contents ne "$1\n")
1109 print "compare_dir_tree: $path contains wrong stuff."
1110 . " Is:\n$contentsShould be:\n$1\n";
1115 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1120 print "compare_dir_tree: $path is not a link.\n";
1125 $contents = readlink ("$basedir/$path");
1126 $contents =~ tr/>/\//;
1127 $fulltarget = "$basedir/$target";
1128 $fulltarget =~ tr/>/\//;
1129 if (!($contents =~ /$fulltarget$/))
1133 $target = $fulltarget;
1135 print "compare_dir_tree: $path should be link to $target, "
1136 . "not $contents.\n";
1142 &error
("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1148 print "leftovers: (@allfiles).\n";
1151 foreach $file (@allfiles)
1153 print "compare_dir_tree: $file should not exist.\n";
1160 # this subroutine generates the numeric suffix used to keep tmp filenames,
1161 # log filenames, etc., unique. If the number passed in is 1, then a null
1162 # string is returned; otherwise, we return ".n", where n + 1 is the number
1170 return "$extext$num";
1176 # This subroutine returns a log filename with a number appended to
1177 # the end corresponding to how many logfiles have been created in the
1178 # current running test. An optional parameter may be passed (0 or 1).
1179 # If a 1 is passed, then it does NOT increment the logfile counter
1180 # and returns the name of the latest logfile. If either no parameter
1181 # is passed at all or a 0 is passed, then the logfile counter is
1182 # incremented and the new name is returned.
1186 local($no_increment) = @_;
1188 $num_of_logfiles += !$no_increment;
1190 return ($log_filename . &num_suffix
($num_of_logfiles));
1193 # This subroutine returns a base (answer) filename with a number
1194 # appended to the end corresponding to how many logfiles (and thus
1195 # base files) have been created in the current running test.
1196 # NO PARAMETERS ARE PASSED TO THIS SUBROUTINE.
1200 return ($base_filename . &num_suffix
($num_of_logfiles));
1203 # This subroutine returns a difference filename with a number appended
1204 # to the end corresponding to how many logfiles (and thus diff files)
1205 # have been created in the current running test.
1209 return ($diff_filename . &num_suffix
($num_of_logfiles));
1212 # This subroutine returns a command filename with a number appended
1213 # to the end corresponding to how many logfiles (and thus command files)
1214 # have been created in the current running test.
1218 return ($run_filename . &num_suffix
($num_of_logfiles));
1221 # just like logfile, only a generic tmp filename for use by the test.
1222 # they are automatically cleaned up unless -keep was used, or the test fails.
1223 # Pass an argument of 1 to return the same filename as the previous call.
1227 local($no_increment) = @_;
1229 $num_of_tmpfiles += !$no_increment;
1231 return ($tmp_filename . &num_suffix
($num_of_tmpfiles));