Author: shuston
Date: Wed Jun  3 20:00:35 2009
New Revision: 781525

URL: http://svn.apache.org/viewvc?rev=781525&view=rev
Log:
Initial capabilities to run test suite on Windows

Added:
    qpid/trunk/qpid/cpp/src/tests/background.ps1
    qpid/trunk/qpid/cpp/src/tests/quick_topictest.ps1
    qpid/trunk/qpid/cpp/src/tests/run_federation_tests.ps1
    qpid/trunk/qpid/cpp/src/tests/run_header_test.ps1
    qpid/trunk/qpid/cpp/src/tests/run_test.ps1
    qpid/trunk/qpid/cpp/src/tests/start_broker.ps1
    qpid/trunk/qpid/cpp/src/tests/stop_broker.ps1
    qpid/trunk/qpid/cpp/src/tests/topictest.ps1
    qpid/trunk/qpid/cpp/src/tests/windows/
    qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp   (with 
props)
Modified:
    qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt

Modified: qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt?rev=781525&r1=781524&r2=781525&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt (original)
+++ qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt Wed Jun  3 20:00:35 2009
@@ -35,8 +35,25 @@
 
 # Like this to work with cmake 2.4 on Unix
 set (qpid_test_boost_libs 
-     boost_regex
-     boost_unit_test_framework)
+     ${Boost_regex_LIBRARY}
+     ${Boost_unit_test_framework_LIBRARY})
+
+# Macro to make it easier to remember where the tests are built
+macro(remember_location testname)
+  set (${testname}_LOCATION 
${CMAKE_CURRENT_BINARY_DIR}/${testname}${CMAKE_EXECUTABLE_SUFFIX})
+endmacro(remember_location)
+
+# Windows uses some process-startup calls to ensure that errors, etc. don't
+# result in error boxes being thrown up. Since it's expected that most test
+# runs will be in scripts, the default is to force these outputs to stderr
+# instead of windows. If you want to remove this code, build without the
+# QPID_WINDOWS_DEFAULT_TEST_OUTPUTS ON.
+if (CMAKE_SYSTEM_NAME STREQUAL Windows)
+  option(QPID_WINDOWS_DEFAULT_TEST_OUTPUTS "Use default error-handling on 
Windows tests" OFF)
+  if (NOT QPID_WINDOWS_DEFAULT_TEST_OUTPUTS)
+    set(platform_test_additions windows/DisableWin32ErrorWindows.cpp)
+  endif (NOT QPID_WINDOWS_DEFAULT_TEST_OUTPUTS)
+endif (CMAKE_SYSTEM_NAME STREQUAL Windows)
 
 #
 # Unit test program
@@ -107,7 +124,8 @@
 #      amqp_0_10/Map.cpp \
 #      amqp_0_10/handlers.cpp 
 
-add_executable (unit_test unit_test ${unit_tests_to_build})
+add_executable (unit_test unit_test
+                ${unit_tests_to_build} ${platform_test_additions})
 # The generally recommended way to add macro settings is to use
 # COMPILE_DEFINITIONS, but it's a rough go to add more than one definition
 # with a value; in this case, assuming that -D works everywhere is easier.
@@ -118,6 +136,7 @@
 target_link_libraries (unit_test
                        ${qpid_test_boost_libs}
                        qpidclient qpidbroker qmfconsole)
+remember_location(unit_test)
 add_dependencies (check unit_test)
 
 add_library (shlibtest MODULE shlibtest.cpp)
@@ -132,115 +151,137 @@
 #
 # Other test programs
 #
-add_executable (perftest perftest.cpp)
+add_executable (perftest perftest.cpp ${platform_test_additions})
 target_link_libraries (perftest qpidclient)
 #perftest_SOURCES=perftest.cpp test_tools.h TestOptions.h ConnectionOptions.h
+remember_location(perftest)
 add_dependencies (check perftest)
 
-add_executable (txtest txtest.cpp)
+add_executable (txtest txtest.cpp ${platform_test_additions})
 target_link_libraries (txtest qpidclient)
 #txtest_SOURCES=txtest.cpp  TestOptions.h ConnectionOptions.h
+remember_location(txtest)
 add_dependencies (check txtest)
 
-add_executable (latencytest latencytest.cpp)
+add_executable (latencytest latencytest.cpp ${platform_test_additions})
 target_link_libraries (latencytest qpidclient)
 #latencytest_SOURCES=latencytest.cpp TestOptions.h ConnectionOptions.h
+remember_location(latencytest)
 add_dependencies (check latencytest)
 
-add_executable (echotest echotest.cpp)
+add_executable (echotest echotest.cpp ${platform_test_additions})
 target_link_libraries (echotest qpidclient)
 #echotest_SOURCES=echotest.cpp TestOptions.h ConnectionOptions.h
+remember_location(echotest)
 add_dependencies (check echotest)
 
-add_executable (client_test client_test.cpp)
+add_executable (client_test client_test.cpp ${platform_test_additions})
 target_link_libraries (client_test qpidclient)
 #client_test_SOURCES=client_test.cpp TestOptions.h ConnectionOptions.h
+remember_location(client_test)
 add_dependencies (check client_test)
 
-add_executable (topic_listener topic_listener.cpp)
+add_executable (topic_listener topic_listener.cpp ${platform_test_additions})
 target_link_libraries (topic_listener qpidclient)
 #topic_listener_SOURCES=topic_listener.cpp TestOptions.h ConnectionOptions.h
+remember_location(topic_listener)
 add_dependencies (check topic_listener)
 
-add_executable (topic_publisher topic_publisher.cpp)
+add_executable (topic_publisher topic_publisher.cpp ${platform_test_additions})
 target_link_libraries (topic_publisher qpidclient)
 #topic_publisher_SOURCES=topic_publisher.cpp TestOptions.h ConnectionOptions.h
+remember_location(topic_publisher)
 add_dependencies (check topic_publisher)
 
-add_executable (publish publish.cpp)
+add_executable (publish publish.cpp ${platform_test_additions})
 target_link_libraries (publish qpidclient)
 #publish_SOURCES=publish.cpp TestOptions.h ConnectionOptions.h
+remember_location(publish)
 add_dependencies (check publish)
 
-add_executable (consume consume.cpp)
+add_executable (consume consume.cpp ${platform_test_additions})
 target_link_libraries (consume qpidclient)
 #consume_SOURCES=consume.cpp  TestOptions.h ConnectionOptions.h
+remember_location(consume)
 add_dependencies (check consume)
 
-add_executable (header_test header_test.cpp)
+add_executable (header_test header_test.cpp ${platform_test_additions})
 target_link_libraries (header_test qpidclient)
 #header_test_SOURCES=header_test.cpp TestOptions.h ConnectionOptions.h
+remember_location(header_test)
 add_dependencies (check header_test)
 
 if (BUILD_CLUSTER)
-  add_executable (failover_soak failover_soak.cpp ForkedBroker.cpp)
+  add_executable (failover_soak failover_soak.cpp ForkedBroker.cpp 
${platform_test_additions})
   target_link_libraries (failover_soak qpidclient)
   #failover_soak_SOURCES=failover_soak.cpp  ForkedBroker.h
+  remember_location(failover_soak)
   add_dependencies (check failover_soak)
 endif (BUILD_CLUSTER)
 
-add_executable (declare_queues declare_queues.cpp)
+add_executable (declare_queues declare_queues.cpp ${platform_test_additions})
 target_link_libraries (declare_queues qpidclient)
+remember_location(declare_queues)
 add_dependencies (check declare_queues)
 
-add_executable (replaying_sender replaying_sender.cpp)
+add_executable (replaying_sender replaying_sender.cpp 
${platform_test_additions})
 target_link_libraries (replaying_sender qpidclient)
+remember_location(replaying_sender)
 add_dependencies (check replaying_sender)
 
-add_executable (resuming_receiver resuming_receiver.cpp)
+add_executable (resuming_receiver resuming_receiver.cpp 
${platform_test_additions})
 target_link_libraries (resuming_receiver qpidclient)
+remember_location(resuming_receiver)
 add_dependencies (check resuming_receiver)
 
-add_executable (txshift txshift.cpp)
+add_executable (txshift txshift.cpp ${platform_test_additions})
 target_link_libraries (txshift qpidclient)
 #txshift_SOURCES=txshift.cpp  TestOptions.h ConnectionOptions.h
+remember_location(txshift)
 add_dependencies (check txshift)
 
-add_executable (txjob txjob.cpp)
+add_executable (txjob txjob.cpp ${platform_test_additions})
 target_link_libraries (txjob qpidclient)
 #txjob_SOURCES=txjob.cpp  TestOptions.h ConnectionOptions.h
+remember_location(txjob)
 add_dependencies (check txjob)
 
-add_executable (receiver receiver.cpp)
+add_executable (receiver receiver.cpp ${platform_test_additions})
 target_link_libraries (receiver qpidclient)
 #receiver_SOURCES=receiver.cpp  TestOptions.h ConnectionOptions.h
+remember_location(receiver)
 add_dependencies (check receiver)
 
-add_executable (sender sender.cpp)
+add_executable (sender sender.cpp ${platform_test_additions})
 target_link_libraries (sender qpidclient)
 #sender_SOURCES=sender.cpp  TestOptions.h ConnectionOptions.h
+remember_location(sender)
 add_dependencies (check sender)
 
 if (CMAKE_SYSTEM_NAME STREQUAL Windows)
-  set (test_script_suffix ".bat")
+  set (ENV{OUTDIR} ${EXECUTABLE_OUTPUT_PATH})
+  set (test_script_suffix ".ps1")
+  set (shell "powershell")
 endif (CMAKE_SYSTEM_NAME STREQUAL Windows)
 
-set(test_wrap ${CMAKE_CURRENT_SOURCE_DIR}/test_wrap${test_script_suffix})
+set(test_wrap ${shell} 
${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix})
 
-add_test (unit_test unit_test)
-add_test (start_broker 
${CMAKE_CURRENT_SOURCE_DIR}/start_broker${test_script_suffix})
-add_test (client_test ${test_wrap} ./client_test)
-add_test (quick_perftest ${test_wrap} ./perftest --summary --count 100)
+add_test (unit_test ${test_wrap} ${unit_test_LOCATION})
+add_test (start_broker ${shell} 
${CMAKE_CURRENT_SOURCE_DIR}/start_broker${test_script_suffix})
+add_test (client_test ${test_wrap} ${client_test_LOCATION})
+add_test (quick_perftest ${test_wrap} ${perftest_LOCATION} --summary --count 
100)
 add_test (quick_topictest ${test_wrap} 
${CMAKE_CURRENT_SOURCE_DIR}/quick_topictest${test_script_suffix})
-add_test (quick_txtest ${test_wrap} ./txtest --queues 4 --tx-count 10 --quiet)
+add_test (quick_txtest ${test_wrap} ${txtest_LOCATION} --queues 4 --tx-count 
10 --quiet)
 if (PYTHON_EXECUTABLE)
-  add_test (run_header_test ${test_wrap} 
${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix})
+  add_test (run_header_test 
${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix})
   add_test (python_tests ${test_wrap} 
${CMAKE_CURRENT_SOURCE_DIR}/python_tests${test_script_suffix})
 endif (PYTHON_EXECUTABLE)
-add_test (stop_broker 
${CMAKE_CURRENT_SOURCE_DIR}/stop_broker${test_script_suffix})
+add_test (stop_broker ${shell} 
${CMAKE_CURRENT_SOURCE_DIR}/stop_broker${test_script_suffix})
 if (PYTHON_EXECUTABLE)
   add_test (federation_tests 
${CMAKE_CURRENT_SOURCE_DIR}/run_federation_tests${test_script_suffix})
+if (BUILD_ACL)
   add_test (acl_tests 
${CMAKE_CURRENT_SOURCE_DIR}/run_acl_tests${test_script_suffix})
+endif (BUILD_ACL)
 endif (PYTHON_EXECUTABLE)
 
 #EXTRA_DIST +=                                                         \

Added: qpid/trunk/qpid/cpp/src/tests/background.ps1
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/background.ps1?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/background.ps1 (added)
+++ qpid/trunk/qpid/cpp/src/tests/background.ps1 Wed Jun  3 20:00:35 2009
@@ -0,0 +1,36 @@
+# From http://ps1.soapyfrog.com/2007/01/22/running-pipelines-in-the-background/
+# Copyright © 2006-2009 Adrian Milliner
+param(
+    [scriptblock] $script,  # scriptblock to run
+    [switch] $inconsole      # don't create a new window
+)
+
+# break out of the script on any errors
+trap { break }
+
+# encode the script to pass to the child process...
+$encodedString = [convert]::ToBase64String(
+    [Text.Encoding]::Unicode.GetBytes([string] $script))
+
+# create a new process
+$p = new-object System.Diagnostics.Process
+
+# create a startinfo object for the process
+$si = new-object System.Diagnostics.ProcessStartInfo
+$si.WorkingDirectory = $pwd
+
+if ($inconsole)
+{ 
+    $si.UseShellExecute = $false
+}
+Else
+{
+    $si.UseShellExecute = $true
+}
+
+# set up the command and arguments to run
+$si.FileName = (get-command powershell.exe).Definition
+$si.Arguments = "-encodedCommand $encodedString"
+
+# and start the powershell process
+[diagnostics.process]::Start($si)

Added: qpid/trunk/qpid/cpp/src/tests/quick_topictest.ps1
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/quick_topictest.ps1?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/quick_topictest.ps1 (added)
+++ qpid/trunk/qpid/cpp/src/tests/quick_topictest.ps1 Wed Jun  3 20:00:35 2009
@@ -0,0 +1,29 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Quick and quiet topic test for make check.
+$srcdir = Split-Path $myInvocation.ScriptName
+$PsHome\powershell $srcdir\topictest.ps1 -subscribers 2 -messages 2 -batches 1 
> topictest.log 2>&1
+if ($LastExitCode != 0) {
+    echo $0 FAILED:
+    cat topictest.log
+    exit $LastExitCode
+}
+rm topictest.log
+exit 0

Added: qpid/trunk/qpid/cpp/src/tests/run_federation_tests.ps1
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/run_federation_tests.ps1?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/run_federation_tests.ps1 (added)
+++ qpid/trunk/qpid/cpp/src/tests/run_federation_tests.ps1 Wed Jun  3 20:00:35 
2009
@@ -0,0 +1,59 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Run the federation tests.
+$srcdir = Split-Path $myInvocation.ScriptName
+$PYTHON_DIR = $srcdir\..\..\..\python
+
+trap stop_brokers INT TERM QUIT
+
+start_brokers() {
+  # Start 2 brokers, saving the port numbers in LOCAL_PORT, REMOTE_PORT.
+  . $srcdir\background.ps1 {
+    ..\Debug\qpidd --auth=no --no-module-dir --port=0 --log-to-file qpidd.log 
$args | foreach { set-content qpidd.port $_ } }
+  while (!(Test-Path qpidd.port)) {
+    Start-Sleep 2
+  }
+  set-item -path env:LOCAL_PORT -value (get-content -path qpidd.port 
-totalcount 1)
+  Remove-Item qpidd.port
+  . $srcdir\background.ps1 {
+    ..\Debug\qpidd --auth=no --no-module-dir --port=0 --log-to-file qpidd.log 
$args | foreach { set-content qpidd.port $_ } }
+  while (!(Test-Path qpidd.port)) {
+    Start-Sleep 2
+  }
+  set-item -path env:REMOTE_PORT -value (get-content -path qpidd.port 
-totalcount 1)
+}
+
+stop_brokers() {
+   ..\Debug\qpidd -q --port $LOCAL_PORT | Out-Default
+   ..\Debug\qpidd -q --port $REMOTE_PORT | Out-Default
+}
+
+if (Test-Path $PYTHON_DIR -pathType Container) {
+    start_brokers
+    "Running federation tests using brokers on ports $LOCAL_PORT $REMOTE_PORT"
+    $env:PYTHONPATH=$PYTHON_DIR
+    $srcdir/federation.py -v -s 
$srcdir\..\..\..\specs\amqp.0-10-qpid-errata.xml -b localhost:$LOCAL_PORT 
--remote-port $REMOTE_PORT $args
+    $RETCODE=$LASTEXITCODE
+    stop_brokers
+    if ($RETCODE != 0) {
+        "FAIL federation tests"
+        exit 1
+    }
+}

Added: qpid/trunk/qpid/cpp/src/tests/run_header_test.ps1
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/run_header_test.ps1?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/run_header_test.ps1 (added)
+++ qpid/trunk/qpid/cpp/src/tests/run_header_test.ps1 Wed Jun  3 20:00:35 2009
@@ -0,0 +1,40 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Simple test of encode/decode of a double in application headers
+# TODO: this should be expanded to cover a wider set of types and go
+# in both directions
+
+$srcdir = Split-Path $myInvocation.ScriptName
+$PYTHON_DIR = $srcdir\..\..\..\python
+if (Test-Path qpidd.port) {
+   set-item -path env:QPID_PORT -value (get-content -path qpidd.port 
-totalcount 1)
+}
+
+if (Test-Path $PYTHON_DIR -pathType Container) {
+    ./header_test -p $QPID_PORT
+    $env:PYTHONPATH="$PYTHON_DIR;$env:PYTHONPATH"
+    $srcdir/header_test.py "localhost" $QPID_PORT
+    exit $LASTEXITCODE
+}
+else {
+    "Skipping header test as python libs not found"
+    exit 0
+}
+

Added: qpid/trunk/qpid/cpp/src/tests/run_test.ps1
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/run_test.ps1?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/run_test.ps1 (added)
+++ qpid/trunk/qpid/cpp/src/tests/run_test.ps1 Wed Jun  3 20:00:35 2009
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Set up environment and run a test executable or script.
+$env:QPID_DATA_DIR = ""
+$env:BOOST_TEST_SHOW_PROGRESS = "yes"
+
+# 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]
+if (Test-Path $prog) {
+   $env:QPID_LIB_DIR = ".."
+   $env:PATH += ";.."
+}
+else {
+   $dir = Split-Path $prog
+   $exe = Split-Path $prog -leaf
+   $subs = "Debug","Release","MinSizeRel","RelWithDebInfo"
+   foreach ($sub in $subs) {
+      $prog = "$dir\$sub\$exe"
+      if (Test-Path $prog) {
+         $args[0] = $prog
+         $env:QPID_LIB_DIR = "..\$sub"
+         $env:PATH += ";..\$sub"
+         break
+      }
+   }
+}
+
+# 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)
+}
+
+exit Invoke-Item "$args" | Out-Default

