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 Free Software Foundation, Inc.
10 # This file is part of GNU Make.
12 # GNU Make is free software; you can redistribute it and/or modify it under
13 # the terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 3 of the License, or (at your option) any later
17 # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 # You should have received a copy of the GNU General Public License along with
23 # this program. If not, see <http://www.gnu.org/licenses/>.
26 # Test driver routines used by a number of test suites, including
27 # those for SCS, make, roll_dir, and scan_deps (?).
29 # this routine controls the whole mess; each test suite sets up a few
30 # variables and then calls &toplevel, which does all the real work.
32 # $Id: test_driver.pl,v 1.26 2009/09/28 23:08:50 psmith Exp $
35 # The number of test categories we've run
37 # The number of test categroies that have passed
38 $categories_passed = 0;
39 # The total number of individual tests that have been run
41 # The total number of individual tests that have passed
42 $total_tests_passed = 0;
43 # The number of tests in this category that have been run
45 # The number of tests in this category that have passed
49 # Yeesh. This whole test environment is such a hack!
53 # Timeout in seconds. If the test takes longer than this we'll fail it.
57 # %makeENV is the cleaned-out environment.
60 # %extraENV are any extra environment variables the tests might want to set.
61 # These are RESET AFTER EVERY TEST!
64 # %origENV is the caller's original environment
69 # We used to say "%ENV = ();" but this doesn't work in Perl 5.000
70 # through Perl 5.004. It was fixed in Perl 5.004_01, but we don't
71 # want to require that here, so just delete each one individually.
72 foreach $v (keys %ENV) {
77 foreach $v (keys %extraENV) {
78 $ENV{$v} = $extraENV{$v};
85 # Pull in benign variables from the user's environment
87 foreach (# UNIX-specific things
88 'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
91 # Windows NT-specific stuff
93 # DJGPP-specific stuff
94 'DJDIR', 'DJGPP', 'SHELL', 'COMSPEC', 'HOSTNAME', 'LFN',
95 'FNCASE', '387', 'EMU387', 'GROUP'
97 $makeENV{$_} = $ENV{$_} if $ENV{$_};
100 # Make sure our compares are not foiled by locale differences
102 $makeENV{LC_ALL
} = 'C';
104 # Replace the environment with the new one
110 $| = 1; # unbuffered output
112 $debug = 0; # debug flag
113 $profile = 0; # profiling flag
114 $verbose = 0; # verbose mode flag
115 $detail = 0; # detailed verbosity
116 $keep = 0; # keep temp files around
117 $workdir = "work"; # The directory where the test will start running
118 $scriptdir = "scripts"; # The directory where we find the test scripts
119 $tmpfilesuffix = "t"; # the suffix used on tmpfiles
120 $default_output_stack_level = 0; # used by attach_default_output, etc.
121 $default_input_stack_level = 0; # used by attach_default_input, etc.
122 $cwd = "."; # don't we wish we knew
123 $cwdslash = ""; # $cwd . $pathsep, but "" rather than "./"
125 &get_osname
; # sets $osname, $vos, $pathsep, and $short_filenames
127 &set_defaults
; # suite-defined
129 &parse_command_line
(@ARGV);
131 print "OS name = `$osname'\n" if $debug;
133 $workpath = "$cwdslash$workdir";
134 $scriptpath = "$cwdslash$scriptdir";
136 &set_more_defaults
; # suite-defined
142 print "Clearing $workpath...\n";
143 &remove_directory_tree
("$workpath/")
144 || &error
("Couldn't wipe out $workpath\n");
148 mkdir ($workpath, 0777) || &error
("Couldn't mkdir $workpath: $!\n");
153 &error
("Failed to find $scriptpath containing perl test scripts.\n");
158 print "Making work dirs...\n";
159 foreach $test (@TESTS)
161 if ($test =~ /^([^\/]+)\
//)
164 push (@rmdirs, $dir);
166 || mkdir ("$workpath/$dir", 0777)
167 || &error
("Couldn't mkdir $workpath/$dir: $!\n");
173 print "Finding tests...\n";
174 opendir (SCRIPTDIR
, $scriptpath)
175 || &error
("Couldn't opendir $scriptpath: $!\n");
176 @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR
) );
177 closedir (SCRIPTDIR
);
180 next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d
"$scriptpath/$dir");
181 push (@rmdirs, $dir);
182 mkdir ("$workpath/$dir", 0777)
183 || &error
("Couldn't mkdir $workpath/$dir: $!\n");
184 opendir (SCRIPTDIR
, "$scriptpath/$dir")
185 || &error
("Couldn't opendir $scriptpath/$dir: $!\n");
186 @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR
) );
187 closedir (SCRIPTDIR
);
188 foreach $test (@files)
191 push (@TESTS, "$dir/$test");
198 &error
("\nNo tests in $scriptpath, and none were specified.\n");
205 foreach $dir (@rmdirs)
207 rmdir ("$workpath/$dir");
212 $categories_failed = $categories_run - $categories_passed;
213 $total_tests_failed = $total_tests_run - $total_tests_passed;
215 if ($total_tests_failed)
217 print "\n$total_tests_failed Test";
218 print "s" unless $total_tests_failed == 1;
219 print " in $categories_failed Categor";
220 print ($categories_failed == 1 ?
"y" : "ies");
221 print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n";
226 print "\n$total_tests_passed Test";
227 print "s" unless $total_tests_passed == 1;
228 print " in $categories_passed Categor";
229 print ($categories_passed == 1 ?
"y" : "ies");
230 print " Complete ... No Failures :-)\n\n";
237 # Set up an initial value. In perl5 we can do it the easy way.
239 $osname = defined($^O
) ?
$^O
: '';
241 # See if the filesystem supports long file names with multiple
243 $short_filenames = 0;
244 (open (TOUCHFD
, "> fancy.file.name") && close (TOUCHFD
))
245 || ($short_filenames = 1);
246 unlink ("fancy.file.name") || ($short_filenames = 1);
248 if (! $short_filenames) {
249 # Thanks go to meyering@cs.utexas.edu (Jim Meyering) for suggesting a
250 # better way of doing this. (We used to test for existence of a /mnt
251 # dir, but that apparently fails on an SGI Indigo (whatever that is).)
252 # Because perl on VOS translates /'s to >'s, we need to test for
253 # VOSness rather than testing for Unixness (ie, try > instead of /).
255 mkdir (".ostest", 0777) || &error
("Couldn't create .ostest: $!\n", 1);
256 open (TOUCHFD
, "> .ostest>ick") && close (TOUCHFD
);
257 chdir (".ostest") || &error
("Couldn't chdir to .ostest: $!\n", 1);
260 if (! $short_filenames && -f
"ick")
268 # the following is regrettably knarly, but it seems to be the only way
269 # to not get ugly error messages if uname can't be found.
270 # Hmmm, BSD/OS 2.0's uname -a is excessively verbose. Let's try it
271 # with switches first.
272 eval "chop (\$osname = `sh -c 'uname -nmsr 2>&1'`)";
273 if ($osname =~ /not found/i)
275 $osname = "(something unixy with no uname)";
277 elsif ($@
ne "" || $?
)
279 eval "chop (\$osname = `sh -c 'uname -a 2>&1'`)";
282 $osname = "(something unixy)";
289 if (! $short_filenames) {
290 chdir ("..") || &error
("Couldn't chdir to ..: $!\n", 1);
291 unlink (".ostest>ick");
292 rmdir (".ostest") || &error
("Couldn't rmdir .ostest: $!\n", 1);
296 sub parse_command_line
300 # use @ARGV if no args were passed in
307 # look at each option; if we don't recognize it, maybe the suite-specific
308 # command line parsing code will...
312 $option = shift @argv;
313 if ($option =~ /^-debug$/i)
315 print "\nDEBUG ON\n";
318 elsif ($option =~ /^-usage$/i)
323 elsif ($option =~ /^-(h|help)$/i)
328 elsif ($option =~ /^-profile$/i)
332 elsif ($option =~ /^-verbose$/i)
336 elsif ($option =~ /^-detail$/i)
341 elsif ($option =~ /^-keep$/i)
345 elsif (&valid_option
($option))
347 # The suite-defined subroutine takes care of the option
349 elsif ($option =~ /^-/)
351 print "Invalid option: $option\n";
355 else # must be the name of a test
357 $option =~ s/\.pl$//;
358 push(@TESTS,$option);
365 local($num) = shift @_;
382 local($width, $string) = @_;
385 if (length ($string))
387 $pad = " " x
( ($width - length ($string) + 1) / 2);
398 $info = "Running tests for $testee on $osname\n"; # $testee is suite-defined
399 $len = &max
(length ($line), length ($testee_version),
400 length ($banner_info), 73) + 5;
401 $line = ("-" x
$len) . "\n";
407 &print_centered
($len, $line);
408 &print_centered
($len, $info);
409 &print_centered
($len, $testee_version); # suite-defined
410 &print_centered
($len, $banner_info); # suite-defined
411 &print_centered
($len, $line);
419 foreach $testname (sort @TESTS)
422 $suite_passed = 1; # reset by test on failure
423 $num_of_logfiles = 0;
424 $num_of_tmpfiles = 0;
427 $old_makefile = undef;
428 $testname =~ s/^$scriptpath$pathsep//;
429 $perl_testname = "$scriptpath$pathsep$testname";
430 $testname =~ s/(\.pl|\.perl)$//;
431 $testpath = "$workpath$pathsep$testname";
432 # Leave enough space in the extensions to append a number, even
433 # though it needs to fit into 8+3 limits.
434 if ($short_filenames) {
447 $log_filename = "$testpath.$logext";
448 $diff_filename = "$testpath.$diffext";
449 $base_filename = "$testpath.$baseext";
450 $run_filename = "$testpath.$runext";
451 $tmp_filename = "$testpath.$tmpfilesuffix";
453 &setup_for_test
; # suite-defined
455 $output = "........................................................ ";
457 substr($output,0,length($testname)) = "$testname ";
461 # Run the actual test!
465 $code = do $perl_testname;
467 $total_tests_run += $tests_run;
468 $total_tests_passed += $tests_passed;
475 warn "\n*** Test died ($testname): $@\n";
477 warn "\n*** Couldn't run $perl_testname\n";
480 elsif ($code == -1) {
483 elsif ($code != 1 && $code != -1) {
485 warn "\n*** Test returned $code\n";
489 ++$categories_passed;
490 $status = "ok ($tests_passed passed)";
491 for ($i = $num_of_tmpfiles; $i; $i--)
493 &rmfiles
($tmp_filename . &num_suffix
($i) );
496 for ($i = $num_of_logfiles ?
$num_of_logfiles : 1; $i; $i--)
498 &rmfiles
($log_filename . &num_suffix
($i) );
499 &rmfiles
($base_filename . &num_suffix
($i) );
502 elsif (!defined $code || $code > 0) {
503 $status = "FAILED ($tests_passed/$tests_run passed)";
510 # If the verbose option has been specified, then a short description
511 # of each test is printed before displaying the results of each test
512 # describing WHAT is being tested.
518 print "\nWHAT IS BEING TESTED\n";
519 print "--------------------";
521 print "\n\n$description\n\n";
524 # If the detail option has been specified, then the details of HOW
525 # the test is testing what it says it is testing in the verbose output
526 # will be displayed here before the results of the test are displayed.
530 print "\nHOW IT IS TESTED\n";
531 print "----------------";
532 print "\n\n$details\n\n";
539 # If the keep flag is not set, this subroutine deletes all filenames that
548 return (unlink @files);
554 sub print_standard_usage
556 local($plname,@moreusage) = @_;
559 print "usage:\t$plname [testname] [-verbose] [-detail] [-keep]\n";
560 print "\t\t\t[-profile] [-usage] [-help] [-debug]\n";
561 foreach (@moreusage) {
566 sub print_standard_help
568 local(@morehelp) = @_;
573 $line = "Test Driver For $testee";
575 $line = "=" x
length ($line);
581 . "${t}You may, if you wish, run only ONE test if you know the name\n"
582 . "${t}of that test and specify this name anywhere on the command\n"
583 . "${t}line. Otherwise ALL existing tests in the scripts directory\n"
584 . "${t}will be run.\n"
586 . "${t}If this option is given, a description of every test is\n"
587 . "${t}displayed before the test is run. (Not all tests may have\n"
588 . "${t}descriptions at this time)\n"
590 . "${t}If this option is given, a detailed description of every\n"
591 . "${t}test is displayed before the test is run. (Not all tests\n"
592 . "${t}have descriptions at this time)\n"
594 . "${t}If this option is given, then the profile file\n"
595 . "${t}is added to other profiles every time $testee is run.\n"
596 . "${t}This option only works on VOS at this time.\n"
598 . "${t}You may give this option if you DO NOT want ANY\n"
599 . "${t}of the files generated by the tests to be deleted. \n"
600 . "${t}Without this option, all files generated by the test will\n"
601 . "${t}be deleted IF THE TEST PASSES.\n"
603 . "${t}Use this option if you would like to see all of the system\n"
604 . "${t}calls issued and their return status while running the tests\n"
605 . "${t}This can be helpful if you're having a problem adding a test\n"
606 . "${t}to the suite, or if the test fails!\n";
608 foreach $line (@morehelp)
611 if (substr ($tline, 0, 1) eq "\t")
613 substr ($tline, 0, 1) = $t;
619 #######################################################################
620 ########### Generic Test Driver Subroutines ###########
621 #######################################################################
630 $depth = defined ($_[0]) ?
$_[0] : 1;
631 ($package, $filename, $linenum) = caller ($depth + 1);
632 return "$filename: $linenum";
637 local($message) = $_[0];
638 local($caller) = &get_caller
(1);
642 $caller = &get_caller
($_[1] + 1) . " -> $caller";
645 die "$caller: $message";
650 local($answer,$logfile) = @_;
651 local($slurp, $answer_matched) = ('', 0);
653 print "Comparing Output ........ " if $debug;
655 $slurp = &read_file_into_string
($logfile);
657 # For make, get rid of any time skew error before comparing--too bad this
658 # has to go into the "generic" driver code :-/
659 $slurp =~ s/^.*modification time .*in the future.*\n//gm;
660 $slurp =~ s/^.*Clock skew detected.*\n//gm;
664 if ($slurp eq $answer) {
667 # See if it is a slash or CRLF problem
668 local ($answer_mod, $slurp_mod) = ($answer, $slurp);
670 $answer_mod =~ tr
,\\,/,;
671 $answer_mod =~ s
,\r\n,\n,gs
;
673 $slurp_mod =~ tr
,\\,/,;
674 $slurp_mod =~ s
,\r\n,\n,gs
;
676 $answer_matched = ($slurp_mod eq $answer_mod);
678 # If it still doesn't match, see if the answer might be a regex.
679 if (!$answer_matched && $answer =~ m
,^/(.+)/$,) {
680 $answer_matched = ($slurp =~ /$1/);
681 if (!$answer_matched && $answer_mod =~ m
,^/(.+)/$,) {
682 $answer_matched = ($slurp_mod =~ /$1/);
687 if ($answer_matched && $test_passed)
689 print "ok\n" if $debug;
694 if (! $answer_matched) {
695 print "DIFFERENT OUTPUT\n" if $debug;
697 &create_file
(&get_basefile
, $answer);
698 &create_file
(&get_runfile
, $command_string);
700 print "\nCreating Difference File ...\n" if $debug;
702 # Create the difference file
704 local($command) = "diff -c " . &get_basefile
. " " . $logfile;
705 &run_command_with_output
(&get_difffile
,$command);
714 sub read_file_into_string
716 local($filename) = @_;
717 local($oldslash) = $/;
721 open (RFISFILE
, $filename) || return "";
722 local ($slurp) = <RFISFILE
>;
730 sub attach_default_output
732 local ($filename) = @_;
737 $code = system "++attach_default_output_hack $filename";
738 $code == -2 || &error
("adoh death\n", 1);
742 open ("SAVEDOS" . $default_output_stack_level . "out", ">&STDOUT")
743 || &error
("ado: $! duping STDOUT\n", 1);
744 open ("SAVEDOS" . $default_output_stack_level . "err", ">&STDERR")
745 || &error
("ado: $! duping STDERR\n", 1);
747 open (STDOUT
, "> " . $filename)
748 || &error
("ado: $filename: $!\n", 1);
749 open (STDERR
, ">&STDOUT")
750 || &error
("ado: $filename: $!\n", 1);
752 $default_output_stack_level++;
755 # close the current stdout/stderr, and restore the previous ones from
758 sub detach_default_output
764 $code = system "++detach_default_output_hack";
765 $code == -2 || &error
("ddoh death\n", 1);
769 if (--$default_output_stack_level < 0)
771 &error
("default output stack has flown under!\n", 1);
777 open (STDOUT
, ">&SAVEDOS" . $default_output_stack_level . "out")
778 || &error
("ddo: $! duping STDOUT\n", 1);
779 open (STDERR
, ">&SAVEDOS" . $default_output_stack_level . "err")
780 || &error
("ddo: $! duping STDERR\n", 1);
782 close ("SAVEDOS" . $default_output_stack_level . "out")
783 || &error
("ddo: $! closing SCSDOSout\n", 1);
784 close ("SAVEDOS" . $default_output_stack_level . "err")
785 || &error
("ddo: $! closing SAVEDOSerr\n", 1);
788 # This runs a command without any debugging info.
793 # We reset this before every invocation. On Windows I think there is only
794 # one environment, not one per process, so I think that variables set in
795 # test scripts might leak into subsequent tests if this isn't reset--???
799 local $SIG{ALRM
} = sub { die "timeout\n"; };
805 # The eval failed. If it wasn't SIGALRM then die.
806 $@
eq "timeout\n" or die;
808 # Timed out. Resend the alarm to our process group to kill the children.
809 $SIG{ALRM
} = 'IGNORE';
817 # run one command (passed as a list of arg 0 - n), returning 0 on success
818 # and nonzero on failure.
822 print "\nrun_command: @_\n" if $debug;
823 my $code = _run_command
(@_);
824 print "run_command returned $code.\n" if $debug;
829 # run one command (passed as a list of arg 0 - n, with arg 0 being the
830 # second arg to this routine), returning 0 on success and non-zero on failure.
831 # The first arg to this routine is a filename to connect to the stdout
832 # & stderr of the child process.
834 sub run_command_with_output
836 my $filename = shift;
838 print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
839 &attach_default_output
($filename);
840 my $code = _run_command
(@_);
841 &detach_default_output
;
842 print "run_command_with_output returned $code.\n" if $debug;
847 # performs the equivalent of an "rm -rf" on the first argument. Like
848 # rm, if the path ends in /, leaves the (now empty) directory; otherwise
851 sub remove_directory_tree
853 local ($targetdir) = @_;
854 local ($nuketop) = 1;
857 $ch = substr ($targetdir, length ($targetdir) - 1);
858 if ($ch eq "/" || $ch eq $pathsep)
860 $targetdir = substr ($targetdir, 0, length ($targetdir) - 1);
869 &remove_directory_tree_inner
("RDT00", $targetdir) || return 0;
872 rmdir $targetdir || return 0;
878 sub remove_directory_tree_inner
880 local ($dirhandle, $targetdir) = @_;
882 local ($subdirhandle);
884 opendir ($dirhandle, $targetdir) || return 0;
885 $subdirhandle = $dirhandle;
887 while ($object = readdir ($dirhandle))
889 if ($object =~ /^(\.\.?|CVS|RCS)$/)
894 $object = "$targetdir$pathsep$object";
897 if (-d _
&& &remove_directory_tree_inner
($subdirhandle, $object))
899 rmdir $object || return 0;
903 unlink $object || return 0;
906 closedir ($dirhandle);
910 # We used to use this behavior for this function:
914 # local (@filenames) = @_;
915 # local ($now) = time;
918 # foreach $file (@filenames)
920 # utime ($now, $now, $file)
921 # || (open (TOUCHFD, ">> $file") && close (TOUCHFD))
922 # || &error ("Couldn't touch $file: $!\n", 1);
927 # But this behaves badly on networked filesystems where the time is
928 # skewed, because it sets the time of the file based on the _local_
929 # host. Normally when you modify a file, it's the _remote_ host that
930 # determines the modtime, based on _its_ clock. So, instead, now we open
931 # the file and write something into it to force the remote host to set
932 # the modtime correctly according to its clock.
940 (open(T
, ">> $file") && print(T
"\n") && close(T
))
941 || &error
("Couldn't touch $file: $!\n", 1);
945 # Touch with a time offset. To DTRT, call touch() then use stat() to get the
946 # access/mod time for each file and apply the offset.
950 local ($off) = shift;
955 local (@s) = stat($_[0]);
957 utime($s[8]+$off, $s[9]+$off, @_);
960 # open a file, write some stuff to it, and close it.
964 local ($filename, @lines) = @_;
966 open (CF
, "> $filename") || &error
("Couldn't open $filename: $!\n", 1);
967 foreach $line (@lines)
974 # create a directory tree described by an associative array, wherein each
975 # key is a relative pathname (using slashes) and its associated value is
977 # DIR indicates a directory
978 # FILE:contents indicates a file, which should contain contents +\n
979 # LINK:target indicates a symlink, pointing to $basedir/target
980 # The first argument is the dir under which the structure will be created
981 # (the dir will be made and/or cleaned if necessary); the second argument
982 # is the associative array.
986 local ($basedir, %dirtree) = @_;
989 &remove_directory_tree
("$basedir");
990 mkdir ($basedir, 0777) || &error
("Couldn't mkdir $basedir: $!\n", 1);
992 foreach $path (sort keys (%dirtree))
994 if ($dirtree {$path} =~ /^DIR$/)
996 mkdir ("$basedir/$path", 0777)
997 || &error
("Couldn't mkdir $basedir/$path: $!\n", 1);
999 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1001 &create_file
("$basedir/$path", $1 . "\n");
1003 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1005 symlink ("$basedir/$1", "$basedir/$path")
1006 || &error
("Couldn't symlink $basedir/$path -> $basedir/$1: $!\n", 1);
1010 &error
("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1013 if ($just_setup_tree)
1015 die "Tree is setup...\n";
1019 # compare a directory tree with an associative array in the format used
1020 # by create_dir_tree, above.
1021 # The first argument is the dir under which the structure should be found;
1022 # the second argument is the associative array.
1024 sub compare_dir_tree
1026 local ($basedir, %dirtree) = @_;
1032 local ($fulltarget);
1037 opendir (DIR
, $basedir) || &error
("Couldn't open $basedir: $!\n", 1);
1038 @allfiles = grep (!/^(\.\.?|CVS|RCS)$/, readdir (DIR
) );
1042 print "dirtree: (%dirtree)\n$basedir: (@allfiles)\n";
1045 foreach $path (sort keys (%dirtree))
1049 print "Checking $path ($dirtree{$path}).\n";
1053 foreach $i (0 .. $#allfiles)
1055 if ($allfiles[$i] eq $path)
1057 splice (@allfiles, $i, 1); # delete it
1060 print " Zapped $path; files now (@allfiles).\n";
1062 lstat ("$basedir/$path");
1070 print "compare_dir_tree: $path does not exist.\n";
1075 if ($dirtree {$path} =~ /^DIR$/)
1077 if (-d _
&& opendir (DIR
, "$basedir/$path") )
1079 @files = readdir (DIR
);
1081 @files = grep (!/^(\.\.?|CVS|RCS)$/ && ($_ = "$path/$_"), @files);
1082 push (@allfiles, @files);
1085 print " Read in $path; new files (@files).\n";
1090 print "compare_dir_tree: $path is not a dir.\n";
1094 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1098 print "compare_dir_tree: $path is not a file.\n";
1105 $contents = &read_file_into_string
("$basedir/$path");
1106 if ($contents ne "$1\n")
1108 print "compare_dir_tree: $path contains wrong stuff."
1109 . " Is:\n$contentsShould be:\n$1\n";
1114 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1119 print "compare_dir_tree: $path is not a link.\n";
1124 $contents = readlink ("$basedir/$path");
1125 $contents =~ tr/>/\//;
1126 $fulltarget = "$basedir/$target";
1127 $fulltarget =~ tr/>/\//;
1128 if (!($contents =~ /$fulltarget$/))
1132 $target = $fulltarget;
1134 print "compare_dir_tree: $path should be link to $target, "
1135 . "not $contents.\n";
1141 &error
("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1147 print "leftovers: (@allfiles).\n";
1150 foreach $file (@allfiles)
1152 print "compare_dir_tree: $file should not exist.\n";
1159 # this subroutine generates the numeric suffix used to keep tmp filenames,
1160 # log filenames, etc., unique. If the number passed in is 1, then a null
1161 # string is returned; otherwise, we return ".n", where n + 1 is the number
1169 return "$extext$num";
1175 # This subroutine returns a log filename with a number appended to
1176 # the end corresponding to how many logfiles have been created in the
1177 # current running test. An optional parameter may be passed (0 or 1).
1178 # If a 1 is passed, then it does NOT increment the logfile counter
1179 # and returns the name of the latest logfile. If either no parameter
1180 # is passed at all or a 0 is passed, then the logfile counter is
1181 # incremented and the new name is returned.
1185 local($no_increment) = @_;
1187 $num_of_logfiles += !$no_increment;
1189 return ($log_filename . &num_suffix
($num_of_logfiles));
1192 # This subroutine returns a base (answer) filename with a number
1193 # appended to the end corresponding to how many logfiles (and thus
1194 # base files) have been created in the current running test.
1195 # NO PARAMETERS ARE PASSED TO THIS SUBROUTINE.
1199 return ($base_filename . &num_suffix
($num_of_logfiles));
1202 # This subroutine returns a difference filename with a number appended
1203 # to the end corresponding to how many logfiles (and thus diff files)
1204 # have been created in the current running test.
1208 return ($diff_filename . &num_suffix
($num_of_logfiles));
1211 # This subroutine returns a command filename with a number appended
1212 # to the end corresponding to how many logfiles (and thus command files)
1213 # have been created in the current running test.
1217 return ($run_filename . &num_suffix
($num_of_logfiles));
1220 # just like logfile, only a generic tmp filename for use by the test.
1221 # they are automatically cleaned up unless -keep was used, or the test fails.
1222 # Pass an argument of 1 to return the same filename as the previous call.
1226 local($no_increment) = @_;
1228 $num_of_tmpfiles += !$no_increment;
1230 return ($tmp_filename . &num_suffix
($num_of_tmpfiles));