mirror of
https://github.com/kdlucas/byte-unixbench.git
synced 2024-12-11 23:30:07 +08:00
Merge pull request #53 from t2-kob/environment_settings
Added change directories and filename via Environment variables.
This commit is contained in:
commit
5734fb362d
@ -5,6 +5,7 @@ use strict;
|
|||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
use Time::HiRes;
|
use Time::HiRes;
|
||||||
use IO::Handle;
|
use IO::Handle;
|
||||||
|
use File::Path;
|
||||||
use FindBin;
|
use FindBin;
|
||||||
|
|
||||||
|
|
||||||
@ -569,17 +570,33 @@ sub getCmdOutput {
|
|||||||
sub getDir {
|
sub getDir {
|
||||||
my ( $var, $def ) = @_;
|
my ( $var, $def ) = @_;
|
||||||
|
|
||||||
|
# If Environment variables(e.g. UB_RESULTDIR) is unset, use default value.
|
||||||
my $val = $ENV{$var} || $def;
|
my $val = $ENV{$var} || $def;
|
||||||
|
|
||||||
# Canonicalise the value.
|
# Only "execl.c" test needs the Environment variable(UB_BINDIR).
|
||||||
my $wd;
|
|
||||||
chomp($wd = `pwd`);
|
|
||||||
chdir($val);
|
|
||||||
chomp($val = `pwd`);
|
|
||||||
chdir($wd);
|
|
||||||
$ENV{$var} = $val;
|
$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 {
|
sub logFile {
|
||||||
my ( $sysInfo ) = @_;
|
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.
|
# Use the date in the base file name.
|
||||||
my $ymd = strftime "%Y-%m-%d", localtime;
|
my $ymd = strftime "%Y-%m-%d", localtime;
|
||||||
|
|
||||||
|
my $count = 1;
|
||||||
while (1) {
|
while (1) {
|
||||||
my $log = sprintf "%s/%s-%s-%02d",
|
my $log = sprintf "%s/%s-%s-%02d",
|
||||||
${RESULTDIR}, $sysInfo->{'name'}, $ymd, $count;
|
${RESULTDIR}, $sysInfo->{'name'}, $ymd, $count;
|
||||||
@ -1872,6 +1896,10 @@ sub main {
|
|||||||
$tests = $index;
|
$tests = $index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create directories.
|
||||||
|
my @creatingDirectories = ( ${TMPDIR}, ${RESULTDIR} );
|
||||||
|
createDirrectoriesIfNotExists(@creatingDirectories);
|
||||||
|
|
||||||
preChecks();
|
preChecks();
|
||||||
my $systemInfo = getSystemInfo();
|
my $systemInfo = getSystemInfo();
|
||||||
|
|
||||||
@ -1888,6 +1916,11 @@ sub main {
|
|||||||
# Display the program banner.
|
# Display the program banner.
|
||||||
system("cat \"${BINDIR}/unixbench.logo\"");
|
system("cat \"${BINDIR}/unixbench.logo\"");
|
||||||
|
|
||||||
|
# Show output output directories, if not in quiet mode.
|
||||||
|
if ($verbose > 0) {
|
||||||
|
printUsingDirectories();
|
||||||
|
}
|
||||||
|
|
||||||
if ($verbose > 1) {
|
if ($verbose > 1) {
|
||||||
printf "\n", join(", ", @$tests);
|
printf "\n", join(", ", @$tests);
|
||||||
printf "Tests to run: %s\n", join(", ", @$tests);
|
printf "Tests to run: %s\n", join(", ", @$tests);
|
||||||
|
@ -65,7 +65,11 @@ so that randomly-churning background processes don't randomise the results
|
|||||||
too much. This is particularly true for the graphics tests.
|
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 setting the following environment variables:
|
||||||
|
|
||||||
|
* "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.
|
||||||
* "UB_OUTPUT_CSV" : If set "true", output results(score only) to .csv.
|
* "UB_OUTPUT_CSV" : If set "true", output results(score only) to .csv.
|
||||||
============================================================================
|
============================================================================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user