[asterisk-scf-commits] asterisk-scf/release/ice-util-cpp.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Apr 15 12:23:01 CDT 2011


branch "master" has been updated
       via  2d86b6396e8ae2eee499da8995994e887701d93d (commit)
       via  d44d47af554d41e1326ae6bbf03fca6cc93cdd32 (commit)
      from  cf2f9b9ada6a587a0cb2926c6c5d594eba26be76 (commit)

Summary of changes:
 CMakeLists.txt                                     |    1 +
 TestFixture/CMakeLists.txt                         |   16 ++++
 TestFixture/include/AsteriskSCF/IceBoxBoostTest.h  |   85 ++++++++++++++++++++
 .../test.cpp => TestFixture/src/TestFixture.cpp    |    5 +-
 4 files changed, 105 insertions(+), 2 deletions(-)
 create mode 100644 TestFixture/CMakeLists.txt
 create mode 100644 TestFixture/include/AsteriskSCF/IceBoxBoostTest.h
 copy AmiCollector/test/test.cpp => TestFixture/src/TestFixture.cpp (86%)


- Log -----------------------------------------------------------------
commit 2d86b6396e8ae2eee499da8995994e887701d93d
Merge: d44d47a cf2f9b9
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Apr 15 12:18:38 2011 -0500

    Merge branch 'master' of git.asterisk.org:asterisk-scf/release/ice-util-cpp into test-utf


commit d44d47af554d41e1326ae6bbf03fca6cc93cdd32
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Thu Apr 7 13:33:21 2011 -0500

    A header file that handles placing a boost unit test under an icebox service.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 67c5652..b092bc7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,3 +6,4 @@ endif()
 add_subdirectory(SmartProxy)
 add_subdirectory(StateReplicator)
 add_subdirectory(AmiCollector)
+add_subdirectory(TestFixture)
diff --git a/TestFixture/CMakeLists.txt b/TestFixture/CMakeLists.txt
new file mode 100644
index 0000000..26d5897
--- /dev/null
+++ b/TestFixture/CMakeLists.txt
@@ -0,0 +1,16 @@
+asterisk_scf_component_init(testfixture CXX)
+
+include_directories(include)
+
+asterisk_scf_component_add_file(testfixture include/AsteriskSCF/IceBoxBoostTest.h)
+asterisk_scf_component_add_file(testfixture src/TestFixture.cpp)
+
+asterisk_scf_component_add_boost_libraries(testfixture  unit_test_framework)
+
+# don't install the component.  it's just there to make Visual Studio happy
+# _do_ install the header files
+asterisk_scf_headers_install(include/)
+
+include_directories(include)
+
+asterisk_scf_component_build_icebox(testfixture)
diff --git a/TestFixture/include/AsteriskSCF/IceBoxBoostTest.h b/TestFixture/include/AsteriskSCF/IceBoxBoostTest.h
new file mode 100644
index 0000000..46fef08
--- /dev/null
+++ b/TestFixture/include/AsteriskSCF/IceBoxBoostTest.h
@@ -0,0 +1,85 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010-2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#pragma once
+
+// We'll take care of kicking off the boost test in the IceBox start() handler.
+#define BOOST_TEST_NO_MAIN 
+
+#include <boost/test/unit_test.hpp>
+
+#include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
+
+/* Cache for the command line arguments and other info that the tests may want. */
+struct IceBoxTestEnv
+{
+public:
+    int argc;
+    char **argv;
+    Ice::CommunicatorPtr communicator; 
+    std::string serviceName;
+    Ice::ObjectAdapterPtr adapter;  // Set by test-specific global fixture if servants are required.
+};
+static IceBoxTestEnv IceBoxTestEnv;
+
+/**
+ * Test service for loading into icebox. This utility caches the arguments passed in
+ * to the boost unit test, then calls the standard boost unit_test_main. 
+ */
+class IceBoxTest : public IceBox::Service
+{
+public:
+    /**
+     * Override of the IceBox::Service start() handler.
+     */
+    void start(std::string const &name,
+        Ice::CommunicatorPtr const &communicator,
+        Ice::StringSeq const &args)
+    {
+        std::vector<char const *> argv;
+        argv.push_back(name.c_str());
+        for (Ice::StringSeq::const_iterator i = args.begin(); i != args.end(); ++i)
+        {
+            argv.push_back(i->c_str());
+        }
+
+        // null terminate list
+        argv.push_back((char const *) 0);
+
+        IceBoxTestEnv.communicator = communicator;
+        IceBoxTestEnv.serviceName = name;
+        IceBoxTestEnv.argc = argv.size() - 1;
+        IceBoxTestEnv.argv = (char**)&argv[0];
+
+        int r = ::boost::unit_test::unit_test_main(&init_unit_test, IceBoxTestEnv.argc, IceBoxTestEnv.argv);
+        exit(r);
+    }
+
+    /**
+     * Override of the IceBox::Service stop() handler.
+     */
+    void stop()
+    {
+    }
+};
+
+extern "C"
+{
+ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
+{
+    return new IceBoxTest;
+}
+}
diff --git a/TestFixture/src/TestFixture.cpp b/TestFixture/src/TestFixture.cpp
new file mode 100644
index 0000000..718456c
--- /dev/null
+++ b/TestFixture/src/TestFixture.cpp
@@ -0,0 +1,19 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#define BOOST_TEST_MODULE DummyTestName
+
+#include  <AsteriskSCF/IceBoxBoostTest.h>

-----------------------------------------------------------------------


-- 
asterisk-scf/release/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list