QPID-7281: Various fixes for the tests on windows

 - Adjust environment script for windows paths
 - Pythonify the test runner for the windows store tests
 - Run the HA tests only on posix systems
 - Remove a finicky assertion in brokertest.py


git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1746375 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt
index efc3176..930d8b7 100644
--- a/qpid/cpp/src/tests/CMakeLists.txt
+++ b/qpid/cpp/src/tests/CMakeLists.txt
@@ -285,7 +285,6 @@
 add_test(NAME client_tests COMMAND ${PYTHON_EXECUTABLE} run_client_tests)
 add_test(NAME federation_tests COMMAND ${PYTHON_EXECUTABLE} run_federation_tests)
 add_test(NAME flow_control_tests COMMAND ${PYTHON_EXECUTABLE} run_flow_control_tests)
-add_test(NAME ha_tests COMMAND ${PYTHON_EXECUTABLE} run_ha_tests)
 add_test(NAME msg_group_tests COMMAND ${PYTHON_EXECUTABLE} run_msg_group_tests)
 add_test(NAME performance_tests COMMAND ${PYTHON_EXECUTABLE} run_performance_tests)
 add_test(NAME python_tests COMMAND ${PYTHON_EXECUTABLE} run_python_tests)
@@ -302,18 +301,14 @@
 if (CMAKE_SYSTEM_NAME STREQUAL Windows)
     # Windows-only tests
 
-    if (BUILD_MSSQL)
-        add_test(NAME store_tests COMMAND powershell run_store_tests.ps1 MSSQL)
-    endif (BUILD_MSSQL)
-
-    if (BUILD_MSCLFS)
-        add_test(NAME store_tests_clfs COMMAND powershell run_store_tests.ps1 MSSQL-CLFS)
-    endif (BUILD_MSCLFS)
+    add_test(NAME windows_store_tests COMMAND ${PYTHON_EXECUTABLE} run_windows_store_tests)
 else (CMAKE_SYSTEM_NAME STREQUAL Windows)
     # Posix-only tests
 
-    add_test(NAME logging_tests COMMAND run_logging_tests) # Pretty simple to convert
+    add_test(NAME ha_tests COMMAND ${PYTHON_EXECUTABLE} run_ha_tests)
+    
     add_test(NAME ipv6_tests COMMAND run_ipv6_tests) # Also pretty simple to convert
+    add_test(NAME logging_tests COMMAND run_logging_tests) # Pretty simple to convert
     add_test(NAME paged_queue_tests COMMAND run_paged_queue_tests)
     add_test(NAME ring_queue_tests COMMAND run_ring_queue_tests)
     add_test(NAME topic_tests COMMAND run_topic_tests)
