diff --git a/UnixBench/Run b/UnixBench/Run index 5955bae..a3c5b81 100755 --- a/UnixBench/Run +++ b/UnixBench/Run @@ -5,6 +5,7 @@ use strict; use POSIX qw(strftime); use Time::HiRes; use IO::Handle; +use File::Path; use FindBin; @@ -569,17 +570,33 @@ sub getCmdOutput { sub getDir { my ( $var, $def ) = @_; + # If Environment variables(e.g. UB_RESULTDIR) is unset, use default value. my $val = $ENV{$var} || $def; - # Canonicalise the value. - my $wd; - chomp($wd = `pwd`); - chdir($val); - chomp($val = `pwd`); - chdir($wd); + # Only "execl.c" test needs the Environment variable(UB_BINDIR). $ENV{$var} = $val; - $val; + return $val; +} + +# Create direcotry(0755) if not exists. +sub createDirrectoriesIfNotExists { + foreach my $path (@_) { + my $isDirectoryNotExists = ! -d $path; + if ( $isDirectoryNotExists ) { + mkpath($path, {chmod => 0755}); + } + } +} + +# Show use directories. +sub printUsingDirectories { + printf "------------------------------------------------------------------------------\n"; + printf " Use directories for:\n"; + printf " * File I/O tests (named fs***) = ${TMPDIR}\n"; + printf " * Results = ${RESULTDIR}\n"; + printf "------------------------------------------------------------------------------\n"; + printf "\n"; } @@ -588,11 +605,18 @@ sub getDir { sub logFile { my ( $sysInfo ) = @_; - my $count = 1; + # If supplied output file name via Environment variable(UB_OUTPUT_FILE_NAME), then use it. + # * If exists same file, it will be overwrite completly. + my $output_file_name_supplied_by_environment = $ENV{"UB_OUTPUT_FILE_NAME"}; + if ( defined($output_file_name_supplied_by_environment) && $output_file_name_supplied_by_environment ne "" ) { + return ${RESULTDIR} . "/" . $output_file_name_supplied_by_environment; + } + # Use the date in the base file name. my $ymd = strftime "%Y-%m-%d", localtime; + my $count = 1; while (1) { my $log = sprintf "%s/%s-%s-%02d", ${RESULTDIR}, $sysInfo->{'name'}, $ymd, $count; @@ -1830,6 +1854,10 @@ sub main { $tests = $index; } + # Create directories. + my @creatingDirectories = ( ${TMPDIR}, ${RESULTDIR} ); + createDirrectoriesIfNotExists(@creatingDirectories); + preChecks(); my $systemInfo = getSystemInfo(); @@ -1846,6 +1874,11 @@ sub main { # Display the program banner. system("cat \"${BINDIR}/unixbench.logo\""); + # Show output output directories, if not in quiet mode. + if ($verbose > 0) { + printUsingDirectories(); + } + if ($verbose > 1) { printf "\n", join(", ", @$tests); printf "Tests to run: %s\n", join(", ", @$tests); diff --git a/UnixBench/USAGE b/UnixBench/USAGE index 903a83f..c3135f9 100644 --- a/UnixBench/USAGE +++ b/UnixBench/USAGE @@ -65,6 +65,11 @@ so that randomly-churning background processes don't randomise the results too much. This is particularly true for the graphics tests. +If you need to change the directories, use "Environment variables" about below. + + * "UB_RESULTDIR" : Output destination path(absolute) of the result files. + * "UB_TMPDIR" : Directory path(absolute) used for file I/O tests(named fs****). + * "UB_OUTPUT_FILE_NAME" : Output file name. If exists same file, it will be overwrite completly. ============================================================================ Tests