@ -1,13 +1,16 @@
# This script enables you running RocksDB tests by running
# This script enables you running RocksDB tests by running
# All the tests concurrently and utilizing all the cores
# All the tests concurrently and utilizing all the cores
Param (
Param (
[switch] $EnableJE = $false , # Look for and use _je executable, append _je to listed exclusions
[switch] $EnableJE = $false , # Look for and use test executable, append _je to listed exclusions
[switch] $RunAll = $false , # Will attempt discover all *_test[_je].exe binaries and run all
[switch] $RunAll = $false , # Will attempt discover all *_test[_je].exe binaries and run all
# of them as Google suites. I.e. It will run test cases concurrently
# of them as Google suites. I.e. It will run test cases concurrently
# except those mentioned as $Run, those will run as individual test cases
# except those mentioned as $Run, those will run as individual test cases
# And any execlued with $ExcludeExes or $ExcludeCases
# And any execlued with $ExcludeExes or $ExcludeCases
# It will also not run any individual test cases
# It will also not run any individual test cases
# excluded but $ExcludeCasese
# excluded but $ExcludeCasese
[switch] $RunAllExe = $false , # Look for and use test exdcutables, append _je to exclusions automatically
# It will attempt to run them in parallel w/o breaking them up on individual
# test cases. Those listed with $ExcludeExes will be excluded
[string] $SuiteRun = " " , # Split test suites in test cases and run in parallel, not compatible with $RunAll
[string] $SuiteRun = " " , # Split test suites in test cases and run in parallel, not compatible with $RunAll
[string] $Run = " " , # Run specified executables in parallel but do not split to test cases
[string] $Run = " " , # Run specified executables in parallel but do not split to test cases
[string] $ExcludeCases = " " , # Exclude test cases, expects a comma separated list, no spaces
[string] $ExcludeCases = " " , # Exclude test cases, expects a comma separated list, no spaces
@ -39,13 +42,18 @@ $RunOnly.Add("compact_on_deletion_collector_test") | Out-Null
$RunOnly . Add ( " merge_test " ) | Out-Null
$RunOnly . Add ( " merge_test " ) | Out-Null
$RunOnly . Add ( " stringappend_test " ) | Out-Null # Apparently incorrectly written
$RunOnly . Add ( " stringappend_test " ) | Out-Null # Apparently incorrectly written
$RunOnly . Add ( " backupable_db_test " ) | Out-Null # Disabled
$RunOnly . Add ( " backupable_db_test " ) | Out-Null # Disabled
$RunOnly . Add ( " timer_queue_test " ) | Out-Null # Not a gtest
if ( $RunAll -and $SuiteRun -ne " " ) {
if ( $RunAll -and $SuiteRun -ne " " ) {
Write-Error " $ RunAll and $ SuiteRun are not compatible "
Write-Error " $ RunAll and $ SuiteRun are not compatible "
exit 1
exit 1
}
}
if ( $RunAllExe -and $Run -ne " " ) {
Write-Error " $ RunAllExe and $ Run are not compatible "
exit 1
}
# If running under Appveyor assume that root
# If running under Appveyor assume that root
[string] $Appveyor = $Env:APPVEYOR_BUILD_FOLDER
[string] $Appveyor = $Env:APPVEYOR_BUILD_FOLDER
if ( $Appveyor -ne " " ) {
if ( $Appveyor -ne " " ) {
@ -131,12 +139,8 @@ function ExtractTestCases([string]$GTestExe, $HashTable) {
# Leading whitespace is fine
# Leading whitespace is fine
$l = $l -replace '^\s+' , ''
$l = $l -replace '^\s+' , ''
# but no whitespace any other place
if ( $l -match " \s+ " ) {
continue
}
# Trailing dot is a test group but no whitespace
# Trailing dot is a test group but no whitespace
else if ( $l -match " \. $ " ) {
if ( $l -match " \. $ " -and $l -notmatch " \s+ " ) {
$Group = $l
$Group = $l
} else {
} else {
# Otherwise it is a test name, remove leading space
# Otherwise it is a test name, remove leading space
@ -223,13 +227,11 @@ $TestExes = [ordered]@{}
if ( $Run -ne " " ) {
if ( $Run -ne " " ) {
$test_list = $Run -split ' '
$test_list = $Run -split ' '
ForEach ( $t in $test_list ) {
ForEach ( $t in $test_list ) {
if ( $EnableJE ) {
if ( $EnableJE ) {
$t + = " _je "
$t + = " _je "
}
}
MakeAndAdd -token $t -HashTable $TestExes
MakeAndAdd -token $t -HashTable $TestExes
}
}
@ -237,6 +239,38 @@ if($Run -ne "") {
Write-Error " Failed to extract tests from $ Run "
Write-Error " Failed to extract tests from $ Run "
exit 1
exit 1
}
}
} elseif ( $RunAllExe ) {
# Discover all the test binaries
if ( $EnableJE ) {
$pattern = " *_test_je.exe "
} else {
$pattern = " *_test.exe "
}
$search_path = -join ( $BinariesFolder , $pattern )
Write-Host " Binaries Search Path: $ search_path "
$DiscoveredExe = @ ( )
dir -Path $search_path | ForEach-Object {
$DiscoveredExe + = ( $_ . Name )
}
# Remove exclusions
ForEach ( $e in $DiscoveredExe ) {
$e = $e -replace '.exe$' , ''
$bare_name = $e -replace '_je$' , ''
if ( $ExcludeExesSet . Contains ( $bare_name ) ) {
Write-Warning " Test $ e is excluded "
continue
}
MakeAndAdd -token $e -HashTable $TestExes
}
if ( $TestExes . Count -lt 1 ) {
Write-Error " Failed to discover test executables "
exit 1
}
}
}
# Ordered by exe @{ Exe = @{ TestCase = LogName }}
# Ordered by exe @{ Exe = @{ TestCase = LogName }}
@ -245,9 +279,7 @@ $CasesToRun = [ordered]@{}
if ( $SuiteRun -ne " " ) {
if ( $SuiteRun -ne " " ) {
$suite_list = $SuiteRun -split ' '
$suite_list = $SuiteRun -split ' '
ProcessSuites -ListOfSuites $suite_list -HashOfHashes $CasesToRun
ProcessSuites -ListOfSuites $suite_list -HashOfHashes $CasesToRun
}
} elseif ( $RunAll ) {
if ( $RunAll ) {
# Discover all the test binaries
# Discover all the test binaries
if ( $EnableJE ) {
if ( $EnableJE ) {
$pattern = " *_test_je.exe "
$pattern = " *_test_je.exe "
@ -255,7 +287,6 @@ if($RunAll) {
$pattern = " *_test.exe "
$pattern = " *_test.exe "
}
}
$search_path = -join ( $BinariesFolder , $pattern )
$search_path = -join ( $BinariesFolder , $pattern )
Write-Host " Binaries Search Path: $ search_path "
Write-Host " Binaries Search Path: $ search_path "
@ -287,8 +318,6 @@ if($RunAll) {
}
}
Write-Host " Attempting to start: $ NumTestsToStart tests "
# Invoke a test with a filter and redirect all output
# Invoke a test with a filter and redirect all output
$InvokeTestCase = {
$InvokeTestCase = {
param ( $exe , $test , $log ) ;
param ( $exe , $test , $log ) ;
@ -365,6 +394,7 @@ function RunJobs($Suites, $TestCmds, [int]$ConcurrencyVal)
break
break
}
}
Write-Host " Starting $ exe_name "
[string] $Exe = -Join ( $BinariesFolder , $exe_name )
[string] $Exe = -Join ( $BinariesFolder , $exe_name )
$job = Start-Job -Name $exe_name -ScriptBlock $InvokeTestAsync -ArgumentList @ ( $Exe , $log_path )
$job = Start-Job -Name $exe_name -ScriptBlock $InvokeTestAsync -ArgumentList @ ( $Exe , $log_path )
$JobToLog . Add ( $job , $log_path )
$JobToLog . Add ( $job , $log_path )