summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2015-03-17 16:15:37 +0000
committerStephen D. Huston <shuston@apache.org>2015-03-17 16:15:37 +0000
commit3bc275dae987e84b4753d4e1bf2db29db82fbe15 (patch)
treee2a6cfbb874af07ac9684d98faa0593774bec569 /cpp
parentb9553523037f69cb8f0c2bc14b8ab195eb631843 (diff)
downloadqpid-python-3bc275dae987e84b4753d4e1bf2db29db82fbe15.tar.gz
Align run_test shell and Powershell versions. Changes the option syntax from two-hyphen to one. Fixes QPID-6399.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1667349 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/tests/CMakeLists.txt24
-rwxr-xr-xcpp/src/tests/run_test46
-rw-r--r--cpp/src/tests/run_test.ps1152
-rw-r--r--cpp/src/tests/test_env.ps1.in12
4 files changed, 165 insertions, 69 deletions
diff --git a/cpp/src/tests/CMakeLists.txt b/cpp/src/tests/CMakeLists.txt
index f3443aa57e..20f98204a4 100644
--- a/cpp/src/tests/CMakeLists.txt
+++ b/cpp/src/tests/CMakeLists.txt
@@ -148,8 +148,8 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows)
set (shell "powershell")
endif (CMAKE_SYSTEM_NAME STREQUAL Windows)
-set(test_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} --build-dir=${CMAKE_BINARY_DIR})
-set(python_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} --build-dir=${CMAKE_BINARY_DIR} --python)
+set(test_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} -buildDir ${CMAKE_BINARY_DIR})
+set(python_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} -buildDir ${CMAKE_BINARY_DIR} -python)
if (BUILD_TESTING_UNITTESTS)
@@ -242,7 +242,7 @@ target_link_libraries (unit_test
set_target_properties (unit_test PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER)
remember_location(unit_test)
-add_test (unit_test ${test_wrap} --boost-test -- ${unit_test_LOCATION})
+add_test (unit_test ${test_wrap} -boostTest -- ${unit_test_LOCATION})
endif (BUILD_TESTING_UNITTESTS)
@@ -348,14 +348,14 @@ if (BUILD_SASL)
add_test(ssl_test ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/ssl_test${test_script_suffix})
endif (BUILD_SSL)
endif (BUILD_SASL)
-add_test (qpid-client-test ${test_wrap} --start-broker -- ${qpid-client-test_LOCATION})
-add_test (quick_perftest ${test_wrap} --start-broker -- ${qpid-perftest_LOCATION} --summary --count 100)
-add_test (quick_topictest ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/quick_topictest${test_script_suffix})
-add_test (quick_txtest ${test_wrap} --start-broker -- ${qpid-txtest_LOCATION} --queues 4 --tx-count 10 --quiet)
-add_test (quick_txtest2 ${test_wrap} --start-broker -- ${qpid-txtest2_LOCATION} --queues 4 --tx-count 10 --quiet)
-add_test (msg_group_tests ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_msg_group_tests${test_script_suffix})
-add_test (run_header_test ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix})
-add_test (python_tests ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/python_tests${test_script_suffix})
+add_test (qpid-client-test ${test_wrap} -startBroker -- ${qpid-client-test_LOCATION})
+add_test (quick_perftest ${test_wrap} -startBroker -- ${qpid-perftest_LOCATION} --summary --count 100)
+add_test (quick_topictest ${test_wrap} -startBroker -- ${CMAKE_CURRENT_SOURCE_DIR}/quick_topictest${test_script_suffix})
+add_test (quick_txtest ${test_wrap} -startBroker -- ${qpid-txtest_LOCATION} --queues 4 --tx-count 10 --quiet)
+add_test (quick_txtest2 ${test_wrap} -startBroker -- ${qpid-txtest2_LOCATION} --queues 4 --tx-count 10 --quiet)
+add_test (msg_group_tests ${test_wrap} -startBroker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_msg_group_tests${test_script_suffix})
+add_test (run_header_test ${test_wrap} -startBroker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix})
+add_test (python_tests ${test_wrap} -startBroker -- ${CMAKE_CURRENT_SOURCE_DIR}/python_tests${test_script_suffix})
if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
# paged queue not yet implemented for windows
add_test (paged_queue_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_paged_queue_tests${test_script_suffix})
@@ -377,7 +377,7 @@ add_test (federation_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_federation_t
add_test (federation_sys_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_federation_sys_tests${test_script_suffix})
add_test (queue_flow_limit_tests
${test_wrap}
- --start-broker "--broker-options=--default-flow-stop-threshold=80 --default-flow-resume-threshold=70"
+ -startBroker -brokerOptions "--default-flow-stop-threshold=80 --default-flow-resume-threshold=70"
-- ${CMAKE_CURRENT_SOURCE_DIR}/run_queue_flow_limit_tests${test_script_suffix})
if (BUILD_ACL)
add_test (acl_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_acl_tests${test_script_suffix})
diff --git a/cpp/src/tests/run_test b/cpp/src/tests/run_test
index acb1714b0e..8e397b3458 100755
--- a/cpp/src/tests/run_test
+++ b/cpp/src/tests/run_test
@@ -34,17 +34,17 @@
wrapper="Qpid Test Wrapper"
function usage {
echo "Usage:"
- echo " --working-dir DIR"
- echo " --build-dir DIR"
- echo " --source-dir DIR"
- echo " --python - run python script"
- echo " --boost-test - run boost unit test"
- echo " --xml - XML output from tests"
- echo " --start-broker - start/stop broker before/after test"
- echo " --broker-options - use these extra options when starting broker"
- echo " --help - print this message"
- echo " -- - This is required to separate the wrapped command"
- echo " from the test parameters"
+ echo " -workingDir DIR"
+ echo " -buildDir DIR"
+ echo " -sourceDir DIR"
+ echo " -python - run python script"
+ echo " -boostTest - run boost unit test"
+ echo " -xml - XML output from tests"
+ echo " -startBroker - start/stop broker before/after test"
+ echo " -brokerOptions - use these extra options when starting broker"
+ echo " -help - print this message"
+ echo " -- - This is required to separate the wrapped command"
+ echo " from the test parameters"
}
function illegal_option {
@@ -66,21 +66,21 @@ working_dir='.'
while true; do
case "$1" in
--) shift; break ;;
- # Split up any parameters expressed as --blah=foo
+ # Split up any parameters expressed as -blah=foo
# and process them next time round the loop
- --*=*) option=${1%%=*}; param=${1#*=}
+ -*=*) option=${1%%=*}; param=${1#*=}
shift;
set -- "$option" "$param" "$@" ;;
- --working-dir) working_dir=$2; shift 2 ;;
- --build-dir) build_dir=$2; shift 2 ;;
- --source-dir) source_dir=$2; shift 2 ;;
- --python) run_python=yes; shift ;;
- --boost-test) boost_test=yes; shift ;;
- --xml) xml_output=yes; shift ;;
- --start-broker) start_broker=yes; shift ;;
- --broker-options) qpidd_extra_options=$2; shift 2 ;;
- --help) usage; exit 0; ;;
- --*) illegal_option "$1"; exit 1; ;;
+ -workingDir) working_dir=$2; shift 2 ;;
+ -buildDir) build_dir=$2; shift 2 ;;
+ -sourceDir) source_dir=$2; shift 2 ;;
+ -python) run_python=yes; shift ;;
+ -boostTest) boost_test=yes; shift ;;
+ -xml) xml_output=yes; shift ;;
+ -startBroker) start_broker=yes; shift ;;
+ -brokerOptions) qpidd_extra_options=$2; shift 2 ;;
+ -help) usage; exit 0; ;;
+ -*) illegal_option "$1"; exit 1; ;;
'') no_command; exit 1; ;;
*) ignored_argument "$1"; shift; ;;
esac
diff --git a/cpp/src/tests/run_test.ps1 b/cpp/src/tests/run_test.ps1
index 872e1dddb1..ff103e4556 100644
--- a/cpp/src/tests/run_test.ps1
+++ b/cpp/src/tests/run_test.ps1
@@ -17,52 +17,146 @@
# under the License.
#
-$srcdir = Split-Path $myInvocation.InvocationName
+param(
+ [string]$workingDir = $pwd,
+ [string]$buildDir = $(throw "-buildDir is required"),
+ [string]$sourceDir,
+ [switch]$python = $false,
+ [switch]$boostTest = $false,
+ [switch]$xml,
+ [switch]$startBroker = $false,
+ [string]$brokerOptions,
+ [switch]$help,
+ [Parameter(Mandatory=$true, ValueFromRemainingArguments=$true, Position=0)]
+ [String[]]$rest
+ )
+if ([string]::IsNullOrEmpty($sourceDir)) {
+ $sourceDir = Split-Path $myInvocation.InvocationName
+}
+
+if ([string]::IsNullOrEmpty($xml)) {
+ $xml = Test-Path variable:global:QPID_XML_TEST_OUTPUT
+}
+
# Set up environment and run a test executable or script.
. .\test_env.ps1
+if ($rest[0] -eq $null) {
+ "No wrapped command specified"
+ exit 1
+}
# The test exe is probably not in the current binary dir - it's usually
# placed in a subdirectory based on the configuration built in Visual Studio.
# So check around to see where it is - when located, set the QPID_LIB_DIR
# and PATH to look in the corresponding configuration off the src directory,
# one level up.
-$prog = $args[0]
+$prog = $rest[0]
+$logfilebase = [System.IO.Path]::GetFileNameWithoutExtension($prog)
+$logfilebase = "$pwd\\$logfilebase"
+# Qpid client lib sees QPID_LOG_TO_FILE; acts like using --log-to-file on
+# command line.
+$env:QPID_LOG_TO_FILE = "$logfilebase.log"
$is_script = $prog -match ".ps1$"
+if (($is_script -or $python) -and !(Test-Path "$prog")) {
+ "$prog does not exist"
+ exit 1
+}
if (!$is_script -and !(Test-Path "$prog")) {
- . $srcdir\find_prog.ps1 $prog
- $args[0] = $prog
+ . $sourceDir\find_prog.ps1 $prog
+ $rest[0] = $prog
$env:QPID_LIB_DIR = "..\$sub"
- $env:PATH += ";$dir\$sub;..\$sub"
}
-# If qpidd.port exists and is not empty run test with QPID_PORT set.
-if (Test-Path qpidd.port) {
- set-item -path env:QPID_PORT -value (get-content -path qpidd.port -totalcount 1)
+# Set up environment for running a Qpid test. If a broker should be started,
+# do that, else check for a saved port number to use.
+if ($startBroker) {
+ $broker = new-object System.Diagnostics.ProcessStartInfo
+ $broker.WorkingDirectory = $pwd
+ $broker.UseShellExecute = $false
+ $broker.CreateNoWindow = $true
+ $broker.RedirectStandardOutput = $true
+ $broker.FileName = $env:QPIDD_EXEC
+ $broker.Arguments = "--auth=no --no-module-dir --port=0 --interface 127.0.0.1 --log-to-file $logfilebase-qpidd.log $brokerOptions"
+ $broker_process = [System.Diagnostics.Process]::Start($broker)
+ $env:QPID_PORT = $broker_process.StandardOutput.ReadLine()
+}
+else {
+ # If qpidd.port exists and is not empty run test with QPID_PORT set.
+ if (Test-Path qpidd.port) {
+ set-item -path env:QPID_PORT -value (get-content -path qpidd.port -totalcount 1)
+ }
+}
+
+# Now start the real test.
+if ($python) {
+ $to_run = $PYTHON_EXE
+ $skip_args0 = $false
+ $outputfile = ""
+}
+elseif ($boostTest) {
+ if ($xml) {
+ $env:BOOST_TEST_SHOW_PROGRESS=no
+ $env:BOOST_TEST_OUTPUT_FORMAT=XML
+ $env:BOOST_TEST_LOG_LEVEL=test_suite
+ $env:BOOST_TEST_REPORT_LEVEL=no
+ $to_run = $rest[0]
+ $skip_args0 = $true
+ $outputfile = "$logfilebase-unittest.xml"
+ }
+ else {
+ $to_run = $rest[0]
+ $skip_args0 = $true
+ $outputfile = ""
+ }
+}
+else {
+ # Non-boost executable or powershell script
+ $outputfile = ""
+ if ($is_script) {
+ $to_run = (get-command powershell.exe).Definition
+ $skip_args0 = $false
+ }
+ else {
+ $to_run = $rest[0]
+ $skip_args0 = $true
+ }
+}
+
+if ($skip_args0) {
+ $arglist = $rest[1..($rest.length-1)]
+}
+else {
+ $arglist = $rest
}
-$si = new-object System.Diagnostics.ProcessStartInfo
-$si.WorkingDirectory = $pwd
-$si.UseShellExecute = $false
-$si.CreateNoWindow = $true
-$si.RedirectStandardOutput = $true
-if ($is_script) {
- $si.FileName = (get-command powershell.exe).Definition
- $si.Arguments = $args
+if ($outputfile -eq "") {
+ $p = Start-Process -FilePath $to_run -ArgumentList $arglist -NoNewWindow -PassThru
+ $line = ""
}
else {
- $si.FileName = $args[0]
- if ($args.length -gt 1) {
- $si.Arguments = $args[1..($args.length-1)]
- }
-}
-$p = [System.Diagnostics.Process]::Start($si)
-$line = ""
-while (($line = $p.StandardOutput.ReadLine()) -ne $null) {
- $line
-}
-# ReadToEnd() works, but doesn't show any output until the program exits.
-#$p.StandardOutput.ReadToEnd()
-$p.WaitForExit()
+ $p = Start-Process -FilePath $to_run -ArgumentList $arglist -NoNewWindow -RedirectStandardOutput $outputfile -PassThru
+}
+Wait-Process -InputObject $p
$status = $p.ExitCode
+
+if (Test-Path $env:QPID_LOG_TO_FILE) {
+ $problems = Select-String -Path $env:QPID_LOG_TO_FILE -pattern " error ", " warning ", " critical "
+ if ($problems -ne $null) {
+ "WARNING: suspicious log entries in $env:QPID_LOG_TO_FILE:\n$problems"
+ $status = 1
+ }
+}
+
+# If a broker was started, stop it.
+if ($startBroker) {
+ & $env:QPIDD_EXEC --no-module-dir --quit
+ # Check qpid log for problems
+ $problems = Select-String -Path $logfilebase-qpidd.log -pattern " error ", " warning ", " critical "
+ if ($problems -ne $null) {
+ "WARNING: suspicious log entries in $logfilebase-qpidd.log:\n$problems"
+ $status = 1
+ }
+}
+
exit $status
diff --git a/cpp/src/tests/test_env.ps1.in b/cpp/src/tests/test_env.ps1.in
index 12373b5b35..94834a4b5e 100644
--- a/cpp/src/tests/test_env.ps1.in
+++ b/cpp/src/tests/test_env.ps1.in
@@ -18,14 +18,16 @@
#
# Environment variables substituted by configure/cmake.
-$srcdir="@abs_srcdir@"
-$builddir="@abs_builddir@"
+$abs_srcdir="@abs_srcdir@"
+$abs_builddir="@abs_builddir@"
$top_srcdir="@abs_top_srcdir@"
$top_builddir="@abs_top_builddir@"
$moduledir="$top_builddir\src@builddir_lib_suffix@"
$testmoduledir="$builddir@builddir_lib_suffix@"
+$BOOST_LIBRARYDIR="@BOOST_LIBRARYDIR@"
# Python paths and directories
+$PYTHON_EXE="@PYTHON_EXECUTABLE@"
$PYTHON_DIR="$builddir\python"
$QPID_PYTHON_TEST="$PYTHON_DIR\commands\qpid-python-test"
if ( !(Test-Path "$PYTHON_DIR") -and (Test-Path "$top_srcdir\..\python")) {
@@ -44,16 +46,16 @@ $QPID_ROUTE_EXEC="$PYTHON_COMMANDS\qpid-route"
$QPID_HA_TOOL_EXEC="$PYTHON_COMMANDS\qpid-ha-tool"
# Executables
-$env:QPIDD_EXEC="$top_builddir\src\qpidd"
+$env:QPIDD_EXEC="$top_builddir\src\@CMAKE_BUILD_TYPE@\qpidd.exe"
$env:QPID_WATCHDOG_EXEC="$top_builddir\src\qpidd_watchdog"
# Test executables
-$QPID_TEST_EXEC_DIR="$builddir"
+$QPID_TEST_EXEC_DIR="$builddir\@CMAKE_BUILD_TYPE@"
$RECEIVER_EXEC="$QPID_TEST_EXEC_DIR\receiver"
$SENDER_EXEC="$QPID_TEST_EXEC_DIR\sender"
# Path
-$env:PATH="$top_builddir\src;$builddir;$srcdir;$PYTHON_COMMANDS;$QPID_TEST_EXEC_DIR;$env:PATH"
+$env:PATH="$top_builddir\src\@CMAKE_BUILD_TYPE@;$builddir\@CMAKE_BUILD_TYPE@;$srcdir;$PYTHON_COMMANDS;$QPID_TEST_EXEC_DIR;@BOOST_LIBRARYDIR@;$env:PATH"
# Modules
$env:TEST_STORE_LIB="$testmoduledir\test_store.so"