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-2013 Free Software Foundation, Inc.
9 # This file is part of GNU Make.
11 # GNU Make is free software; you can redistribute it and/or modify it under
12 # the terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 3 of the License, or (at your option) any later
16 # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 # You should have received a copy of the GNU General Public License along with
22 # this program. If not, see <http://www.gnu.org/licenses/>.
25 # Test driver routines used by a number of test suites, including
26 # those for SCS, make, roll_dir, and scan_deps (?).
28 # this routine controls the whole mess; each test suite sets up a few
29 # variables and then calls &toplevel, which does all the real work.
34 # The number of test categories we've run
36 # The number of test categroies that have passed
37 $categories_passed = 0;
38 # The total number of individual tests that have been run
40 # The total number of individual tests that have passed
41 $total_tests_passed = 0;
42 # The number of tests in this category that have been run
44 # The number of tests in this category that have passed
48 # Yeesh. This whole test environment is such a hack!
52 # 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',
93 # Windows NT-specific stuff
95 # DJGPP-specific stuff
96 'DJDIR', 'DJGPP', 'SHELL', 'COMSPEC', 'HOSTNAME', 'LFN',
97 'FNCASE', '387', 'EMU387', 'GROUP'
99 $makeENV{$_} = $ENV{$_} if $ENV{$_};
102 # Make sure our compares are not foiled by locale differences
104 $makeENV{LC_ALL} = 'C';
106 # Replace the environment with the new one
112 $| = 1; # unbuffered output
114 $debug = 0; # debug flag
115 $profile = 0; # profiling flag
116 $verbose = 0; # verbose mode flag
117 $detail = 0; # detailed verbosity
118 $keep = 0; # keep temp files around
119 $workdir = "work"; # The directory where the test will start running
120 $scriptdir = "scripts"; # The directory where we find the test scripts
121 $tmpfilesuffix = "t"; # the suffix used on tmpfiles
122 $default_output_stack_level = 0; # used by attach_default_output, etc.
123 $default_input_stack_level = 0; # used by attach_default_input, etc.
124 $cwd = "."; # don't we wish we knew
125 $cwdslash = ""; # $cwd . $pathsep, but "" rather than "./"
127 &get_osname; # sets $osname, $vos, $pathsep, and $short_filenames
129 &set_defaults; # suite-defined
131 &parse_command_line (@ARGV);
133 print "OS name = '$osname'\n" if $debug;
135 $workpath = "$cwdslash$workdir";
136 $scriptpath = "$cwdslash$scriptdir";
138 &set_more_defaults; # suite-defined
144 print "Clearing $workpath...\n";
145 &remove_directory_tree("$workpath/")
146 || &error ("Couldn't wipe out $workpath\n");
150 mkdir ($workpath, 0777) || &error ("Couldn't mkdir $workpath: $!\n");
155 &error ("Failed to find $scriptpath containing perl test scripts.\n");
160 print "Making work dirs...\n";
161 foreach $test (@TESTS)
163 if ($test =~ /^([^\/]+)\//)
166 push (@rmdirs, $dir);
168 || mkdir ("$workpath/$dir", 0777)
169 || &error ("Couldn't mkdir $workpath/$dir: $!\n");
175 print "Finding tests...\n";
176 opendir (SCRIPTDIR, $scriptpath)
177 || &error ("Couldn't opendir $scriptpath: $!\n");
178 @dirs = grep (!/^(\..*|CVS|RCS)$/, readdir (SCRIPTDIR) );
179 closedir (SCRIPTDIR);
182 next if ($dir =~ /^(\..*|CVS|RCS)$/ || ! -d "$scriptpath/$dir");
183 push (@rmdirs, $dir);
184 mkdir ("$workpath/$dir", 0777)
185 || &error ("Couldn't mkdir $workpath/$dir: $!\n");
186 opendir (SCRIPTDIR, "$scriptpath/$dir")
187 || &error ("Couldn't opendir $scriptpath/$dir: $!\n");
188 @files = grep (!/^(\..*|CVS|RCS|.*~)$/, readdir (SCRIPTDIR) );
189 closedir (SCRIPTDIR);
190 foreach $test (@files)
193 push (@TESTS, "$dir/$test");
200 &error ("\nNo tests in $scriptpath, and none were specified.\n");
207 foreach $dir (@rmdirs)
209 rmdir ("$workpath/$dir");
214 $categories_failed = $categories_run - $categories_passed;
215 $total_tests_failed = $total_tests_run - $total_tests_passed;
217 if ($total_tests_failed)
219 print "\n$total_tests_failed Test";
220 print "s" unless $total_tests_failed == 1;
221 print " in $categories_failed Categor";
222 print ($categories_failed == 1 ? "y" : "ies");
223 print " Failed (See .$diffext* files in $workdir dir for details) :-(\n\n";
228 print "\n$total_tests_passed Test";
229 print "s" unless $total_tests_passed == 1;
230 print " in $categories_passed Categor";
231 print ($categories_passed == 1 ? "y" : "ies");
232 print " Complete ... No Failures :-)\n\n";
239 # Set up an initial value. In perl5 we can do it the easy way.
240 $osname = defined($^O) ? $^O : '';
242 # Find a path to Perl
244 # See if the filesystem supports long file names with multiple
246 $short_filenames = 0;
247 (open (TOUCHFD, "> fancy.file.name") && close (TOUCHFD))
248 || ($short_filenames = 1);
249 unlink ("fancy.file.name") || ($short_filenames = 1);
251 if (! $short_filenames) {
252 # Thanks go to meyering@cs.utexas.edu (Jim Meyering) for suggesting a
253 # better way of doing this. (We used to test for existence of a /mnt
254 # dir, but that apparently fails on an SGI Indigo (whatever that is).)
255 # Because perl on VOS translates /'s to >'s, we need to test for
256 # VOSness rather than testing for Unixness (ie, try > instead of /).
258 mkdir (".ostest", 0777) || &error ("Couldn't create .ostest: $!\n", 1);
259 open (TOUCHFD, "> .ostest>ick") && close (TOUCHFD);
260 chdir (".ostest") || &error ("Couldn't chdir to .ostest: $!\n", 1);
263 if (! $short_filenames && -f "ick")
271 # the following is regrettably knarly, but it seems to be the only way
272 # to not get ugly error messages if uname can't be found.
273 # Hmmm, BSD/OS 2.0's uname -a is excessively verbose. Let's try it
274 # with switches first.
275 eval "chop (\$osname = `sh -c 'uname -nmsr 2>&1'`)";
276 if ($osname =~ /not found/i)
278 $osname = "(something posixy with no uname)";
280 elsif ($@ ne "" || $?)
282 eval "chop (\$osname = `sh -c 'uname -a 2>&1'`)";
285 $osname = "(something posixy)";
292 if (! $short_filenames) {
293 chdir ("..") || &error ("Couldn't chdir to ..: $!\n", 1);
294 unlink (".ostest>ick");
295 rmdir (".ostest") || &error ("Couldn't rmdir .ostest: $!\n", 1);
299 sub parse_command_line
303 # use @ARGV if no args were passed in
310 # look at each option; if we don't recognize it, maybe the suite-specific
311 # command line parsing code will...
315 $option = shift @argv;
316 if ($option =~ /^-debug$/i)
318 print "\nDEBUG ON\n";
321 elsif ($option =~ /^-usage$/i)
326 elsif ($option =~ /^-(h|help)$/i)
331 elsif ($option =~ /^-profile$/i)
335 elsif ($option =~ /^-verbose$/i)
339 elsif ($option =~ /^-detail$/i)
344 elsif ($option =~ /^-keep$/i)
348 elsif (&valid_option($option))
350 # The suite-defined subroutine takes care of the option
352 elsif ($option =~ /^-/)
354 print "Invalid option: $option\n";
358 else # must be the name of a test
360 $option =~ s/\.pl$//;
361 push(@TESTS,$option);
368 local($num) = shift @_;
385 local($width, $string) = @_;
388 if (length ($string))
390 $pad = " " x ( ($width - length ($string) + 1) / 2);
401 $info = "Running tests for $testee on $osname\n"; # $testee is suite-defined
402 $len = &max (length ($line), length ($testee_version),
403 length ($banner_info), 73) + 5;
404 $line = ("-" x $len) . "\n";
410 &print_centered ($len, $line);
411 &print_centered ($len, $info);
412 &print_centered ($len, $testee_version); # suite-defined
413 &print_centered ($len, $banner_info); # suite-defined
414 &print_centered ($len, $line);
422 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";
456 $output = "........................................................ ";
458 substr($output,0,length($testname)) = "$testname ";
466 $code = do $perl_testname;
469 $total_tests_run += $tests_run;
470 $total_tests_passed += $tests_passed;
473 if (!defined($code)) {
474 # Failed to parse or called die
476 warn "\n*** Test died ($testname): $@\n";
478 warn "\n*** Couldn't parse $perl_testname\n";
480 $status = "FAILED ($tests_passed/$tests_run passed)";
483 elsif ($code == -1) {
484 # Skipped... not supported
490 # Bad result... this shouldn't really happen. Usually means that
491 # the suite forgot to end with "1;".
492 warn "\n*** Test returned $code\n";
493 $status = "FAILED ($tests_passed/$tests_run passed)";
496 elsif ($tests_run == 0) {
498 $status = "FAILED (no tests found!)";
501 elsif ($tests_run > $tests_passed) {
503 $status = "FAILED ($tests_passed/$tests_run passed)";
508 ++$categories_passed;
509 $status = "ok ($tests_passed passed)";
512 for ($i = $num_of_tmpfiles; $i; $i--) {
513 rmfiles($tmp_filename . num_suffix($i));
515 for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--) {
516 rmfiles($log_filename . num_suffix($i));
517 rmfiles($base_filename . num_suffix($i));
521 # If the verbose option has been specified, then a short description
522 # of each test is printed before displaying the results of each test
523 # describing WHAT is being tested.
527 print "\nWHAT IS BEING TESTED\n";
528 print "--------------------";
530 print "\n\n$description\n\n";
533 # If the detail option has been specified, then the details of HOW
534 # the test is testing what it says it is testing in the verbose output
535 # will be displayed here before the results of the test are displayed.
538 print "\nHOW IT IS TESTED\n";
539 print "----------------";
540 print "\n\n$details\n\n";
547 # If the keep flag is not set, this subroutine deletes all filenames that
556 return (unlink @files);
562 sub print_standard_usage
564 local($plname,@moreusage) = @_;
567 print "usage:\t$plname [testname] [-verbose] [-detail] [-keep]\n";
568 print "\t\t\t[-profile] [-usage] [-help] [-debug]\n";
569 foreach (@moreusage) {
574 sub print_standard_help
576 local(@morehelp) = @_;
581 $line = "Test Driver For $testee";
583 $line = "=" x length ($line);
589 . "${t}You may, if you wish, run only ONE test if you know the name\n"
590 . "${t}of that test and specify this name anywhere on the command\n"
591 . "${t}line. Otherwise ALL existing tests in the scripts directory\n"
592 . "${t}will be run.\n"
594 . "${t}If this option is given, a description of every test is\n"
595 . "${t}displayed before the test is run. (Not all tests may have\n"
596 . "${t}descriptions at this time)\n"
598 . "${t}If this option is given, a detailed description of every\n"
599 . "${t}test is displayed before the test is run. (Not all tests\n"
600 . "${t}have descriptions at this time)\n"
602 . "${t}If this option is given, then the profile file\n"
603 . "${t}is added to other profiles every time $testee is run.\n"
604 . "${t}This option only works on VOS at this time.\n"
606 . "${t}You may give this option if you DO NOT want ANY\n"
607 . "${t}of the files generated by the tests to be deleted. \n"
608 . "${t}Without this option, all files generated by the test will\n"
609 . "${t}be deleted IF THE TEST PASSES.\n"
611 . "${t}Use this option if you would like to see all of the system\n"
612 . "${t}calls issued and their return status while running the tests\n"
613 . "${t}This can be helpful if you're having a problem adding a test\n"
614 . "${t}to the suite, or if the test fails!\n";
616 foreach $line (@morehelp)
619 if (substr ($tline, 0, 1) eq "\t")
621 substr ($tline, 0, 1) = $t;
627 #######################################################################
628 ########### Generic Test Driver Subroutines ###########
629 #######################################################################
638 $depth = defined ($_[0]) ? $_[0] : 1;
639 ($package, $filename, $linenum) = caller ($depth + 1);
640 return "$filename: $linenum";
645 local($message) = $_[0];
646 local($caller) = &get_caller (1);
650 $caller = &get_caller ($_[1] + 1) . " -> $caller";
653 die "$caller: $message";
658 local($answer,$logfile) = @_;
659 local($slurp, $answer_matched) = ('', 0);
663 if (! defined $answer) {
664 print "Ignoring output ........ " if $debug;
667 print "Comparing Output ........ " if $debug;
669 $slurp = &read_file_into_string ($logfile);
671 # For make, get rid of any time skew error before comparing--too bad this
672 # has to go into the "generic" driver code :-/
673 $slurp =~ s/^.*modification time .*in the future.*\n//gm;
674 $slurp =~ s/^.*Clock skew detected.*\n//gm;
676 if ($slurp eq $answer) {
679 # See if it is a slash or CRLF problem
680 local ($answer_mod, $slurp_mod) = ($answer, $slurp);
682 $answer_mod =~ tr,\\,/,;
683 $answer_mod =~ s,\r\n,\n,gs;
685 $slurp_mod =~ tr,\\,/,;
686 $slurp_mod =~ s,\r\n,\n,gs;
688 $answer_matched = ($slurp_mod eq $answer_mod);
690 # If it still doesn't match, see if the answer might be a regex.
691 if (!$answer_matched && $answer =~ m,^/(.+)/$,) {
692 $answer_matched = ($slurp =~ /$1/);
693 if (!$answer_matched && $answer_mod =~ m,^/(.+)/$,) {
694 $answer_matched = ($slurp_mod =~ /$1/);
700 if ($answer_matched && $test_passed)
702 print "ok\n" if $debug;
707 if (! $answer_matched) {
708 print "DIFFERENT OUTPUT\n" if $debug;
710 &create_file (&get_basefile, $answer);
711 &create_file (&get_runfile, $command_string);
713 print "\nCreating Difference File ...\n" if $debug;
715 # Create the difference file
717 local($command) = "diff -c " . &get_basefile . " " . $logfile;
718 &run_command_with_output(&get_difffile,$command);
724 sub read_file_into_string
726 local($filename) = @_;
727 local($oldslash) = $/;
731 open (RFISFILE, $filename) || return "";
732 local ($slurp) = <RFISFILE>;
743 sub attach_default_output
745 local ($filename) = @_;
750 $code = system "++attach_default_output_hack $filename";
751 $code == -2 || &error ("adoh death\n", 1);
756 open($dup, '>&', STDOUT) or error("ado: $! duping STDOUT\n", 1);
757 push @OUTSTACK, $dup;
760 open($dup, '>&', STDERR) or error("ado: $! duping STDERR\n", 1);
761 push @ERRSTACK, $dup;
763 open(STDOUT, '>', $filename) or error("ado: $filename: $!\n", 1);
764 open(STDERR, ">&STDOUT") or error("ado: $filename: $!\n", 1);
767 # close the current stdout/stderr, and restore the previous ones from
770 sub detach_default_output
776 $code = system "++detach_default_output_hack";
777 $code == -2 || &error ("ddoh death\n", 1);
781 @OUTSTACK or error("default output stack has flown under!\n", 1);
786 open (STDOUT, '>&', pop @OUTSTACK) or error("ddo: $! duping STDOUT\n", 1);
787 open (STDERR, '>&', pop @ERRSTACK) or error("ddo: $! duping STDERR\n", 1);
790 # This runs a command without any debugging info.
795 # We reset this before every invocation. On Windows I think there is only
796 # one environment, not one per process, so I think that variables set in
797 # test scripts might leak into subsequent tests if this isn't reset--???
803 exec(@_) or die "Cannot execute $_[0]\n";
805 local $SIG{ALRM} = sub { my $e = $ERRSTACK[0]; print $e "\nTest timed out after $test_timeout seconds\n"; die "timeout\n"; };
807 waitpid($pid, 0) > 0 or die "No such pid: $pid\n";
812 # The eval failed. If it wasn't SIGALRM then die.
813 $@ eq "timeout\n" or die "Command failed: $@";
815 # Timed out. Resend the alarm to our process group to kill the children.
816 $SIG{ALRM} = 'IGNORE';
824 # run one command (passed as a list of arg 0 - n), returning 0 on success
825 # and nonzero on failure.
829 print "\nrun_command: @_\n" if $debug;
830 my $code = _run_command(@_);
831 print "run_command returned $code.\n" if $debug;
836 # run one command (passed as a list of arg 0 - n, with arg 0 being the
837 # second arg to this routine), returning 0 on success and non-zero on failure.
838 # The first arg to this routine is a filename to connect to the stdout
839 # & stderr of the child process.
841 sub run_command_with_output
843 my $filename = shift;
845 print "\nrun_command_with_output($filename,$runname): @_\n" if $debug;
846 &attach_default_output ($filename);
847 my $code = eval { _run_command(@_) };
849 &detach_default_output;
853 print "run_command_with_output returned $code.\n" if $debug;
858 # performs the equivalent of an "rm -rf" on the first argument. Like
859 # rm, if the path ends in /, leaves the (now empty) directory; otherwise
862 sub remove_directory_tree
864 local ($targetdir) = @_;
865 local ($nuketop) = 1;
868 $ch = substr ($targetdir, length ($targetdir) - 1);
869 if ($ch eq "/" || $ch eq $pathsep)
871 $targetdir = substr ($targetdir, 0, length ($targetdir) - 1);
880 &remove_directory_tree_inner ("RDT00", $targetdir) || return 0;
883 rmdir $targetdir || return 0;
889 sub remove_directory_tree_inner
891 local ($dirhandle, $targetdir) = @_;
893 local ($subdirhandle);
895 opendir ($dirhandle, $targetdir) || return 0;
896 $subdirhandle = $dirhandle;
898 while ($object = readdir ($dirhandle))
900 if ($object =~ /^(\.\.?|CVS|RCS)$/)
905 $object = "$targetdir$pathsep$object";
908 if (-d _ && &remove_directory_tree_inner ($subdirhandle, $object))
910 rmdir $object || return 0;
914 unlink $object || return 0;
917 closedir ($dirhandle);
921 # We used to use this behavior for this function:
925 # local (@filenames) = @_;
926 # local ($now) = time;
929 # foreach $file (@filenames)
931 # utime ($now, $now, $file)
932 # || (open (TOUCHFD, ">> $file") && close (TOUCHFD))
933 # || &error ("Couldn't touch $file: $!\n", 1);
938 # But this behaves badly on networked filesystems where the time is
939 # skewed, because it sets the time of the file based on the _local_
940 # host. Normally when you modify a file, it's the _remote_ host that
941 # determines the modtime, based on _its_ clock. So, instead, now we open
942 # the file and write something into it to force the remote host to set
943 # the modtime correctly according to its clock.
951 (open(T, ">> $file") && print(T "\n") && close(T))
952 || &error("Couldn't touch $file: $!\n", 1);
956 # Touch with a time offset. To DTRT, call touch() then use stat() to get the
957 # access/mod time for each file and apply the offset.
961 local ($off) = shift;
966 local (@s) = stat($_[0]);
968 utime($s[8]+$off, $s[9]+$off, @_);
971 # open a file, write some stuff to it, and close it.
975 local ($filename, @lines) = @_;
977 open (CF, "> $filename") || &error ("Couldn't open $filename: $!\n", 1);
978 foreach $line (@lines)
985 # create a directory tree described by an associative array, wherein each
986 # key is a relative pathname (using slashes) and its associated value is
988 # DIR indicates a directory
989 # FILE:contents indicates a file, which should contain contents +\n
990 # LINK:target indicates a symlink, pointing to $basedir/target
991 # The first argument is the dir under which the structure will be created
992 # (the dir will be made and/or cleaned if necessary); the second argument
993 # is the associative array.
997 local ($basedir, %dirtree) = @_;
1000 &remove_directory_tree ("$basedir");
1001 mkdir ($basedir, 0777) || &error ("Couldn't mkdir $basedir: $!\n", 1);
1003 foreach $path (sort keys (%dirtree))
1005 if ($dirtree {$path} =~ /^DIR$/)
1007 mkdir ("$basedir/$path", 0777)
1008 || &error ("Couldn't mkdir $basedir/$path: $!\n", 1);
1010 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1012 &create_file ("$basedir/$path", $1 . "\n");
1014 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1016 symlink ("$basedir/$1", "$basedir/$path")
1017 || &error ("Couldn't symlink $basedir/$path -> $basedir/$1: $!\n", 1);
1021 &error ("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1024 if ($just_setup_tree)
1026 die "Tree is setup...\n";
1030 # compare a directory tree with an associative array in the format used
1031 # by create_dir_tree, above.
1032 # The first argument is the dir under which the structure should be found;
1033 # the second argument is the associative array.
1035 sub compare_dir_tree
1037 local ($basedir, %dirtree) = @_;
1043 local ($fulltarget);
1048 opendir (DIR, $basedir) || &error ("Couldn't open $basedir: $!\n", 1);
1049 @allfiles = grep (!/^(\.\.?|CVS|RCS)$/, readdir (DIR) );
1053 print "dirtree: (%dirtree)\n$basedir: (@allfiles)\n";
1056 foreach $path (sort keys (%dirtree))
1060 print "Checking $path ($dirtree{$path}).\n";
1064 foreach $i (0 .. $#allfiles)
1066 if ($allfiles[$i] eq $path)
1068 splice (@allfiles, $i, 1); # delete it
1071 print " Zapped $path; files now (@allfiles).\n";
1073 lstat ("$basedir/$path");
1081 print "compare_dir_tree: $path does not exist.\n";
1086 if ($dirtree {$path} =~ /^DIR$/)
1088 if (-d _ && opendir (DIR, "$basedir/$path") )
1090 @files = readdir (DIR);
1092 @files = grep (!/^(\.\.?|CVS|RCS)$/ && ($_ = "$path/$_"), @files);
1093 push (@allfiles, @files);
1096 print " Read in $path; new files (@files).\n";
1101 print "compare_dir_tree: $path is not a dir.\n";
1105 elsif ($dirtree {$path} =~ /^FILE:(.*)$/)
1109 print "compare_dir_tree: $path is not a file.\n";
1116 $contents = &read_file_into_string ("$basedir/$path");
1117 if ($contents ne "$1\n")
1119 print "compare_dir_tree: $path contains wrong stuff."
1120 . " Is:\n$contentsShould be:\n$1\n";
1125 elsif ($dirtree {$path} =~ /^LINK:(.*)$/)
1130 print "compare_dir_tree: $path is not a link.\n";
1135 $contents = readlink ("$basedir/$path");
1136 $contents =~ tr/>/\//;
1137 $fulltarget = "$basedir/$target";
1138 $fulltarget =~ tr/>/\//;
1139 if (!($contents =~ /$fulltarget$/))
1143 $target = $fulltarget;
1145 print "compare_dir_tree: $path should be link to $target, "
1146 . "not $contents.\n";
1152 &error ("Bogus dirtree type: \"$dirtree{$path}\"\n", 1);
1158 print "leftovers: (@allfiles).\n";
1161 foreach $file (@allfiles)
1163 print "compare_dir_tree: $file should not exist.\n";
1170 # this subroutine generates the numeric suffix used to keep tmp filenames,
1171 # log filenames, etc., unique. If the number passed in is 1, then a null
1172 # string is returned; otherwise, we return ".n", where n + 1 is the number
1180 return "$extext$num";
1186 # This subroutine returns a log filename with a number appended to
1187 # the end corresponding to how many logfiles have been created in the
1188 # current running test. An optional parameter may be passed (0 or 1).
1189 # If a 1 is passed, then it does NOT increment the logfile counter
1190 # and returns the name of the latest logfile. If either no parameter
1191 # is passed at all or a 0 is passed, then the logfile counter is
1192 # incremented and the new name is returned.
1196 local($no_increment) = @_;
1198 $num_of_logfiles += !$no_increment;
1200 return ($log_filename . &num_suffix ($num_of_logfiles));
1203 # This subroutine returns a base (answer) filename with a number
1204 # appended to the end corresponding to how many logfiles (and thus
1205 # base files) have been created in the current running test.
1206 # NO PARAMETERS ARE PASSED TO THIS SUBROUTINE.
1210 return ($base_filename . &num_suffix ($num_of_logfiles));
1213 # This subroutine returns a difference filename with a number appended
1214 # to the end corresponding to how many logfiles (and thus diff files)
1215 # have been created in the current running test.
1219 return ($diff_filename . &num_suffix ($num_of_logfiles));
1222 # This subroutine returns a command filename with a number appended
1223 # to the end corresponding to how many logfiles (and thus command files)
1224 # have been created in the current running test.
1228 return ($run_filename . &num_suffix ($num_of_logfiles));
1231 # just like logfile, only a generic tmp filename for use by the test.
1232 # they are automatically cleaned up unless -keep was used, or the test fails.
1233 # Pass an argument of 1 to return the same filename as the previous call.
1237 local($no_increment) = @_;
1239 $num_of_tmpfiles += !$no_increment;
1241 return ($tmp_filename . &num_suffix ($num_of_tmpfiles));