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.33 2012/03/04 00:24:31 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',
95 # Windows NT-specific stuff
97 # DJGPP-specific stuff
98 'DJDIR', 'DJGPP', 'SHELL', 'COMSPEC', 'HOSTNAME', 'LFN',
99 'FNCASE', '387', 'EMU387', 'GROUP'
101 $makeENV{$_} = $ENV{$_} if $ENV{$_};
104 # Make sure our compares are not foiled by locale differences
106 $makeENV{LC_ALL
} = 'C';
108 # Replace the environment with the new one
114 $| = 1; # unbuffered output
116 $debug = 0; # debug flag
117 $profile = 0; # profiling flag
118 $verbose = 0; # verbose mode flag
119 $detail = 0; # detailed verbosity
120 $keep = 0; # keep temp files around
121 $workdir = "work"; # The directory where the test will start running
122 $scriptdir = "scripts"; # The directory where we find the test scripts
123 $tmpfilesuffix = "t"; # the suffix used on tmpfiles
124 $default_output_stack_level = 0; # used by attach_default_output, etc.
125 $default_input_stack_level = 0; # used by attach_default_input, etc.
126 $cwd = "."; # don't we wish we knew
127 $cwdslash = ""; # $cwd . $pathsep, but "" rather than "./"
129 &get_osname
; # sets $osname, $vos, $pathsep, and $short_filenames
131 &set_defaults
; # suite-defined
133 &parse_command_line
(@ARGV);
135 print "OS name = '$osname'\n" if $debug;
137 $workpath = "$cwdslash$workdir";
138 $scriptpath = "$cwdslash$scriptdir";
140 &set_more_defaults
; # suite-defined
146 print "Clearing $workpath...\n";
147 &remove_directory_tree
("$workpath/")
148 || &error
("Couldn't wipe out $workpath\n");
152 mkdir ($workpath, 0777) || &error
("Couldn't mkdir $workpath: $!\n");
157 &error
("Failed to find $scriptpath containing perl test scripts.\n");
162 print "Making work dirs...\n";
163 foreach $test (@TESTS)
165 if ($test =~ /^([^\/]+)\
//)
168 push (@rmdirs, $dir);
170 || mkdir ("$workpath/$dir", 0777)
171 || &error
("Couldn't mkdir $workpath/$dir: $!\n");
177 print "Finding tests...\n";
178 opendir (SCRIPTDIR
, $scriptpath)
179 || &error
("Couldn't opendir $scriptpath: $!\n");
180 @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR
) );
181 closedir (SCRIPTDIR
);
184 next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d
"$scriptpath/$dir");
185 push (@rmdirs, $dir);
186 mkdir ("$workpath/$dir", 0777)
187 || &error
("Couldn't mkdir $workpath/$dir: $!\n");
188 opendir (SCRIPTDIR
, "$scriptpath/$dir")
189 || &error
("Couldn't opendir $scriptpath/$dir: $!\n");
190 @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR
) );
191 closedir (SCRIPTDIR
);
192 foreach $test (@files)
195 push (@TESTS, "$dir/$test");
202 &error
("\nNo tests in $scriptpath, and none were specified.\n");
209 foreach $dir (@rmdirs)
211 rmdir ("$workpath/$dir");
216 $categories_failed = $categories_run - $categories_passed;
217 $total_tests_failed = $total_tests_run - $total_tests_passed;
219 if ($total_tests_failed)
221 print "\n$total_tests_failed Test";
222 print "s" unless $total_tests_failed == 1;
223 print " in $categories_failed Categor";
224 print ($categories_failed == 1 ?
"y" : "ies");
225 print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n";
230 print "\n$total_tests_passed Test";
231 print "s" unless $total_tests_passed == 1;
232 print " in $categories_passed Categor";
233 print ($categories_passed == 1 ?
"y" : "ies");
234 print " Complete ... No Failures :-)\n\n";
241 # Set up an initial value. In perl5 we can do it the easy way.
242 $osname = defined($^O
) ?
$^O
: '';
244 # Find a path to Perl
246 # See if the filesystem supports long file names with multiple
248 $short_filenames = 0;
249 (open (TOUCHFD
, "> fancy.file.name") && close (TOUCHFD
))
250 || ($short_filenames = 1);
251 unlink ("fancy.file.name") || ($short_filenames = 1);
253 if (! $short_filenames) {
254 # Thanks go to meyering@cs.utexas.edu (Jim Meyering) for suggesting a
255 # better way of doing this. (We used to test for existence of a /mnt
256 # dir, but that apparently fails on an SGI Indigo (whatever that is).)
257 # Because perl on VOS translates /'s to >'s, we need to test for
258 # VOSness rather than testing for Unixness (ie, try > instead of /).
260 mkdir (".ostest", 0777) || &error
("Couldn't create .ostest: $!\n", 1);
261 open (TOUCHFD
, "> .ostest>ick") && close (TOUCHFD
);
262 chdir (".ostest") || &error
("Couldn't chdir to .ostest: $!\n", 1);
265 if (! $short_filenames && -f
"ick")
273 # the following is regrettably knarly, but it seems to be the only way
274 # to not get ugly error messages if uname can't be found.
275 # Hmmm, BSD/OS 2.0's uname -a is excessively verbose. Let's try it
276 # with switches first.
277 eval "chop (\$osname = `sh -c 'uname -nmsr 2>&1'`)";
278 if ($osname =~ /not found/i)
280 $osname = "(something posixy with no uname)";
282 elsif ($@
ne "" || $?
)
284 eval "chop (\$osname = `sh -c 'uname -a 2>&1'`)";
287 $osname = "(something posixy)";
294 if (! $short_filenames) {
295 chdir ("..") || &error
("Couldn't chdir to ..: $!\n", 1);
296 unlink (".ostest>ick");
297 rmdir (".ostest") || &error
("Couldn't rmdir .ostest: $!\n", 1);
301 sub parse_command_line
305 # use @ARGV if no args were passed in
312 # look at each option; if we don't recognize it, maybe the suite-specific
313 # command line parsing code will...
317 $option = shift @argv;
318 if ($option =~ /^-debug$/i)
320 print "\nDEBUG ON\n";
323 elsif ($option =~ /^-usage$/i)
328 elsif ($option =~ /^-(h|help)$/i)
333 elsif ($option =~ /^-profile$/i)
337 elsif ($option =~ /^-verbose$/i)
341 elsif ($option =~ /^-detail$/i)
346 elsif ($option =~ /^-keep$/i)
350 elsif (&valid_option
($option))
352 # The suite-defined subroutine takes care of the option
354 elsif ($option =~ /^-/)
356 print "Invalid option: $option\n";
360 else # must be the name of a test
362 $option =~ s/\.pl$//;
363 push(@TESTS,$option);
370 local($num) = shift @_;
387 local($width, $string) = @_;
390 if (length ($string))
392 $pad = " " x
( ($width - length ($string) + 1) / 2);
403 $info = "Running tests for $testee on $osname\n"; # $testee is suite-defined
404 $len = &max
(length ($line), length ($testee_version),
405 length ($banner_info), 73) + 5;
406 $line = ("-" x
$len) . "\n";
412 &print_centered
($len, $line);
413 &print_centered
($len, $info);
414 &print_centered
($len, $testee_version); # suite-defined
415 &print_centered
($len, $banner_info); # suite-defined
416 &print_centered
($len, $line);
424 foreach $testname (sort @TESTS)
427 $suite_passed = 1; # reset by test on failure
428 $num_of_logfiles = 0;
429 $num_of_tmpfiles = 0;
432 $old_makefile = undef;
433 $testname =~ s/^$scriptpath$pathsep//;
434 $perl_testname = "$scriptpath$pathsep$testname";
435 $testname =~ s/(\.pl|\.perl)$//;
436 $testpath = "$workpath$pathsep$testname";
437 # Leave enough space in the extensions to append a number, even
438 # though it needs to fit into 8+3 limits.
439 if ($short_filenames) {
452 $log_filename = "$testpath.$logext";
453 $diff_filename = "$testpath.$diffext";
454 $base_filename = "$testpath.$baseext";
455 $run_filename = "$testpath.$runext";
456 $tmp_filename = "$testpath.$tmpfilesuffix";
458 &setup_for_test
; # suite-defined
460 $output = "........................................................ ";
462 substr($output,0,length($testname)) = "$testname ";
466 # Run the actual test!
470 $code = do $perl_testname;
472 $total_tests_run += $tests_run;
473 $total_tests_passed += $tests_passed;
480 warn "\n*** Test died ($testname): $@\n";
482 warn "\n*** Couldn't run $perl_testname\n";
485 elsif ($code == -1) {
488 elsif ($code != 1 && $code != -1) {
490 warn "\n*** Test returned $code\n";
494 ++$categories_passed;
495 $status = "ok ($tests_passed passed)";
496 for ($i = $num_of_tmpfiles; $i; $i--)
498 &rmfiles
($tmp_filename . &num_suffix
($i) );
501 for ($i = $num_of_logfiles ?
$num_of_logfiles : 1; $i; $i--)
503 &rmfiles
($log_filename . &num_suffix
($i) );
504 &rmfiles
($base_filename . &num_suffix
($i) );
507 elsif (!defined $code || $code > 0) {
508 $status = "FAILED ($tests_passed/$tests_run passed)";
515 # If the verbose option has been specified, then a short description
516 # of each test is printed before displaying the results of each test
517 # describing WHAT is being tested.
523 print "\nWHAT IS BEING TESTED\n";
524 print "--------------------";
526 print "\n\n$description\n\n";
529 # If the detail option has been specified, then the details of HOW
530 # the test is testing what it says it is testing in the verbose output
531 # will be displayed here before the results of the test are displayed.
535 print "\nHOW IT IS TESTED\n";
536 print "----------------";
537 print "\n\n$details\n\n";
544 # If the keep flag is not set, this subroutine deletes all filenames that
553 return (unlink @files);
559 sub print_standard_usage
561 local($plname,@moreusage) = @_;
564 print "usage:\t$plname [testname] [-verbose] [-detail] [-keep]\n";
565 print "\t\t\t[-profile] [-usage] [-help] [-debug]\n";
566 foreach (@moreusage) {
571 sub print_standard_help
573 local(@morehelp) = @_;
578 $line = "Test Driver For $testee";
580 $line = "=" x
length ($line);
586 . "${t}You may, if you wish, run only ONE test if you know the name\n"
587 . "${t}of that test and specify this name anywhere on the command\n"
588 . "${t}line. Otherwise ALL existing tests in the scripts directory\n"
589 . "${t}will be run.\n"
591 . "${t}If this option is given, a description of every test is\n"
592 . "${t}displayed before the test is run. (Not all tests may have\n"
593 . "${t}descriptions at this time)\n"
595 . "${t}If this option is given, a detailed description of every\n"
596 . "${t}test is displayed before the test is run. (Not all tests\n"
597 . "${t}have descriptions at this time)\n"
599 . "${t}If this option is given, then the profile file\n"
600 . "${t}is added to other profiles every time $testee is run.\n"
601 . "${t}This option only works on VOS at this time.\n"
603 . "${t}You may give this option if you DO NOT want ANY\n"
604 . "${t}of the files generated by the tests to be deleted. \n"
605 . "${t}Without this option, all files generated by the test will\n"
606 . "${t}be deleted IF THE TEST PASSES.\n"
608 . "${t}Use this option if you would like to see all of the system\n"
609 . "${t}calls issued and their return status while running the tests\n"
610 . "${t}This can be helpful if you're having a problem adding a test\n"
611 . "${t}to the suite, or if the test fails!\n";
613 foreach $line (@morehelp)
616 if (substr ($tline, 0, 1) eq "\t")
618 substr ($tline, 0, 1) = $t;
624 #######################################################################
625 ########### Generic Test Driver Subroutines ###########
626 #######################################################################
635 $depth = defined ($_[0]) ?
$_[0] : 1;
636 ($package, $filename, $linenum) = caller ($depth + 1);
637 return "$filename: $linenum";
642 local($message) = $_[0];
643 local($caller) = &get_caller
(1);
647 $caller = &get_caller
($_[1] + 1) . " -> $caller";
650 die "$caller: $message";
655 local($answer,$logfile) = @_;
656 local($slurp, $answer_matched) = ('', 0);
658 print "Comparing Output ........ " if $debug;
660 $slurp = &read_file_into_string
($logfile);
662 # For make, get rid of any time skew error before comparing--too bad this
663 # has to go into the "generic" driver code :-/
664 $slurp =~ s/^.*modification time .*in the future.*\n//gm;
665 $slurp =~ s/^.*Clock skew detected.*\n//gm;
669 if ($slurp eq $answer) {
672 # See if it is a slash or CRLF problem
673 local ($answer_mod, $slurp_mod) = ($answer, $slurp);
675 $answer_mod =~ tr
,\\,/,;
676 $answer_mod =~ s
,\r\n,\n,gs
;
678 $slurp_mod =~ tr
,\\,/,;
679 $slurp_mod =~ s
,\r\n,\n,gs
;
681 $answer_matched = ($slurp_mod eq $answer_mod);
683 # If it still doesn't match, see if the answer might be a regex.
684 if (!$answer_matched && $answer =~ m
,^/(.+)/$,) {
685 $answer_matched = ($slurp =~ /$1/);
686 if (!$answer_matched && $answer_mod =~ m
,^/(.+)/$,) {
687 $answer_matched = ($slurp_mod =~ /$1/);
692 if ($answer_matched && $test_passed)
694 print "ok\n" if $debug;
699 if (! $answer_matched) {
700 print "DIFFERENT OUTPUT\n" if $debug;
702 &create_file
(&get_basefile
, $answer);
703 &create_file
(&get_runfile
, $command_string);
705 print "\nCreating Difference File ...\n" if $debug;
707 # Create the difference file
709 local($command) = "diff -c " . &get_basefile
. " " . $logfile;
710 &run_command_with_output
(&get_difffile
,$command);
719 sub read_file_into_string
721 local($filename) = @_;
722 local($oldslash) = $/;
726 open (RFISFILE
, $filename) || return "";
727 local ($slurp) = <RFISFILE
>;
735 sub attach_default_output
737 local ($filename) = @_;
742 $code = system "++attach_default_output_hack $filename";
743 $code == -2 || &error
("adoh death\n", 1);
747 open ("SAVEDOS" . $default_output_stack_level . "out", ">&STDOUT")
748 || &error
("ado: $! duping STDOUT\n", 1);
749 open ("SAVEDOS" . $default_output_stack_level . "err", ">&STDERR")
750 || &error
("ado: $! duping STDERR\n", 1);
752 open (STDOUT
, "> " . $filename)
753 || &error
("ado: $filename: $!\n", 1);
754 open (STDERR
, ">&STDOUT")
755 || &error
("ado: $filename: $!\n", 1);
757 $default_output_stack_level++;
760 # close the current stdout/stderr, and restore the previous ones from
763 sub detach_default_output
769 $code = system "++detach_default_output_hack";
770 $code == -2 || &error
("ddoh death\n", 1);
774 if (--$default_output_stack_level < 0)
776 &error
("default output stack has flown under!\n", 1);
782 open (STDOUT
, ">&SAVEDOS" . $default_output_stack_level . "out")
783 || &error
("ddo: $! duping STDOUT\n", 1);
784 open (STDERR
, ">&SAVEDOS" . $default_output_stack_level . "err")
785 || &error
("ddo: $! duping STDERR\n", 1);
787 close ("SAVEDOS" . $default_output_stack_level . "out")
788 || &error
("ddo: $! closing SCSDOSout\n", 1);
789 close ("SAVEDOS" . $default_output_stack_level . "err")
790 || &error
("ddo: $! closing SAVEDOSerr\n", 1);
793 # This runs a command without any debugging info.
798 # We reset this before every invocation. On Windows I think there is only
799 # one environment, not one per process, so I think that variables set in
800 # test scripts might leak into subsequent tests if this isn't reset--???
804 local $SIG{ALRM
} = sub { die "timeout\n"; };
810 # The eval failed. If it wasn't SIGALRM then die.
811 $@
eq "timeout\n" or die;
813 # Timed out. Resend the alarm to our process group to kill the children.
814 $SIG{ALRM
} = 'IGNORE';
822 # run one command (passed as a list of arg 0 - n), returning 0 on success
823 # and nonzero on failure.
827 print "\nrun_command: @_\n" if $debug;
828 my $code = _run_command
(@_);
829 print "run_command returned $code.\n" if $debug;
834 # run one command (passed as a list of arg 0 - n, with arg 0 being the
835 # second arg to this routine), returning 0 on success and non-zero on failure.
836 # The first arg to this routine is a filename to connect to the stdout
837 # & stderr of the child process.
839 sub run_command_with_output
841 my $filename = shift;
843 print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
844 &attach_default_output
($filename);
845 my $code = _run_command
(@_);
846 &detach_default_output
;
847 print "run_command_with_output returned $code.\n" if $debug;
852 # performs the equivalent of an "rm -rf" on the first argument. Like
853 # rm, if the path ends in /, leaves the (now empty) directory; otherwise
856 sub remove_directory_tree
858 local ($targetdir) = @_;
859 local ($nuketop) = 1;
862 $ch = substr ($targetdir, length ($targetdir) - 1);
863 if ($ch eq "/" || $ch eq $pathsep)
865 $targetdir = substr ($targetdir, 0, length ($targetdir) - 1);
874 &remove_directory_tree_inner
("RDT00", $targetdir) || return 0;
877 rmdir $targetdir || return 0;
883 sub remove_directory_tree_inner
885 local ($dirhandle, $targetdir) = @_;
887 local ($subdirhandle);
889 opendir ($dirhandle, $targetdir) || return 0;
890 $subdirhandle = $dirhandle;
892 while ($object = readdir ($dirhandle))
894 if ($object =~ /^(\.\.?|CVS|RCS)$/)
899 $object = "$targetdir$pathsep$object";
902 if (-d _
&& &remove_directory_tree_inner
($subdirhandle, $object))
904 rmdir $object || return 0;
908 unlink $object || return 0;
911 closedir ($dirhandle);
915 # We used to use this behavior for this function:
919 # local (@filenames) = @_;
920 # local ($now) = time;
923 # foreach $file (@filenames)
925 # utime ($now, $now, $file)
926 # || (open (TOUCHFD, ">> $file") && close (TOUCHFD))
927 # || &error ("Couldn't touch $file: $!\n", 1);
932 # But this behaves badly on networked filesystems where the time is
933 # skewed, because it sets the time of the file based on the _local_
934 # host. Normally when you modify a file, it's the _remote_ host that
935 # determines the modtime, based on _its_ clock. So, instead, now we open
936 # the file and write something into it to force the remote host to set
937 # the modtime correctly according to its clock.
945 (open(T
, ">> $file") && print(T
"\n") && close(T
))
946 || &error
("Couldn't touch $file: $!\n", 1);
950 # Touch with a time offset. To DTRT, call touch() then use stat() to get the
951 # access/mod time for each file and apply the offset.
955 local ($off) = shift;
960 local (@s) = stat($_[0]);
962 utime($s[8]+$off, $s[9]+$off, @_);
965 # open a file, write some stuff to it, and close it.
969 local ($filename, @lines) = @_;
971 open (CF
, "> $filename") || &error
("Couldn't open $filename: $!\n", 1);
972 foreach $line (@lines)
979 # create a directory tree described by an associative array, wherein each
980 # key is a relative pathname (using slashes) and its associated value is
982 # DIR indicates a directory
983 # FILE:contents indicates a file, which should contain contents +\n
984 # LINK:target indicates a symlink, pointing to $basedir/target
985 # The first argument is the dir under which the structure will be created
986 # (the dir will be made and/or cleaned if necessary); the second argument
987 # is the associative array.
991 local ($basedir, %dirtree) = @_;
994 &remove_directory_tree
("$basedir");
995 mkdir ($basedir, 0777) || &error
("Couldn't mkdir $basedir: $!\n", 1);
997 foreach $path (sort keys (%dirtree))
999 if ($dirtree {$path} =~ /^DIR$/)
1001 mkdir ("$basedir/$path", 0777)
1002 || &error
("Couldn't mkdir $basedir/$path: $!\n", 1);
1004 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1006 &create_file
("$basedir/$path", $1 . "\n");
1008 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1010 symlink ("$basedir/$1", "$basedir/$path")
1011 || &error
("Couldn't symlink $basedir/$path -> $basedir/$1: $!\n", 1);
1015 &error
("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1018 if ($just_setup_tree)
1020 die "Tree is setup...\n";
1024 # compare a directory tree with an associative array in the format used
1025 # by create_dir_tree, above.
1026 # The first argument is the dir under which the structure should be found;
1027 # the second argument is the associative array.
1029 sub compare_dir_tree
1031 local ($basedir, %dirtree) = @_;
1037 local ($fulltarget);
1042 opendir (DIR
, $basedir) || &error
("Couldn't open $basedir: $!\n", 1);
1043 @allfiles = grep (!/^(\.\.?|CVS|RCS)$/, readdir (DIR
) );
1047 print "dirtree: (%dirtree)\n$basedir: (@allfiles)\n";
1050 foreach $path (sort keys (%dirtree))
1054 print "Checking $path ($dirtree{$path}).\n";
1058 foreach $i (0 .. $#allfiles)
1060 if ($allfiles[$i] eq $path)
1062 splice (@allfiles, $i, 1); # delete it
1065 print " Zapped $path; files now (@allfiles).\n";
1067 lstat ("$basedir/$path");
1075 print "compare_dir_tree: $path does not exist.\n";
1080 if ($dirtree {$path} =~ /^DIR$/)
1082 if (-d _
&& opendir (DIR
, "$basedir/$path") )
1084 @files = readdir (DIR
);
1086 @files = grep (!/^(\.\.?|CVS|RCS)$/ && ($_ = "$path/$_"), @files);
1087 push (@allfiles, @files);
1090 print " Read in $path; new files (@files).\n";
1095 print "compare_dir_tree: $path is not a dir.\n";
1099 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1103 print "compare_dir_tree: $path is not a file.\n";
1110 $contents = &read_file_into_string
("$basedir/$path");
1111 if ($contents ne "$1\n")
1113 print "compare_dir_tree: $path contains wrong stuff."
1114 . " Is:\n$contentsShould be:\n$1\n";
1119 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1124 print "compare_dir_tree: $path is not a link.\n";
1129 $contents = readlink ("$basedir/$path");
1130 $contents =~ tr/>/\//;
1131 $fulltarget = "$basedir/$target";
1132 $fulltarget =~ tr/>/\//;
1133 if (!($contents =~ /$fulltarget$/))
1137 $target = $fulltarget;
1139 print "compare_dir_tree: $path should be link to $target, "
1140 . "not $contents.\n";
1146 &error
("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1152 print "leftovers: (@allfiles).\n";
1155 foreach $file (@allfiles)
1157 print "compare_dir_tree: $file should not exist.\n";
1164 # this subroutine generates the numeric suffix used to keep tmp filenames,
1165 # log filenames, etc., unique. If the number passed in is 1, then a null
1166 # string is returned; otherwise, we return ".n", where n + 1 is the number
1174 return "$extext$num";
1180 # This subroutine returns a log filename with a number appended to
1181 # the end corresponding to how many logfiles have been created in the
1182 # current running test. An optional parameter may be passed (0 or 1).
1183 # If a 1 is passed, then it does NOT increment the logfile counter
1184 # and returns the name of the latest logfile. If either no parameter
1185 # is passed at all or a 0 is passed, then the logfile counter is
1186 # incremented and the new name is returned.
1190 local($no_increment) = @_;
1192 $num_of_logfiles += !$no_increment;
1194 return ($log_filename . &num_suffix
($num_of_logfiles));
1197 # This subroutine returns a base (answer) filename with a number
1198 # appended to the end corresponding to how many logfiles (and thus
1199 # base files) have been created in the current running test.
1200 # NO PARAMETERS ARE PASSED TO THIS SUBROUTINE.
1204 return ($base_filename . &num_suffix
($num_of_logfiles));
1207 # This subroutine returns a difference filename with a number appended
1208 # to the end corresponding to how many logfiles (and thus diff files)
1209 # have been created in the current running test.
1213 return ($diff_filename . &num_suffix
($num_of_logfiles));
1216 # This subroutine returns a command filename with a number appended
1217 # to the end corresponding to how many logfiles (and thus command files)
1218 # have been created in the current running test.
1222 return ($run_filename . &num_suffix
($num_of_logfiles));
1225 # just like logfile, only a generic tmp filename for use by the test.
1226 # they are automatically cleaned up unless -keep was used, or the test fails.
1227 # Pass an argument of 1 to return the same filename as the previous call.
1231 local($no_increment) = @_;
1233 $num_of_tmpfiles += !$no_increment;
1235 return ($tmp_filename . &num_suffix
($num_of_tmpfiles));