diff --git a/qpid/cpp/src/tests/brokertest.py b/qpid/cpp/src/tests/brokertest.py
index 8c32faa..b40e953 100644
--- a/qpid/cpp/src/tests/brokertest.py
+++ b/qpid/cpp/src/tests/brokertest.py
@@ -157,7 +157,6 @@
         """
         self._clean = False
         self._clean_lock = Lock()
-        assert find_exe(cmd[0]), "executable not found: "+cmd[0]
         if type(cmd) is type(""): cmd = [cmd] # Make it a list.
         self.cmd  = [ str(x) for x in cmd ]
         self.expect = expect
diff --git a/qpid/cpp/src/tests/common.py b/qpid/cpp/src/tests/common.py
index 12a73ed..d6dc640 100644
--- a/qpid/cpp/src/tests/common.py
+++ b/qpid/cpp/src/tests/common.py
@@ -23,7 +23,6 @@
 
 import atexit as _atexit
 import os as _os
-import platform as _platform
 import re as _re
 import shlex as _shlex
 import shutil as _shutil
@@ -32,8 +31,6 @@
 import time as _time
 import uuid as _uuid
 
-WINDOWS = _platform.system() == "Windows"
-
 def _unique_id():
     return str(_uuid.uuid4())[:4]
 
diff --git a/qpid/cpp/src/tests/env.py.in b/qpid/cpp/src/tests/env.py.in
index c2dfbcb..29b8c87 100644
--- a/qpid/cpp/src/tests/env.py.in
+++ b/qpid/cpp/src/tests/env.py.in
@@ -21,6 +21,10 @@
 
 from plano import *
 
+import platform as _platform
+
+WINDOWS = _platform.system() == "Windows"
+
 def _export(name, value):
     globals()[name] = value
 
@@ -33,6 +37,8 @@
     if exists(path):
         _export(name, path)
 
+_cmake_build_type = "RelWithDebInfo" # XXX
+
 # Variables substituted by cmake
 
 _export("BUILD_DIR", normalize_path("@CMAKE_BINARY_DIR@"))
@@ -59,11 +65,16 @@
 
 # Path
 
+_build_src_dir = join(BUILD_DIR, "src")
+_build_tests_dir = join(BUILD_DIR, "src", "tests")
+
+if WINDOWS:
+    _build_src_dir = join(_build_src_dir, _cmake_build_type)
+    _build_tests_dir = join(_build_tests_dir, _cmake_build_type)
+
 _path = [
-    join(BUILD_DIR, "src"),
-    join(BUILD_DIR, "src", "RelWithDebInfo"),
-    join(BUILD_DIR, "src", "tests"),
-    join(BUILD_DIR, "src", "tests", "RelWithDebInfo"),
+    _build_src_dir,
+    _build_tests_dir,
     join(BUILD_DIR, "management", "python", "bin"),
 ]
 
@@ -74,14 +85,19 @@
 
 # Modules
 
-_export_module("HA_LIB", join(BUILD_DIR, "src", "ha.so"))
-_export_module("XML_LIB", join(BUILD_DIR, "src", "xml.so"))
-_export_module("AMQP_LIB", join(BUILD_DIR, "src", "amqp.so"))
-_export_module("TEST_STORE_LIB", join(BUILD_DIR, "src", "tests", "test_store.so"))
-_export_module("STORE_LIB", join(BUILD_DIR, "src", "linearstore.so"))
+_module_prefix = join(BUILD_DIR, "src")
+              
+if WINDOWS:
+    _module_prefix = join(_module_prefix, _cmake_build_type)
+
+_export_module("HA_LIB", join(_module_prefix, "ha@CMAKE_SHARED_LIBRARY_SUFFIX@"))
+_export_module("XML_LIB", join(_module_prefix, "xml@CMAKE_SHARED_LIBRARY_SUFFIX@"))
+_export_module("AMQP_LIB", join(_module_prefix, "amqp@CMAKE_SHARED_LIBRARY_SUFFIX@"))
+_export_module("TEST_STORE_LIB", join(_module_prefix, "tests", "test_store@CMAKE_SHARED_LIBRARY_SUFFIX@"))
+_export_module("STORE_LIB", join(_module_prefix, "linearstore@CMAKE_SHARED_LIBRARY_SUFFIX@"))
 
 if STORE_LIB is None:
-    _export_module("STORE_LIB", join(BUILD_DIR, "src", "legacystore.so"))
+    _export_module("STORE_LIB", join(_module_prefix, "legacystore@CMAKE_SHARED_LIBRARY_SUFFIX@"))
 
 # Summarize
 
diff --git a/qpid/cpp/src/tests/run_windows_store_tests b/qpid/cpp/src/tests/run_windows_store_tests
new file mode 100644
index 0000000..900d0fc
--- /dev/null
+++ b/qpid/cpp/src/tests/run_windows_store_tests
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+
+#
+# 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.
+#
+
+from common import *
+
+store_lib = join(BUILD_DIR, "src", "qpid", "store", "RelWithDebInfo", "store.dll")
+store_sql_lib = join(BUILD_DIR, "src", "qpid", "store", "RelWithDebInfo", "mssql_store.dll")
+store_clfs_lib = join(BUILD_DIR, "src", "qpid", "store", "RelWithDebInfo", "msclfs_store.dll")
+
+if exists(store_sql_lib):
+    port = start_broker("broker_sql",
+                        "--load-module {0}".format(store_lib),
+                        "--load-module {0}".format(store_sql_lib))
+
+    run_broker_tests(port,
+                     "-m qpid_tests.broker_0_10.dtx",
+                     "-m qpid_tests.broker_0_10.persistence")
+
+    stop_broker(port)
+
+if exists(store_clfs_lib):
+    port = start_broker("broker_clfs",
+                        "--load-module {0}".format(store_lib),
+                        "--load-module {0}".format(store_clfs_lib))
+
+    run_broker_tests(port,
+                     "-m qpid_tests.broker_0_10.dtx",
+                     "-m qpid_tests.broker_0_10.persistence")
+
+    stop_broker(port)
+
+ENV["STORE_SQL_LIB"] = store_sql_lib
+ENV["STORE_SQL_CLFS_LIB"] = store_clfs_lib
+
+if exists(store_sql_lib):
+    ENV["STORE_CATALOG"] = join(WORK_DIR, "store_recovery_sql_test")
+    call("qpid-python-test -m store -DOUTDIR={0}", WORK_DIR)
+
+if exists(store_clfs_lib):
+    ENV["STORE_CATALOG"] = join(WORK_DIR, "store_recovery_clfs_test")
+    call("qpid-python-test -m store -DOUTDIR={0}", WORK_DIR)
+
+check_results()