From fb25b1613f594a7b276d18f88e5e9d36a8e7cb14 Mon Sep 17 00:00:00 2001 From: t2-kob <4531723+t2-kob@users.noreply.github.com> Date: Fri, 12 Jan 2018 11:53:53 +0900 Subject: [PATCH 1/2] Added change directories and filename via Environment variables. --- UnixBench/Run | 49 +++++++++++++++++++++++++++++++++++++++++-------- UnixBench/USAGE | 5 +++++ 2 files changed, 46 insertions(+), 8 deletions(-) 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 From ba94c19199d8c5892a02499fd34ea48d281e540e Mon Sep 17 00:00:00 2001 From: t2-kob <4531723+t2-kob@users.noreply.github.com> Date: Sun, 14 Jan 2018 12:49:11 +0900 Subject: [PATCH 2/2] Fixed the "USAGE" to improve readability. --- UnixBench/USAGE | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/UnixBench/USAGE b/UnixBench/USAGE index c3135f9..748b033 100644 --- a/UnixBench/USAGE +++ b/UnixBench/USAGE @@ -65,11 +65,12 @@ 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. +Output can be specified by using the following variables: - * "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. + * "UB_RESULTDIR" : Absolute path of output directory of result files. + * "UB_TMPDIR" : Absolute path of temporary files for IO tests. + * "UB_OUTPUT_FILE_NAME" : Output file name. If exists it will be overwritten. + ============================================================================ Tests