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, 2010, 2011, 2012 Free
10 # Software Foundation, Inc.
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.31 2012/01/16 02:29:25 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.
60 # %makeENV is the cleaned-out environment.
63 # %extraENV are any extra environment variables the tests might want to set.
64 # These are RESET AFTER EVERY TEST!
67 # %origENV is the caller's original environment
72 # We used to say "%ENV = ();" but this doesn't work in Perl 5.000
73 # through Perl 5.004. It was fixed in Perl 5.004_01, but we don't
74 # want to require that here, so just delete each one individually.
75 foreach $v (keys %ENV) {
80 foreach $v (keys %extraENV) {
81 $ENV{$v} = $extraENV{$v};
88 # Pull in benign variables from the user's environment
90 foreach (# UNIX-specific things
91 'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
94 # Windows NT-specific stuff
96 # DJGPP-specific stuff
97 'DJDIR', 'DJGPP', 'SHELL', 'COMSPEC', 'HOSTNAME', 'LFN',
98 'FNCASE', '387', 'EMU387', 'GROUP'
100 $makeENV{$_} = $ENV{$_} if $ENV{$_};
103 # Make sure our compares are not foiled by locale differences
105 $makeENV{LC_ALL
} = 'C';
107 # Replace the environment with the new one
113 $| = 1; # unbuffered output
115 $debug = 0; # debug flag
116 $profile = 0; # profiling flag
117 $verbose = 0; # verbose mode flag
118 $detail = 0; # detailed verbosity
119 $keep = 0; # keep temp files around
120 $workdir = "work"; # The directory where the test will start running
121 $scriptdir = "scripts"; # The directory where we find the test scripts
122 $tmpfilesuffix = "t"; # the suffix used on tmpfiles
123 $default_output_stack_level = 0; # used by attach_default_output, etc.
124 $default_input_stack_level = 0; # used by attach_default_input, etc.
125 $cwd = "."; # don't we wish we knew
126 $cwdslash = ""; # $cwd . $pathsep, but "" rather than "./"
128 &get_osname
; # sets $osname, $vos, $pathsep, and $short_filenames
130 &set_defaults
; # suite-defined
132 &parse_command_line
(@ARGV);
134 print "OS name = `$osname'\n" if $debug;
136 $workpath = "$cwdslash$workdir";
137 $scriptpath = "$cwdslash$scriptdir";
139 &set_more_defaults
; # suite-defined
145 print "Clearing $workpath...\n";
146 &remove_directory_tree
("$workpath/")
147 || &error
("Couldn't wipe out $workpath\n");
151 mkdir ($workpath, 0777) || &error
("Couldn't mkdir $workpath: $!\n");
156 &error
("Failed to find $scriptpath containing perl test scripts.\n");
161 print "Making work dirs...\n";
162 foreach $test (@TESTS)
164 if ($test =~ /^([^\/]+)\
//)
167 push (@rmdirs, $dir);
169 || mkdir ("$workpath/$dir", 0777)
170 || &error
("Couldn't mkdir $workpath/$dir: $!\n");
176 print "Finding tests...\n";
177 opendir (SCRIPTDIR
, $scriptpath)
178 || &error
("Couldn't opendir $scriptpath: $!\n");
179 @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR
) );
180 closedir (SCRIPTDIR
);
183 next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d
"$scriptpath/$dir");
184 push (@rmdirs, $dir);
185 mkdir ("$workpath/$dir", 0777)
186 || &error
("Couldn't mkdir $workpath/$dir: $!\n");
187 opendir (SCRIPTDIR
, "$scriptpath/$dir")
188 || &error
("Couldn't opendir $scriptpath/$dir: $!\n");
189 @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR
) );
190 closedir (SCRIPTDIR
);
191 foreach $test (@files)
194 push (@TESTS, "$dir/$test");
201 &error
("\nNo tests in $scriptpath, and none were specified.\n");
208 foreach $dir (@rmdirs)
210 rmdir ("$workpath/$dir");
215 $categories_failed = $categories_run - $categories_passed;
216 $total_tests_failed = $total_tests_run - $total_tests_passed;
218 if ($total_tests_failed)
220 print "\n$total_tests_failed Test";
221 print "s" unless $total_tests_failed == 1;
222 print " in $categories_failed Categor";
223 print ($categories_failed == 1 ?
"y" : "ies");
224 print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n";
229 print "\n$total_tests_passed Test";
230 print "s" unless $total_tests_passed == 1;
231 print " in $categories_passed Categor";
232 print ($categories_passed == 1 ?
"y" : "ies");
233 print " Complete ... No Failures :-)\n\n";
240 # Set up an initial value. In perl5 we can do it the easy way.
241 $osname = defined($^O
) ?
$^O
: '';
243 # Find a path to Perl
245 # See if the filesystem supports long file names with multiple
247 $short_filenames = 0;
248 (open (TOUCHFD
, "> fancy.file.name") && close (TOUCHFD
))
249 || ($short_filenames = 1);
250 unlink ("fancy.file.name") || ($short_filenames = 1);
252 if (! $short_filenames) {
253 # Thanks go to meyering@cs.utexas.edu (Jim Meyering) for suggesting a
254 # better way of doing this. (We used to test for existence of a /mnt
255 # dir, but that apparently fails on an SGI Indigo (whatever that is).)
256 # Because perl on VOS translates /'s to >'s, we need to test for
257 # VOSness rather than testing for Unixness (ie, try > instead of /).
259 mkdir (".ostest", 0777) || &error
("Couldn't create .ostest: $!\n", 1);
260 open (TOUCHFD
, "> .ostest>ick") && close (TOUCHFD
);
261 chdir (".ostest") || &error
("Couldn't chdir to .ostest: $!\n", 1);
264 if (! $short_filenames && -f
"ick")
272 # the following is regrettably knarly, but it seems to be the only way
273 # to not get ugly error messages if uname can't be found.
274 # Hmmm, BSD/OS 2.0's uname -a is excessively verbose. Let's try it
275 # with switches first.
276 eval "chop (\$osname = `sh -c 'uname -nmsr 2>&1'`)";
277 if ($osname =~ /not found/i)
279 $osname = "(something posixy with no uname)";
281 elsif ($@
ne "" || $?
)
283 eval "chop (\$osname = `sh -c 'uname -a 2>&1'`)";
286 $osname = "(something posixy)";
293 if (! $short_filenames) {
294 chdir ("..") || &error
("Couldn't chdir to ..: $!\n", 1);
295 unlink (".ostest>ick");
296 rmdir (".ostest") || &error
("Couldn't rmdir .ostest: $!\n", 1);
300 sub parse_command_line
304 # use @ARGV if no args were passed in
311 # look at each option; if we don't recognize it, maybe the suite-specific
312 # command line parsing code will...
316 $option = shift @argv;
317 if ($option =~ /^-debug$/i)
319 print "\nDEBUG ON\n";
322 elsif ($option =~ /^-usage$/i)
327 elsif ($option =~ /^-(h|help)$/i)
332 elsif ($option =~ /^-profile$/i)
336 elsif ($option =~ /^-verbose$/i)
340 elsif ($option =~ /^-detail$/i)
345 elsif ($option =~ /^-keep$/i)
349 elsif (&valid_option
($option))
351 # The suite-defined subroutine takes care of the option
353 elsif ($option =~ /^-/)
355 print "Invalid option: $option\n";
359 else # must be the name of a test
361 $option =~ s/\.pl$//;
362 push(@TESTS,$option);
369 local($num) = shift @_;
386 local($width, $string) = @_;
389 if (length ($string))
391 $pad = " " x
( ($width - length ($string) + 1) / 2);
402 $info = "Running tests for $testee on $osname\n"; # $testee is suite-defined
403 $len = &max
(length ($line), length ($testee_version),
404 length ($banner_info), 73) + 5;
405 $line = ("-" x
$len) . "\n";
411 &print_centered
($len, $line);
412 &print_centered
($len, $info);
413 &print_centered
($len, $testee_version); # suite-defined
414 &print_centered
($len, $banner_info); # suite-defined
415 &print_centered
($len, $line);
423 foreach $testname (sort @TESTS)
426 $suite_passed = 1; # reset by test on failure
427 $num_of_logfiles = 0;
428 $num_of_tmpfiles = 0;
431 $old_makefile = undef;
432 $testname =~ s/^$scriptpath$pathsep//;
433 $perl_testname = "$scriptpath$pathsep$testname";
434 $testname =~ s/(\.pl|\.perl)$//;
435 $testpath = "$workpath$pathsep$testname";
436 # Leave enough space in the extensions to append a number, even
437 # though it needs to fit into 8+3 limits.
438 if ($short_filenames) {
451 $log_filename = "$testpath.$logext";
452 $diff_filename = "$testpath.$diffext";
453 $base_filename = "$testpath.$baseext";
454 $run_filename = "$testpath.$runext";
455 $tmp_filename = "$testpath.$tmpfilesuffix";
457 &setup_for_test
; # suite-defined
459 $output = "........................................................ ";
461 substr($output,0,length($testname)) = "$testname ";
465 # Run the actual test!
469 $code = do $perl_testname;
471 $total_tests_run += $tests_run;
472 $total_tests_passed += $tests_passed;
479 warn "\n*** Test died ($testname): $@\n";
481 warn "\n*** Couldn't run $perl_testname\n";
484 elsif ($code == -1) {
487 elsif ($code != 1 && $code != -1) {
489 warn "\n*** Test returned $code\n";
493 ++$categories_passed;
494 $status = "ok ($tests_passed passed)";
495 for ($i = $num_of_tmpfiles; $i; $i--)
497 &rmfiles
($tmp_filename . &num_suffix
($i) );
500 for ($i = $num_of_logfiles ?
$num_of_logfiles : 1; $i; $i--)
502 &rmfiles
($log_filename . &num_suffix
($i) );
503 &rmfiles
($base_filename . &num_suffix
($i) );
506 elsif (!defined $code || $code > 0) {
507 $status = "FAILED ($tests_passed/$tests_run passed)";
514 # If the verbose option has been specified, then a short description
515 # of each test is printed before displaying the results of each test
516 # describing WHAT is being tested.
522 print "\nWHAT IS BEING TESTED\n";
523 print "--------------------";
525 print "\n\n$description\n\n";
528 # If the detail option has been specified, then the details of HOW
529 # the test is testing what it says it is testing in the verbose output
530 # will be displayed here before the results of the test are displayed.
534 print "\nHOW IT IS TESTED\n";
535 print "----------------";
536 print "\n\n$details\n\n";
543 # If the keep flag is not set, this subroutine deletes all filenames that
552 return (unlink @files);
558 sub print_standard_usage
560 local($plname,@moreusage) = @_;
563 print "usage:\t$plname [testname] [-verbose] [-detail] [-keep]\n";
564 print "\t\t\t[-profile] [-usage] [-help] [-debug]\n";
565 foreach (@moreusage) {
570 sub print_standard_help
572 local(@morehelp) = @_;
577 $line = "Test Driver For $testee";
579 $line = "=" x
length ($line);
585 . "${t}You may, if you wish, run only ONE test if you know the name\n"
586 . "${t}of that test and specify this name anywhere on the command\n"
587 . "${t}line. Otherwise ALL existing tests in the scripts directory\n"
588 . "${t}will be run.\n"
590 . "${t}If this option is given, a description of every test is\n"
591 . "${t}displayed before the test is run. (Not all tests may have\n"
592 . "${t}descriptions at this time)\n"
594 . "${t}If this option is given, a detailed description of every\n"
595 . "${t}test is displayed before the test is run. (Not all tests\n"
596 . "${t}have descriptions at this time)\n"
598 . "${t}If this option is given, then the profile file\n"
599 . "${t}is added to other profiles every time $testee is run.\n"
600 . "${t}This option only works on VOS at this time.\n"
602 . "${t}You may give this option if you DO NOT want ANY\n"
603 . "${t}of the files generated by the tests to be deleted. \n"
604 . "${t}Without this option, all files generated by the test will\n"
605 . "${t}be deleted IF THE TEST PASSES.\n"
607 . "${t}Use this option if you would like to see all of the system\n"
608 . "${t}calls issued and their return status while running the tests\n"
609 . "${t}This can be helpful if you're having a problem adding a test\n"
610 . "${t}to the suite, or if the test fails!\n";
612 foreach $line (@morehelp)
615 if (substr ($tline, 0, 1) eq "\t")
617 substr ($tline, 0, 1) = $t;
623 #######################################################################
624 ########### Generic Test Driver Subroutines ###########
625 #######################################################################
634 $depth = defined ($_[0]) ?
$_[0] : 1;
635 ($package, $filename, $linenum) = caller ($depth + 1);
636 return "$filename: $linenum";
641 local($message) = $_[0];
642 local($caller) = &get_caller
(1);
646 $caller = &get_caller
($_[1] + 1) . " -> $caller";
649 die "$caller: $message";
654 local($answer,$logfile) = @_;
655 local($slurp, $answer_matched) = ('', 0);
657 print "Comparing Output ........ " if $debug;
659 $slurp = &read_file_into_string
($logfile);
661 # For make, get rid of any time skew error before comparing--too bad this
662 # has to go into the "generic" driver code :-/
663 $slurp =~ s/^.*modification time .*in the future.*\n//gm;
664 $slurp =~ s/^.*Clock skew detected.*\n//gm;
668 if ($slurp eq $answer) {
671 # See if it is a slash or CRLF problem
672 local ($answer_mod, $slurp_mod) = ($answer, $slurp);
674 $answer_mod =~ tr
,\\,/,;
675 $answer_mod =~ s
,\r\n,\n,gs
;
677 $slurp_mod =~ tr
,\\,/,;
678 $slurp_mod =~ s
,\r\n,\n,gs
;
680 $answer_matched = ($slurp_mod eq $answer_mod);
682 # If it still doesn't match, see if the answer might be a regex.
683 if (!$answer_matched && $answer =~ m
,^/(.+)/$,) {
684 $answer_matched = ($slurp =~ /$1/);
685 if (!$answer_matched && $answer_mod =~ m
,^/(.+)/$,) {
686 $answer_matched = ($slurp_mod =~ /$1/);
691 if ($answer_matched && $test_passed)
693 print "ok\n" if $debug;
698 if (! $answer_matched) {
699 print "DIFFERENT OUTPUT\n" if $debug;
701 &create_file
(&get_basefile
, $answer);
702 &create_file
(&get_runfile
, $command_string);
704 print "\nCreating Difference File ...\n" if $debug;
706 # Create the difference file
708 local($command) = "diff -c " . &get_basefile
. " " . $logfile;
709 &run_command_with_output
(&get_difffile
,$command);
718 sub read_file_into_string
720 local($filename) = @_;
721 local($oldslash) = $/;
725 open (RFISFILE
, $filename) || return "";
726 local ($slurp) = <RFISFILE
>;
734 sub attach_default_output
736 local ($filename) = @_;
741 $code = system "++attach_default_output_hack $filename";
742 $code == -2 || &error
("adoh death\n", 1);
746 open ("SAVEDOS" . $default_output_stack_level . "out", ">&STDOUT")
747 || &error
("ado: $! duping STDOUT\n", 1);
748 open ("SAVEDOS" . $default_output_stack_level . "err", ">&STDERR")
749 || &error
("ado: $! duping STDERR\n", 1);
751 open (STDOUT
, "> " . $filename)
752 || &error
("ado: $filename: $!\n", 1);
753 open (STDERR
, ">&STDOUT")
754 || &error
("ado: $filename: $!\n", 1);
756 $default_output_stack_level++;
759 # close the current stdout/stderr, and restore the previous ones from
762 sub detach_default_output
768 $code = system "++detach_default_output_hack";
769 $code == -2 || &error
("ddoh death\n", 1);
773 if (--$default_output_stack_level < 0)
775 &error
("default output stack has flown under!\n", 1);
781 open (STDOUT
, ">&SAVEDOS" . $default_output_stack_level . "out")
782 || &error
("ddo: $! duping STDOUT\n", 1);
783 open (STDERR
, ">&SAVEDOS" . $default_output_stack_level . "err")
784 || &error
("ddo: $! duping STDERR\n", 1);
786 close ("SAVEDOS" . $default_output_stack_level . "out")
787 || &error
("ddo: $! closing SCSDOSout\n", 1);
788 close ("SAVEDOS" . $default_output_stack_level . "err")
789 || &error
("ddo: $! closing SAVEDOSerr\n", 1);
792 # This runs a command without any debugging info.
797 # We reset this before every invocation. On Windows I think there is only
798 # one environment, not one per process, so I think that variables set in
799 # test scripts might leak into subsequent tests if this isn't reset--???
803 local $SIG{ALRM
} = sub { die "timeout\n"; };
809 # The eval failed. If it wasn't SIGALRM then die.
810 $@
eq "timeout\n" or die;
812 # Timed out. Resend the alarm to our process group to kill the children.
813 $SIG{ALRM
} = 'IGNORE';
821 # run one command (passed as a list of arg 0 - n), returning 0 on success
822 # and nonzero on failure.
826 print "\nrun_command: @_\n" if $debug;
827 my $code = _run_command
(@_);
828 print "run_command returned $code.\n" if $debug;
833 # run one command (passed as a list of arg 0 - n, with arg 0 being the
834 # second arg to this routine), returning 0 on success and non-zero on failure.
835 # The first arg to this routine is a filename to connect to the stdout
836 # & stderr of the child process.
838 sub run_command_with_output
840 my $filename = shift;
842 print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
843 &attach_default_output
($filename);
844 my $code = _run_command
(@_);
845 &detach_default_output
;
846 print "run_command_with_output returned $code.\n" if $debug;
851 # performs the equivalent of an "rm -rf" on the first argument. Like
852 # rm, if the path ends in /, leaves the (now empty) directory; otherwise
855 sub remove_directory_tree
857 local ($targetdir) = @_;
858 local ($nuketop) = 1;
861 $ch = substr ($targetdir, length ($targetdir) - 1);
862 if ($ch eq "/" || $ch eq $pathsep)
864 $targetdir = substr ($targetdir, 0, length ($targetdir) - 1);
873 &remove_directory_tree_inner
("RDT00", $targetdir) || return 0;
876 rmdir $targetdir || return 0;
882 sub remove_directory_tree_inner
884 local ($dirhandle, $targetdir) = @_;
886 local ($subdirhandle);
888 opendir ($dirhandle, $targetdir) || return 0;
889 $subdirhandle = $dirhandle;
891 while ($object = readdir ($dirhandle))
893 if ($object =~ /^(\.\.?|CVS|RCS)$/)
898 $object = "$targetdir$pathsep$object";
901 if (-d _
&& &remove_directory_tree_inner
($subdirhandle, $object))
903 rmdir $object || return 0;
907 unlink $object || return 0;
910 closedir ($dirhandle);
914 # We used to use this behavior for this function:
918 # local (@filenames) = @_;
919 # local ($now) = time;
922 # foreach $file (@filenames)
924 # utime ($now, $now, $file)
925 # || (open (TOUCHFD, ">> $file") && close (TOUCHFD))
926 # || &error ("Couldn't touch $file: $!\n", 1);
931 # But this behaves badly on networked filesystems where the time is
932 # skewed, because it sets the time of the file based on the _local_
933 # host. Normally when you modify a file, it's the _remote_ host that
934 # determines the modtime, based on _its_ clock. So, instead, now we open
935 # the file and write something into it to force the remote host to set
936 # the modtime correctly according to its clock.
944 (open(T
, ">> $file") && print(T
"\n") && close(T
))
945 || &error
("Couldn't touch $file: $!\n", 1);
949 # Touch with a time offset. To DTRT, call touch() then use stat() to get the
950 # access/mod time for each file and apply the offset.
954 local ($off) = shift;
959 local (@s) = stat($_[0]);
961 utime($s[8]+$off, $s[9]+$off, @_);
964 # open a file, write some stuff to it, and close it.
968 local ($filename, @lines) = @_;
970 open (CF
, "> $filename") || &error
("Couldn't open $filename: $!\n", 1);
971 foreach $line (@lines)
978 # create a directory tree described by an associative array, wherein each
979 # key is a relative pathname (using slashes) and its associated value is
981 # DIR indicates a directory
982 # FILE:contents indicates a file, which should contain contents +\n
983 # LINK:target indicates a symlink, pointing to $basedir/target
984 # The first argument is the dir under which the structure will be created
985 # (the dir will be made and/or cleaned if necessary); the second argument
986 # is the associative array.
990 local ($basedir, %dirtree) = @_;
993 &remove_directory_tree
("$basedir");
994 mkdir ($basedir, 0777) || &error
("Couldn't mkdir $basedir: $!\n", 1);
996 foreach $path (sort keys (%dirtree))
998 if ($dirtree {$path} =~ /^DIR$/)
1000 mkdir ("$basedir/$path", 0777)
1001 || &error
("Couldn't mkdir $basedir/$path: $!\n", 1);
1003 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1005 &create_file
("$basedir/$path", $1 . "\n");
1007 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1009 symlink ("$basedir/$1", "$basedir/$path")
1010 || &error
("Couldn't symlink $basedir/$path -> $basedir/$1: $!\n", 1);
1014 &error
("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1017 if ($just_setup_tree)
1019 die "Tree is setup...\n";
1023 # compare a directory tree with an associative array in the format used
1024 # by create_dir_tree, above.
1025 # The first argument is the dir under which the structure should be found;
1026 # the second argument is the associative array.
1028 sub compare_dir_tree
1030 local ($basedir, %dirtree) = @_;
1036 local ($fulltarget);
1041 opendir (DIR
, $basedir) || &error
("Couldn't open $basedir: $!\n", 1);
1042 @allfiles = grep (!/^(\.\.?|CVS|RCS)$/, readdir (DIR
) );
1046 print "dirtree: (%dirtree)\n$basedir: (@allfiles)\n";
1049 foreach $path (sort keys (%dirtree))
1053 print "Checking $path ($dirtree{$path}).\n";
1057 foreach $i (0 .. $#allfiles)
1059 if ($allfiles[$i] eq $path)
1061 splice (@allfiles, $i, 1); # delete it
1064 print " Zapped $path; files now (@allfiles).\n";
1066 lstat ("$basedir/$path");
1074 print "compare_dir_tree: $path does not exist.\n";
1079 if ($dirtree {$path} =~ /^DIR$/)
1081 if (-d _
&& opendir (DIR
, "$basedir/$path") )
1083 @files = readdir (DIR
);
1085 @files = grep (!/^(\.\.?|CVS|RCS)$/ && ($_ = "$path/$_"), @files);
1086 push (@allfiles, @files);
1089 print " Read in $path; new files (@files).\n";
1094 print "compare_dir_tree: $path is not a dir.\n";
1098 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1102 print "compare_dir_tree: $path is not a file.\n";
1109 $contents = &read_file_into_string
("$basedir/$path");
1110 if ($contents ne "$1\n")
1112 print "compare_dir_tree: $path contains wrong stuff."
1113 . " Is:\n$contentsShould be:\n$1\n";
1118 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1123 print "compare_dir_tree: $path is not a link.\n";
1128 $contents = readlink ("$basedir/$path");
1129 $contents =~ tr/>/\//;
1130 $fulltarget = "$basedir/$target";
1131 $fulltarget =~ tr/>/\//;
1132 if (!($contents =~ /$fulltarget$/))
1136 $target = $fulltarget;
1138 print "compare_dir_tree: $path should be link to $target, "
1139 . "not $contents.\n";
1145 &error
("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1151 print "leftovers: (@allfiles).\n";
1154 foreach $file (@allfiles)
1156 print "compare_dir_tree: $file should not exist.\n";
1163 # this subroutine generates the numeric suffix used to keep tmp filenames,
1164 # log filenames, etc., unique. If the number passed in is 1, then a null
1165 # string is returned; otherwise, we return ".n", where n + 1 is the number
1173 return "$extext$num";
1179 # This subroutine returns a log filename with a number appended to
1180 # the end corresponding to how many logfiles have been created in the
1181 # current running test. An optional parameter may be passed (0 or 1).
1182 # If a 1 is passed, then it does NOT increment the logfile counter
1183 # and returns the name of the latest logfile. If either no parameter
1184 # is passed at all or a 0 is passed, then the logfile counter is
1185 # incremented and the new name is returned.
1189 local($no_increment) = @_;
1191 $num_of_logfiles += !$no_increment;
1193 return ($log_filename . &num_suffix
($num_of_logfiles));
1196 # This subroutine returns a base (answer) filename with a number
1197 # appended to the end corresponding to how many logfiles (and thus
1198 # base files) have been created in the current running test.
1199 # NO PARAMETERS ARE PASSED TO THIS SUBROUTINE.
1203 return ($base_filename . &num_suffix
($num_of_logfiles));
1206 # This subroutine returns a difference filename with a number appended
1207 # to the end corresponding to how many logfiles (and thus diff files)
1208 # have been created in the current running test.
1212 return ($diff_filename . &num_suffix
($num_of_logfiles));
1215 # This subroutine returns a command filename with a number appended
1216 # to the end corresponding to how many logfiles (and thus command files)
1217 # have been created in the current running test.
1221 return ($run_filename . &num_suffix
($num_of_logfiles));
1224 # just like logfile, only a generic tmp filename for use by the test.
1225 # they are automatically cleaned up unless -keep was used, or the test fails.
1226 # Pass an argument of 1 to return the same filename as the previous call.
1230 local($no_increment) = @_;
1232 $num_of_tmpfiles += !$no_increment;
1234 return ($tmp_filename . &num_suffix
($num_of_tmpfiles));