summaryrefslogtreecommitdiff
path: root/sal/cppunittester
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-02-25 16:01:35 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-02-25 16:01:35 +0100
commitdf43fd9cd28a12f2e90ae40c163a20005ef2ae20 (patch)
tree8079928c67a566f6d84dc415bc28d80fd3c7626f /sal/cppunittester
parent58eb3fb273f12dc632536366c9867d5bd952151c (diff)
debuglevels: GCC WaE / replace cppunit's DynamicLibraryManager (which does not seem to be public API) with osl_loadModule
Diffstat (limited to 'sal/cppunittester')
-rw-r--r--sal/cppunittester/cast.c36
-rw-r--r--sal/cppunittester/cast.h46
-rw-r--r--sal/cppunittester/cppunittester.cxx59
-rw-r--r--sal/cppunittester/makefile.mk2
4 files changed, 38 insertions, 105 deletions
diff --git a/sal/cppunittester/cast.c b/sal/cppunittester/cast.c
deleted file mode 100644
index 38c081a60708..000000000000
--- a/sal/cppunittester/cast.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2011 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 "sal/config.h"
-
-#include "osl/module.h"
-
-#include "cast.h"
-
-oslGenericFunction cast(void * fn) {
- return (oslGenericFunction) fn;
-}
diff --git a/sal/cppunittester/cast.h b/sal/cppunittester/cast.h
deleted file mode 100644
index 4cfd411da930..000000000000
--- a/sal/cppunittester/cast.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2011 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.
-*
-************************************************************************/
-
-#ifndef INCLUDED_SAL_CPPUNITTESTER_CAST_H
-#define INCLUDED_SAL_CPPUNITTESTER_CAST_H
-
-#include "sal/config.h"
-
-#include "osl/module.h"
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-/* C++ compilers would warn about that cast, so it is done in C: */
-oslGenericFunction cast(void * fn);
-
-#if defined __cplusplus
-}
-#endif
-
-#endif
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index e3ced7253e47..6aba6dc14b30 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -34,12 +34,16 @@
#include <string>
#include "cppunittester/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 "preextstl.h"
#include "cppunit/CompilerOutputter.h"
@@ -47,14 +51,10 @@
#include "cppunit/TestResultCollector.h"
#include "cppunit/TestRunner.h"
#include "cppunit/extensions/TestFactoryRegistry.h"
-#include "cppunit/plugin/DynamicLibraryManager.h"
-#include "cppunit/plugin/DynamicLibraryManagerException.h"
#include "cppunit/plugin/PlugInManager.h"
#include "cppunit/portability/Stream.h"
#include "postextstl.h"
-#include "cast.h"
-
namespace {
void usageFailure() {
@@ -65,15 +65,29 @@ void usageFailure() {
std::exit(EXIT_FAILURE);
}
-std::string getArgument(sal_uInt32 index) {
- rtl::OUString s16;
- rtl_getAppCommandArg(index, &s16.pData);
+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())));
+}
+
+std::string convertStrict(rtl::OUString const & s16) {
rtl::OString s8;
if (!s16.convertToString(
&s8, osl_getThreadTextEncoding(),
(RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
| RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))
- || (s8.getLength()
+ || (static_cast< sal_uInt32 >(s8.getLength())
> std::numeric_limits< std::string::size_type >::max()))
{
std::cerr
@@ -91,38 +105,39 @@ SAL_IMPLEMENT_MAIN() {
CppUnit::TestResult result;
sal_uInt32 index = 0;
for (; index < rtl_getAppCommandArgCount(); index += 3) {
- std::string arg(getArgument(index));
- if (arg.compare("--protector") != 0) {
+ if (!getArgument(index).equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("--protector")))
+ {
break;
}
if (rtl_getAppCommandArgCount() - index < 3) {
usageFailure();
}
- try {
- result.pushProtector(
- (*reinterpret_cast< cppunittester::ProtectorFactory * >(
- cast(
- (new CppUnit::DynamicLibraryManager(
- getArgument(index + 1)))
- ->findSymbol(getArgument(index + 2)))))());
- } catch (CppUnit::DynamicLibraryManagerException & e) {
+ rtl::OUString lib(getArgument(index + 1));
+ rtl::OUString sym(getArgument(index + 2));
+ oslGenericFunction fn = (new osl::Module(lib))->getFunctionSymbol(sym);
+ CppUnit::Protector * p = fn == 0
+ ? 0
+ : (*reinterpret_cast< cppunittester::ProtectorFactory * >(fn))();
+ if (p == 0) {
std::cerr
- << "Failure instantiating protector \""
- << getArgument(index + 1) << "\", \"" << getArgument(index + 2)
- << "\": " << e.what() << std::endl;
+ << "Failure instantiating protector \"" << convertLazy(lib)
+ << "\", \"" << convertLazy(sym) << '"' << std::endl;
std::exit(EXIT_FAILURE);
}
+ result.pushProtector(p);
}
if (rtl_getAppCommandArgCount() - index != 1) {
usageFailure();
}
CppUnit::PlugInManager manager;
- manager.load(getArgument(index));
+ manager.load(convertStrict(getArgument(index)));
CppUnit::TestRunner runner;
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
CppUnit::TestResultCollector collector;
result.addListener(&collector);
runner.run(result);
CppUnit::CompilerOutputter(&collector, CppUnit::stdCErr()).write();
+ fprintf( stderr, "-----\n" ); fflush( stderr );
return collector.wasSuccessful() ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/sal/cppunittester/makefile.mk b/sal/cppunittester/makefile.mk
index 657b8f804504..61fe7868c9f3 100644
--- a/sal/cppunittester/makefile.mk
+++ b/sal/cppunittester/makefile.mk
@@ -44,7 +44,7 @@ CFLAGSCXX += $(CPPUNIT_CFLAGS)
OBJFILES = $(APP1OBJS)
-APP1OBJS = $(OBJ)/cast.obj $(OBJ)/cppunittester.obj
+APP1OBJS = $(OBJ)/cppunittester.obj
APP1RPATH = NONE
APP1STDLIBS = $(CPPUNITLIB) $(SALLIB)
APP1TARGET = cppunittester