Added: qpid/trunk/qpid/cpp/src/tests/start_broker.ps1
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/start_broker.ps1?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/start_broker.ps1 (added)
+++ qpid/trunk/qpid/cpp/src/tests/start_broker.ps1 Wed Jun  3 20:00:35 2009
@@ -0,0 +1,43 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Get the directory where this script resides.
+function Get-ScriptPath
+  { Split-Path $myInvocation.ScriptName }
+
+# Start a test broker and capture it's port (from stdout) to qpidd.port
+# This script will exit immediately after spawning the broker process. To avoid
+# running more tests before the broker is initialized, wait for the qpidd.port
+# file to appear before exiting.
+if (Test-Path qpidd.port) {
+   Remove-Item qpidd.port
+}
+$srcdir = Get-ScriptPath
+. $srcdir\background.ps1 {
+  ..\Debug\qpidd --auth=no --no-module-dir --port=0 --log-to-file qpidd.log 
$args | foreach { set-content qpidd.port $_ } }
+$wait_time = 0
+while (!(Test-Path qpidd.port) -and ($wait_time -lt 10)) {
+   Start-Sleep 2
+   $wait_time += 2
+}
+if (Test-Path qpidd.port) {
+  exit 0
+}
+"Time out waiting for broker to start"
+exit 1

