2019-04-18 17:51:19 +00:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
2015-10-02 18:33:35 +00:00
|
|
|
# This script enables you running RocksDB tests by running
|
2017-04-05 18:22:36 +00:00
|
|
|
# All the tests concurrently and utilizing all the cores
|
2015-10-02 18:33:35 +00:00
|
|
|
Param(
|
2017-11-10 18:27:35 +00:00
|
|
|
[switch]$EnableJE = $false, # Look for and use test executable, append _je to listed exclusions
|
2017-04-05 18:22:36 +00:00
|
|
|
[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
|
|
|
|
# except those mentioned as $Run, those will run as individual test cases
|
|
|
|
# And any execlued with $ExcludeExes or $ExcludeCases
|
|
|
|
# It will also not run any individual test cases
|
|
|
|
# excluded but $ExcludeCasese
|
2017-11-10 18:27:35 +00:00
|
|
|
[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
|
2017-04-05 18:22:36 +00:00
|
|
|
[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]$ExcludeCases = "", # Exclude test cases, expects a comma separated list, no spaces
|
|
|
|
# Takes effect when $RunAll or $SuiteRun is specified. Must have full
|
|
|
|
# Test cases name including a group and a parameter if any
|
|
|
|
[string]$ExcludeExes = "", # Exclude exes from consideration, expects a comma separated list,
|
|
|
|
# no spaces. Takes effect only when $RunAll is specified
|
|
|
|
[string]$WorkFolder = "", # Direct tests to use that folder. SSD or Ram drive are better options.
|
2015-11-05 22:03:41 +00:00
|
|
|
# Number of async tasks that would run concurrently. Recommend a number below 64.
|
|
|
|
# However, CPU utlization really depends on the storage media. Recommend ram based disk.
|
2015-11-12 22:42:38 +00:00
|
|
|
# a value of 1 will run everything serially
|
2017-04-05 18:22:36 +00:00
|
|
|
[int]$Concurrency = 8,
|
|
|
|
[int]$Limit = -1 # -1 means do not limit for test purposes
|
2015-10-02 18:33:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Folders and commands must be fullpath to run assuming
|
|
|
|
# the current folder is at the root of the git enlistment
|
2017-04-05 18:22:36 +00:00
|
|
|
$StartDate = (Get-Date)
|
|
|
|
$StartDate
|
|
|
|
|
|
|
|
|
|
|
|
$DebugPreference = "Continue"
|
|
|
|
|
|
|
|
# These tests are not google test suites and we should guard
|
|
|
|
# Against running them as suites
|
|
|
|
$RunOnly = New-Object System.Collections.Generic.HashSet[string]
|
|
|
|
$RunOnly.Add("c_test") | Out-Null
|
|
|
|
$RunOnly.Add("compact_on_deletion_collector_test") | Out-Null
|
|
|
|
$RunOnly.Add("merge_test") | Out-Null
|
|
|
|
$RunOnly.Add("stringappend_test") | Out-Null # Apparently incorrectly written
|
|
|
|
$RunOnly.Add("backupable_db_test") | Out-Null # Disabled
|
2017-11-10 18:27:35 +00:00
|
|
|
$RunOnly.Add("timer_queue_test") | Out-Null # Not a gtest
|
2017-04-05 18:22:36 +00:00
|
|
|
|
|
|
|
if($RunAll -and $SuiteRun -ne "") {
|
|
|
|
Write-Error "$RunAll and $SuiteRun are not compatible"
|
|
|
|
exit 1
|
|
|
|
}
|
2015-10-02 18:33:35 +00:00
|
|
|
|
2017-11-10 18:27:35 +00:00
|
|
|
if($RunAllExe -and $Run -ne "") {
|
|
|
|
Write-Error "$RunAllExe and $Run are not compatible"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2015-10-02 18:33:35 +00:00
|
|
|
# If running under Appveyor assume that root
|
|
|
|
[string]$Appveyor = $Env:APPVEYOR_BUILD_FOLDER
|
|
|
|
if($Appveyor -ne "") {
|
|
|
|
$RootFolder = $Appveyor
|
|
|
|
} else {
|
|
|
|
$RootFolder = $PSScriptRoot -replace '\\build_tools', ''
|
|
|
|
}
|
|
|
|
|
|
|
|
$LogFolder = -Join($RootFolder, "\db_logs\")
|
|
|
|
$BinariesFolder = -Join($RootFolder, "\build\Debug\")
|
|
|
|
|
|
|
|
if($WorkFolder -eq "") {
|
|
|
|
|
|
|
|
# If TEST_TMPDIR is set use it
|
|
|
|
[string]$var = $Env:TEST_TMPDIR
|
|
|
|
if($var -eq "") {
|
|
|
|
$WorkFolder = -Join($RootFolder, "\db_tests\")
|
|
|
|
$Env:TEST_TMPDIR = $WorkFolder
|
|
|
|
} else {
|
|
|
|
$WorkFolder = $var
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
# Override from a command line
|
|
|
|
$Env:TEST_TMPDIR = $WorkFolder
|
|
|
|
}
|
|
|
|
|
2016-03-23 23:33:57 +00:00
|
|
|
Write-Output "Root: $RootFolder, WorkFolder: $WorkFolder"
|
2017-04-05 18:22:36 +00:00
|
|
|
Write-Output "BinariesFolder: $BinariesFolder, LogFolder: $LogFolder"
|
2016-03-23 23:33:57 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
# Create test directories in the current folder
|
|
|
|
md -Path $WorkFolder -ErrorAction Ignore | Out-Null
|
|
|
|
md -Path $LogFolder -ErrorAction Ignore | Out-Null
|
2016-03-23 23:33:57 +00:00
|
|
|
|
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
$ExcludeCasesSet = New-Object System.Collections.Generic.HashSet[string]
|
|
|
|
if($ExcludeCases -ne "") {
|
|
|
|
Write-Host "ExcludeCases: $ExcludeCases"
|
|
|
|
$l = $ExcludeCases -split ' '
|
|
|
|
ForEach($t in $l) {
|
|
|
|
$ExcludeCasesSet.Add($t) | Out-Null
|
|
|
|
}
|
2015-10-02 18:33:35 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
$ExcludeExesSet = New-Object System.Collections.Generic.HashSet[string]
|
|
|
|
if($ExcludeExes -ne "") {
|
|
|
|
Write-Host "ExcludeExe: $ExcludeExes"
|
|
|
|
$l = $ExcludeExes -split ' '
|
|
|
|
ForEach($t in $l) {
|
|
|
|
$ExcludeExesSet.Add($t) | Out-Null
|
|
|
|
}
|
2015-10-02 18:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-29 19:22:48 +00:00
|
|
|
# Extract the names of its tests by running db_test with --gtest_list_tests.
|
|
|
|
# This filter removes the "#"-introduced comments, and expands to
|
|
|
|
# fully-qualified names by changing input like this:
|
|
|
|
#
|
|
|
|
# DBTest.
|
|
|
|
# Empty
|
|
|
|
# WriteEmptyBatch
|
|
|
|
# MultiThreaded/MultiThreadedDBTest.
|
|
|
|
# MultiThreaded/0 # GetParam() = 0
|
|
|
|
# MultiThreaded/1 # GetParam() = 1
|
|
|
|
#
|
|
|
|
# into this:
|
|
|
|
#
|
|
|
|
# DBTest.Empty
|
|
|
|
# DBTest.WriteEmptyBatch
|
|
|
|
# MultiThreaded/MultiThreadedDBTest.MultiThreaded/0
|
|
|
|
# MultiThreaded/MultiThreadedDBTest.MultiThreaded/1
|
2017-04-05 18:22:36 +00:00
|
|
|
#
|
2015-10-02 18:33:35 +00:00
|
|
|
# Output into the parameter in a form TestName -> Log File Name
|
2017-04-05 18:22:36 +00:00
|
|
|
function ExtractTestCases([string]$GTestExe, $HashTable) {
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-10-02 18:33:35 +00:00
|
|
|
$Tests = @()
|
|
|
|
# Run db_test to get a list of tests and store it into $a array
|
2017-04-05 18:22:36 +00:00
|
|
|
&$GTestExe --gtest_list_tests | tee -Variable Tests | Out-Null
|
2015-09-29 19:22:48 +00:00
|
|
|
|
|
|
|
# Current group
|
|
|
|
$Group=""
|
|
|
|
|
2015-10-02 18:33:35 +00:00
|
|
|
ForEach( $l in $Tests) {
|
2017-04-05 18:22:36 +00:00
|
|
|
|
|
|
|
# Leading whitespace is fine
|
|
|
|
$l = $l -replace '^\s+',''
|
|
|
|
# Trailing dot is a test group but no whitespace
|
2017-11-10 18:27:35 +00:00
|
|
|
if ($l -match "\.$" -and $l -notmatch "\s+") {
|
2015-09-29 19:22:48 +00:00
|
|
|
$Group = $l
|
|
|
|
} else {
|
|
|
|
# Otherwise it is a test name, remove leading space
|
2017-04-05 18:22:36 +00:00
|
|
|
$test = $l
|
2015-09-29 19:22:48 +00:00
|
|
|
# remove trailing comment if any and create a log name
|
|
|
|
$test = $test -replace '\s+\#.*',''
|
|
|
|
$test = "$Group$test"
|
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
if($ExcludeCasesSet.Contains($test)) {
|
|
|
|
Write-Warning "$test case is excluded"
|
2015-09-29 19:22:48 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2015-10-02 18:33:35 +00:00
|
|
|
$test_log = $test -replace '[\./]','_'
|
2015-09-29 19:22:48 +00:00
|
|
|
$test_log += ".log"
|
2015-11-18 02:41:29 +00:00
|
|
|
$log_path = -join ($LogFolder, $test_log)
|
2015-09-29 19:22:48 +00:00
|
|
|
|
|
|
|
# Add to a hashtable
|
2015-11-18 02:41:29 +00:00
|
|
|
$HashTable.Add($test, $log_path);
|
2015-09-29 19:22:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
# The function removes trailing .exe siffix if any,
|
|
|
|
# creates a name for the log file
|
2017-04-05 18:22:36 +00:00
|
|
|
# Then adds the test name if it was not excluded into
|
|
|
|
# a HashTable in a form of test_name -> log_path
|
2015-11-12 22:42:38 +00:00
|
|
|
function MakeAndAdd([string]$token, $HashTable) {
|
2017-04-05 18:22:36 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
$test_name = $token -replace '.exe$', ''
|
|
|
|
$log_name = -join ($test_name, ".log")
|
2015-11-18 02:41:29 +00:00
|
|
|
$log_path = -join ($LogFolder, $log_name)
|
2017-04-05 18:22:36 +00:00
|
|
|
$HashTable.Add($test_name, $log_path)
|
2015-11-12 22:42:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
# This function takes a list of Suites to run
|
|
|
|
# Lists all the test cases in each of the suite
|
|
|
|
# and populates HashOfHashes
|
|
|
|
# Ordered by suite(exe) @{ Exe = @{ TestCase = LogName }}
|
|
|
|
function ProcessSuites($ListOfSuites, $HashOfHashes) {
|
|
|
|
|
|
|
|
$suite_list = $ListOfSuites
|
|
|
|
# Problem: if you run --gtest_list_tests on
|
|
|
|
# a non Google Test executable then it will start executing
|
|
|
|
# and we will get nowhere
|
|
|
|
ForEach($suite in $suite_list) {
|
|
|
|
|
|
|
|
if($RunOnly.Contains($suite)) {
|
|
|
|
Write-Warning "$suite is excluded from running as Google test suite"
|
|
|
|
continue
|
|
|
|
}
|
2015-10-02 18:33:35 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
if($EnableJE) {
|
|
|
|
$suite += "_je"
|
|
|
|
}
|
2015-11-12 22:42:38 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
$Cases = [ordered]@{}
|
|
|
|
$Cases.Clear()
|
|
|
|
$suite_exe = -Join ($BinariesFolder, $suite)
|
|
|
|
ExtractTestCases -GTestExe $suite_exe -HashTable $Cases
|
|
|
|
if($Cases.Count -gt 0) {
|
|
|
|
$HashOfHashes.Add($suite, $Cases);
|
|
|
|
}
|
|
|
|
}
|
2015-11-12 22:42:38 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
# Make logs and run
|
|
|
|
if($CasesToRun.Count -lt 1) {
|
|
|
|
Write-Error "Failed to extract tests from $SuiteRun"
|
|
|
|
exit 1
|
|
|
|
}
|
2015-10-02 18:33:35 +00:00
|
|
|
|
|
|
|
}
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
# This will contain all test executables to run
|
|
|
|
|
|
|
|
# Hash table that contains all non suite
|
|
|
|
# Test executable to run
|
|
|
|
$TestExes = [ordered]@{}
|
|
|
|
|
|
|
|
# Check for test exe that are not
|
|
|
|
# Google Test Suites
|
|
|
|
# Since this is explicitely mentioned it is not subject
|
|
|
|
# for exclusions
|
|
|
|
if($Run -ne "") {
|
|
|
|
|
|
|
|
$test_list = $Run -split ' '
|
|
|
|
ForEach($t in $test_list) {
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
if($EnableJE) {
|
2017-04-05 18:22:36 +00:00
|
|
|
$t += "_je"
|
2015-11-12 22:42:38 +00:00
|
|
|
}
|
2017-04-05 18:22:36 +00:00
|
|
|
MakeAndAdd -token $t -HashTable $TestExes
|
|
|
|
}
|
2015-11-12 22:42:38 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
if($TestExes.Count -lt 1) {
|
|
|
|
Write-Error "Failed to extract tests from $Run"
|
|
|
|
exit 1
|
|
|
|
}
|
2017-11-10 18:27:35 +00:00
|
|
|
} 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
|
|
|
|
}
|
2015-10-02 18:33:35 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
# Ordered by exe @{ Exe = @{ TestCase = LogName }}
|
|
|
|
$CasesToRun = [ordered]@{}
|
|
|
|
|
|
|
|
if($SuiteRun -ne "") {
|
|
|
|
$suite_list = $SuiteRun -split ' '
|
|
|
|
ProcessSuites -ListOfSuites $suite_list -HashOfHashes $CasesToRun
|
2017-11-10 18:27:35 +00:00
|
|
|
} elseif ($RunAll) {
|
2017-04-05 18:22:36 +00:00
|
|
|
# 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"
|
|
|
|
|
|
|
|
$ListOfExe = @()
|
|
|
|
dir -Path $search_path | ForEach-Object {
|
|
|
|
$ListOfExe += ($_.Name)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Exclude those in RunOnly from running as suites
|
|
|
|
$ListOfSuites = @()
|
|
|
|
ForEach($e in $ListOfExe) {
|
|
|
|
|
|
|
|
$e = $e -replace '.exe$', ''
|
|
|
|
$bare_name = $e -replace '_je$', ''
|
|
|
|
|
|
|
|
if($ExcludeExesSet.Contains($bare_name)) {
|
|
|
|
Write-Warning "Test $e is excluded"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2017-05-10 17:18:26 +00:00
|
|
|
if($RunOnly.Contains($bare_name)) {
|
2017-04-05 18:22:36 +00:00
|
|
|
MakeAndAdd -token $e -HashTable $TestExes
|
|
|
|
} else {
|
|
|
|
$ListOfSuites += $bare_name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessSuites -ListOfSuites $ListOfSuites -HashOfHashes $CasesToRun
|
2015-11-12 22:42:38 +00:00
|
|
|
}
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
|
2015-10-02 18:33:35 +00:00
|
|
|
# Invoke a test with a filter and redirect all output
|
|
|
|
$InvokeTestCase = {
|
2015-09-29 19:22:48 +00:00
|
|
|
param($exe, $test, $log);
|
|
|
|
&$exe --gtest_filter=$test > $log 2>&1
|
|
|
|
}
|
|
|
|
|
2015-10-02 18:33:35 +00:00
|
|
|
# Invoke all tests and redirect output
|
|
|
|
$InvokeTestAsync = {
|
|
|
|
param($exe, $log)
|
|
|
|
&$exe > $log 2>&1
|
|
|
|
}
|
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
# Hash that contains tests to rerun if any failed
|
|
|
|
# Those tests will be rerun sequentially
|
2017-04-05 18:22:36 +00:00
|
|
|
# $Rerun = [ordered]@{}
|
2015-09-29 19:22:48 +00:00
|
|
|
# Test limiting factor here
|
2017-04-05 18:22:36 +00:00
|
|
|
[int]$count = 0
|
2015-11-12 22:42:38 +00:00
|
|
|
# Overall status
|
2018-03-06 19:47:42 +00:00
|
|
|
[bool]$script:success = $true;
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
function RunJobs($Suites, $TestCmds, [int]$ConcurrencyVal)
|
2015-11-12 22:42:38 +00:00
|
|
|
{
|
|
|
|
# Array to wait for any of the running jobs
|
|
|
|
$jobs = @()
|
|
|
|
# Hash JobToLog
|
|
|
|
$JobToLog = @{}
|
2015-10-02 18:33:35 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
# Wait for all to finish and get the results
|
|
|
|
while(($JobToLog.Count -gt 0) -or
|
2017-04-05 18:22:36 +00:00
|
|
|
($TestCmds.Count -gt 0) -or
|
|
|
|
($Suites.Count -gt 0)) {
|
2015-10-02 18:33:35 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
# Make sure we have maximum concurrent jobs running if anything
|
|
|
|
# and the $Limit either not set or allows to proceed
|
|
|
|
while(($JobToLog.Count -lt $ConcurrencyVal) -and
|
2017-04-05 18:22:36 +00:00
|
|
|
((($TestCmds.Count -gt 0) -or ($Suites.Count -gt 0)) -and
|
2015-11-12 22:42:38 +00:00
|
|
|
(($Limit -lt 0) -or ($count -lt $Limit)))) {
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
# We always favore suites to run if available
|
|
|
|
[string]$exe_name = ""
|
|
|
|
[string]$log_path = ""
|
|
|
|
$Cases = @{}
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
if($Suites.Count -gt 0) {
|
2017-06-05 18:23:31 +00:00
|
|
|
# Will the first one
|
2017-04-05 18:22:36 +00:00
|
|
|
ForEach($e in $Suites.Keys) {
|
|
|
|
$exe_name = $e
|
|
|
|
$Cases = $Suites[$e]
|
2015-11-12 22:42:38 +00:00
|
|
|
break
|
2017-04-05 18:22:36 +00:00
|
|
|
}
|
|
|
|
[string]$test_case = ""
|
|
|
|
[string]$log_path = ""
|
|
|
|
ForEach($c in $Cases.Keys) {
|
|
|
|
$test_case = $c
|
|
|
|
$log_path = $Cases[$c]
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Host "Starting $exe_name::$test_case"
|
|
|
|
[string]$Exe = -Join ($BinariesFolder, $exe_name)
|
|
|
|
$job = Start-Job -Name "$exe_name::$test_case" -ArgumentList @($Exe,$test_case,$log_path) -ScriptBlock $InvokeTestCase
|
|
|
|
$JobToLog.Add($job, $log_path)
|
|
|
|
|
|
|
|
$Cases.Remove($test_case)
|
|
|
|
if($Cases.Count -lt 1) {
|
|
|
|
$Suites.Remove($exe_name)
|
|
|
|
}
|
|
|
|
|
|
|
|
} elseif ($TestCmds.Count -gt 0) {
|
|
|
|
|
|
|
|
ForEach($e in $TestCmds.Keys) {
|
|
|
|
$exe_name = $e
|
|
|
|
$log_path = $TestCmds[$e]
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2017-11-10 18:27:35 +00:00
|
|
|
Write-Host "Starting $exe_name"
|
2017-04-05 18:22:36 +00:00
|
|
|
[string]$Exe = -Join ($BinariesFolder, $exe_name)
|
|
|
|
$job = Start-Job -Name $exe_name -ScriptBlock $InvokeTestAsync -ArgumentList @($Exe,$log_path)
|
|
|
|
$JobToLog.Add($job, $log_path)
|
|
|
|
|
|
|
|
$TestCmds.Remove($exe_name)
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
} else {
|
2017-04-05 18:22:36 +00:00
|
|
|
Write-Error "In the job loop but nothing to run"
|
|
|
|
exit 1
|
2015-11-12 22:42:38 +00:00
|
|
|
}
|
2015-11-05 22:03:41 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
++$count
|
2017-04-05 18:22:36 +00:00
|
|
|
} # End of Job starting loop
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
if($JobToLog.Count -lt 1) {
|
|
|
|
break
|
|
|
|
}
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
$jobs = @()
|
|
|
|
foreach($k in $JobToLog.Keys) { $jobs += $k }
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
$completed = Wait-Job -Job $jobs -Any
|
|
|
|
$log = $JobToLog[$completed]
|
|
|
|
$JobToLog.Remove($completed)
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
$message = -join @($completed.Name, " State: ", ($completed.State))
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
$log_content = @(Get-Content $log)
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
if($completed.State -ne "Completed") {
|
2018-03-06 19:47:42 +00:00
|
|
|
$script:success = $false
|
2015-09-29 19:22:48 +00:00
|
|
|
Write-Warning $message
|
|
|
|
$log_content | Write-Warning
|
|
|
|
} else {
|
2015-12-10 16:54:48 +00:00
|
|
|
# Scan the log. If we find PASSED and no occurrence of FAILED
|
2015-11-12 22:42:38 +00:00
|
|
|
# then it is a success
|
|
|
|
[bool]$pass_found = $false
|
|
|
|
ForEach($l in $log_content) {
|
|
|
|
|
|
|
|
if(($l -match "^\[\s+FAILED") -or
|
|
|
|
($l -match "Assertion failed:")) {
|
|
|
|
$pass_found = $false
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
if(($l -match "^\[\s+PASSED") -or
|
|
|
|
($l -match " : PASSED$") -or
|
|
|
|
($l -match "^PASS$") -or # Special c_test case
|
|
|
|
($l -match "Passed all tests!") ) {
|
|
|
|
$pass_found = $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$pass_found) {
|
2018-03-06 19:47:42 +00:00
|
|
|
$script:success = $false;
|
2015-11-12 22:42:38 +00:00
|
|
|
Write-Warning $message
|
|
|
|
$log_content | Write-Warning
|
|
|
|
} else {
|
|
|
|
Write-Host $message
|
|
|
|
}
|
2015-09-29 19:22:48 +00:00
|
|
|
}
|
2015-11-12 22:42:38 +00:00
|
|
|
|
|
|
|
# Remove cached job info from the system
|
|
|
|
# Should be no output
|
|
|
|
Receive-Job -Job $completed | Out-Null
|
2015-09-29 19:22:48 +00:00
|
|
|
}
|
2015-11-12 22:42:38 +00:00
|
|
|
}
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
RunJobs -Suites $CasesToRun -TestCmds $TestExes -ConcurrencyVal $Concurrency
|
2015-11-12 22:42:38 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
$EndDate = (Get-Date)
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
New-TimeSpan -Start $StartDate -End $EndDate |
|
|
|
|
ForEach-Object {
|
|
|
|
"Elapsed time: {0:g}" -f $_
|
|
|
|
}
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2015-11-12 22:42:38 +00:00
|
|
|
|
2018-03-06 19:47:42 +00:00
|
|
|
if(!$script:success) {
|
2015-09-29 19:22:48 +00:00
|
|
|
# This does not succeed killing off jobs quick
|
|
|
|
# So we simply exit
|
|
|
|
# Remove-Job -Job $jobs -Force
|
|
|
|
# indicate failure using this exit code
|
2017-04-05 18:22:36 +00:00
|
|
|
exit 1
|
2015-09-29 19:22:48 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 18:22:36 +00:00
|
|
|
exit 0
|
|
|
|
|
2015-12-10 16:54:48 +00:00
|
|
|
|