summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2011-08-01 00:59:09 +0300
committerTor Lillqvist <tml@iki.fi>2011-08-01 00:59:09 +0300
commit9b330a37b239ec3f1327c7b7cb29abf658a090d0 (patch)
tree296011b8706df12b313ea7d7609a71816c94df81
parentf577683bca2b9cb1cad836f26d78f616e9ff06c9 (diff)
Add statically linked cppu unit test for iOS
-rw-r--r--cppu/qa/cppu_cppunittester_all.cxx146
-rw-r--r--cppu/qa/makefile.mk16
-rw-r--r--cppu/qa/test_any.cxx4
-rw-r--r--cppu/qa/test_recursion.cxx5
-rw-r--r--cppu/qa/test_reference.cxx4
-rw-r--r--cppu/qa/test_unotype.cxx4
6 files changed, 174 insertions, 5 deletions
diff --git a/cppu/qa/cppu_cppunittester_all.cxx b/cppu/qa/cppu_cppunittester_all.cxx
new file mode 100644
index 000000000..e77c046bf
--- /dev/null
+++ b/cppu/qa/cppu_cppunittester_all.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#include "precompiled_cppu.hxx"
+
+#include "sal/config.h"
+
+#include <cstdlib>
+#include <iostream>
+#include <limits>
+#include <string>
+#include "protectorfactory.hxx"
+#include "osl/module.h"
+#include "osl/module.hxx"
+#include "osl/thread.h"
+#include "rtl/process.h"
+#include "rtl/string.h"
+#include "rtl/string.hxx"
+#include "rtl/textcvt.h"
+#include "rtl/ustring.hxx"
+#include "sal/main.h"
+#include "sal/types.h"
+
+#include "cppunit/CompilerOutputter.h"
+#include "cppunit/TestResult.h"
+#include "cppunit/TestResultCollector.h"
+#include "cppunit/TestRunner.h"
+#include "cppunit/plugin/TestPlugIn.h"
+#include "cppunit/plugin/PlugInParameters.h"
+#include "cppunit/extensions/TestFactoryRegistry.h"
+#include "cppunit/portability/Stream.h"
+
+#include "boost/noncopyable.hpp"
+
+namespace {
+
+void usageFailure() {
+ std::cerr
+ << ("Usage: cppunittester (--protector <shared-library-path>"
+ " <function-symbol>)* <shared-library-path>")
+ << std::endl;
+ std::exit(EXIT_FAILURE);
+}
+
+rtl::OUString getArgument(sal_Int32 index) {
+ rtl::OUString arg;
+ rtl_getAppCommandArg(index, &arg.pData);
+ return arg;
+}
+
+std::string convertLazy(rtl::OUString const & s16) {
+ rtl::OString s8(rtl::OUStringToOString(s16, osl_getThreadTextEncoding()));
+ return std::string(
+ s8.getStr(),
+ ((static_cast< sal_uInt32 >(s8.getLength())
+ > (std::numeric_limits< std::string::size_type >::max)())
+ ? (std::numeric_limits< std::string::size_type >::max)()
+ : static_cast< std::string::size_type >(s8.getLength())));
+}
+
+//Allow the whole uniting testing framework to be run inside a "Protector"
+//which knows about uno exceptions, so it can print the content of the
+//exception before falling over and dying
+class CPPUNIT_API ProtectedFixtureFunctor : public CppUnit::Functor, private boost::noncopyable
+{
+private:
+ const std::string &args;
+ CppUnit::TestResult &result;
+public:
+ ProtectedFixtureFunctor(const std::string &args_, CppUnit::TestResult &result_)
+ : args(args_)
+ , result(result_)
+ {
+ }
+ bool run() const
+ {
+ CppUnit::TestRunner runner;
+ runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+ CppUnit::TestResultCollector collector;
+ result.addListener(&collector);
+ runner.run(result);
+ CppUnit::CompilerOutputter(&collector, CppUnit::stdCErr()).write();
+ return collector.wasSuccessful();
+ }
+ virtual bool operator()() const
+ {
+ return run();
+ }
+};
+}
+
+extern "C" CppUnitTestPlugIn
+ *cppunitTest_qa_cppu_any(void),
+ *cppunitTest_qa_cppu_unotype(void),
+ *cppunitTest_qa_cppu_reference(void),
+ *cppunitTest_qa_cppu_recursion(void);
+
+
+SAL_IMPLEMENT_MAIN() {
+ TestPlugInSignature plugs[] = {
+ cppunitTest_qa_cppu_any,
+ cppunitTest_qa_cppu_unotype,
+ cppunitTest_qa_cppu_reference,
+ cppunitTest_qa_cppu_recursion,
+ NULL
+ };
+ CppUnit::TestResult result;
+ std::string args;
+ bool ok = false;
+ for (TestPlugInSignature *plug = plugs; *plug != NULL; plug++) {
+ CppUnitTestPlugIn *iface;
+ iface = (*plug)();
+ iface->initialize(&CppUnit::TestFactoryRegistry::getRegistry(), CppUnit::PlugInParameters());
+ }
+ ProtectedFixtureFunctor tests(args, result);
+ ok = tests.run();
+
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppu/qa/makefile.mk b/cppu/qa/makefile.mk
index 6d9d87935..86cd144a4 100644
--- a/cppu/qa/makefile.mk
+++ b/cppu/qa/makefile.mk
@@ -33,13 +33,12 @@ ENABLE_EXCEPTIONS := TRUE
.INCLUDE: settings.mk
-.IF "$(CROSS_COMPILING)"=="YES"
-all:
- @echo Nothing done when cross-compiling
-.ENDIF
-
CFLAGSCXX+=$(CPPUNIT_CFLAGS)
+.IF "$(OS)" == "IOS"
+CFLAGSCXX += -x objective-c++ -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300
+.ENDIF
+
DLLPRE=# no leading "lib" on .so files
INCPRE+=$(MISC)$/$(TARGET)$/inc
@@ -74,6 +73,13 @@ DEF4NAME = $(SHL4TARGET)
SLOFILES = $(SHL1OBJS) $(SHL2OBJS) $(SHL3OBJS) $(SHL4OBJS)
+.IF "$(OS)" == "IOS"
+APP5OBJS = $(OBJ)/cppu_cppunittester_all.obj $(SHL1OBJS) $(SHL2OBJS) $(SHL3OBJS) $(SHL4OBJS)
+APP5RPATH = NONE
+APP5STDLIBS = $(CPPUNITLIB) $(CPPULIB) $(SALLIB)
+APP5TARGET = cppu_cppunittester_all
+.ENDIF
+
.INCLUDE: target.mk
$(SHL1OBJS): $(MISC)$/$(TARGET).cppumaker.flag
diff --git a/cppu/qa/test_any.cxx b/cppu/qa/test_any.cxx
index be0d1f7b1..ec5bbc628 100644
--- a/cppu/qa/test_any.cxx
+++ b/cppu/qa/test_any.cxx
@@ -29,6 +29,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_cppu.hxx"
+#ifdef IOS
+#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTest_qa_cppu_any
+#endif
+
#include "sal/config.h"
#include <stdlib.h> // wntmsci10 does not like <cstdlib>
diff --git a/cppu/qa/test_recursion.cxx b/cppu/qa/test_recursion.cxx
index 610bce5b8..ca4a4c400 100644
--- a/cppu/qa/test_recursion.cxx
+++ b/cppu/qa/test_recursion.cxx
@@ -27,6 +27,11 @@
************************************************************************/
#include "precompiled_cppu.hxx"
+
+#ifdef IOS
+#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTest_qa_cppu_recursion
+#endif
+
#include "sal/config.h"
#include <cppunit/TestSuite.h>
diff --git a/cppu/qa/test_reference.cxx b/cppu/qa/test_reference.cxx
index f6e93cf6c..cb44084f7 100644
--- a/cppu/qa/test_reference.cxx
+++ b/cppu/qa/test_reference.cxx
@@ -29,6 +29,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_cppu.hxx"
+#ifdef IOS
+#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTest_qa_cppu_reference
+#endif
+
#include "sal/config.h"
#include <cppunit/TestSuite.h>
diff --git a/cppu/qa/test_unotype.cxx b/cppu/qa/test_unotype.cxx
index 00a185465..c06296f5e 100644
--- a/cppu/qa/test_unotype.cxx
+++ b/cppu/qa/test_unotype.cxx
@@ -29,6 +29,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_cppu.hxx"
+#ifdef IOS
+#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTest_qa_cppu_unotype
+#endif
+
#include "sal/config.h"
#include <cppunit/TestSuite.h>