Added: qpid/trunk/qpid/cpp/src/tests/stop_broker.ps1
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/stop_broker.ps1?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/stop_broker.ps1 (added)
+++ qpid/trunk/qpid/cpp/src/tests/stop_broker.ps1 Wed Jun  3 20:00:35 2009
@@ -0,0 +1,39 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Stop the broker, check for errors.
+Get-Content -path qpidd.port -totalCount 1 | Set-Variable -name qpid_port
+Remove-Item qpidd.port
+
+# Piping the output makes the script wait for qpidd to finish.
+..\Debug\qpidd --quit --port $qpid_port | Write-Output
+
+# Check qpidd.log.
+filter bad_stuff {
+  $_ -match "( warning | error | critical )"
+}
+
+$qpidd_errors = $false
+Get-Content -path qpidd.log | where { bad_stuff } | Out-Default | Set-Variable 
-name qpidd_errors -value $true
+if ($qpidd_errors -eq $true) {
+  "WARNING: Suspicious broker log entries in qpidd.log, above."
+  exit 1
+}
+
+exit 0

Added: qpid/trunk/qpid/cpp/src/tests/topictest.ps1
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/topictest.ps1?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/topictest.ps1 (added)
+++ qpid/trunk/qpid/cpp/src/tests/topictest.ps1 Wed Jun  3 20:00:35 2009
@@ -0,0 +1,65 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Run the C++ topic test
+
+# Clean up old log files
+Get-Item subscriber_*.log | Remove-Item
+
+# Parameters with default values: s (subscribers) m (messages) b (batches)
+#                                 h (host) t (false; use transactions)
+param (
+  [int]$subscribers = 10,
+  [int]$messages = 2000,
+  [int]$batches = 10,
+  [string]$broker,
+  [switch] $t           # transactional
+)
+
+function subscribe {
+    "Start subscriber $args[0]"
+    $LOG = "subscriber_$args[0].log"
+    . $srcdir\background.ps1 {
+      $env:OUTDIR\topic_listener $TRANSACTIONAL > $LOG 2>&1
+      if ($LastExitCode -ne 0) { Remove-Item $LOG }
+    } -inconsole
+}
+
+publish() {
+    if ($t) {
+      $transactional = "--transactional --durable"
+    }
+    $env:OUTDIR\topic_publisher --messages $messages --batches $batches 
--subscribers $subscribers $host $transactional 2>&1
+}
+
+$srcdir = Split-Path $myInvocation.ScriptName
+if ($broker.length) {
+  $broker = "-h$broker"
+}
+
+$i = $subscribers
+while ($i -gt 0) {
+  subscribe $i
+  $i--
+}
+
+# FIXME aconway 2007-03-27: Hack around startup race. Fix topic test.
+Start-Sleep 2
+publish
+exit $LastExitCode

Added: qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp?rev=781525&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp (added)
+++ qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp Wed Jun  
3 20:00:35 2009
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+// This file intends to prevent Windows from throwing up error boxes and
+// offering to debug when serious errors happen. The errors are displayed
+// on stderr instead. The purpose of this is to allow the tests to proceed
+// scripted and catch the text for logging. If this behavior is desired,
+// include this file with the executable being built. If the default
+// behaviors are desired, don't include this file in the build.
+
+#include <crtdbg.h>
+#include <windows.h>
+
+namespace {
+
+struct redirect_errors_to_stderr {
+    redirect_errors_to_stderr ();
+};
+
+static redirect_errors_to_stderr block;
+
+redirect_errors_to_stderr::redirect_errors_to_stderr()
+{
+    _CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_FILE);
+    _CrtSetReportFile (_CRT_WARN, _CRTDBG_FILE_STDERR);
+    _CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_FILE);
+    _CrtSetReportFile (_CRT_ERROR, _CRTDBG_FILE_STDERR);
+    _CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_FILE);
+    _CrtSetReportFile (_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+
+    // Prevent the system from displaying the critical-error-handler
+    // and can't-open-file message boxes.
+    SetErrorMode(SEM_FAILCRITICALERRORS);
+    SetErrorMode(SEM_NOOPENFILEERRORBOX);
+}
+
+}  // namespace

Propchange: qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscr...@qpid.apache.org

Reply via email to