summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2011-02-25 11:32:55 +0100
committersb <sb@openoffice.org>2011-02-25 11:32:55 +0100
commit58eb3fb273f12dc632536366c9867d5bd952151c (patch)
treee16ed6025fd2a24ede60ff35aafe22d701e6d527 /sal
parent4dcc14fa7e853546d68a48cd9d5f81b69c25bc1f (diff)
debuglevels: #i117073# added cppunittester --protector support; added unoexceptionprotector and use it in installationtest.mk; reverted changes to smoketest.cxx obsoleted by these additions
Diffstat (limited to 'sal')
-rw-r--r--sal/cppunittester/cast.c36
-rw-r--r--sal/cppunittester/cast.h46
-rw-r--r--sal/cppunittester/cppunittester.cxx87
-rw-r--r--sal/cppunittester/makefile.mk2
-rw-r--r--sal/inc/cppunittester/protectorfactory.hxx45
-rw-r--r--sal/prj/d.lst2
6 files changed, 204 insertions, 14 deletions
diff --git a/sal/cppunittester/cast.c b/sal/cppunittester/cast.c
new file mode 100644
index 000000000000..38c081a60708
--- /dev/null
+++ b/sal/cppunittester/cast.c
@@ -0,0 +1,36 @@
+/*************************************************************************
+*
+* 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
new file mode 100644
index 000000000000..4cfd411da930
--- /dev/null
+++ b/sal/cppunittester/cast.h
@@ -0,0 +1,46 @@
+/*************************************************************************
+*
+* 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 ac99601f5ce5..e3ced7253e47 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -30,6 +30,16 @@
#include <cstdlib>
#include <iostream>
+#include <limits>
+#include <string>
+
+#include "cppunittester/protectorfactory.hxx"
+#include "osl/thread.h"
+#include "rtl/process.h"
+#include "rtl/string.hxx"
+#include "rtl/textcvt.h"
+#include "rtl/ustring.hxx"
+#include "sal/main.h"
#include "preextstl.h"
#include "cppunit/CompilerOutputter.h"
@@ -37,28 +47,79 @@
#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 "osl/thread.h"
-#include "rtl/process.h"
-#include "rtl/string.hxx"
-#include "rtl/ustring.hxx"
-#include "sal/main.h"
+
+#include "cast.h"
+
+namespace {
+
+void usageFailure() {
+ std::cerr
+ << ("Usage: cppunittester (--protector <shared-library-path>"
+ " <function-symbol>)* <shared-library-path>")
+ << std::endl;
+ std::exit(EXIT_FAILURE);
+}
+
+std::string getArgument(sal_uInt32 index) {
+ rtl::OUString s16;
+ rtl_getAppCommandArg(index, &s16.pData);
+ rtl::OString s8;
+ if (!s16.convertToString(
+ &s8, osl_getThreadTextEncoding(),
+ (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
+ | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))
+ || (s8.getLength()
+ > std::numeric_limits< std::string::size_type >::max()))
+ {
+ std::cerr
+ << "Failure converting argument from UTF-16 back to system encoding"
+ << std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+ return std::string(
+ s8.getStr(), static_cast< std::string::size_type >(s8.getLength()));
+}
+
+}
SAL_IMPLEMENT_MAIN() {
- if (rtl_getAppCommandArgCount() != 1) {
- std::cerr << "Usage: cppunittester <shared-library-path>" << std::endl;
- return EXIT_FAILURE;
+ CppUnit::TestResult result;
+ sal_uInt32 index = 0;
+ for (; index < rtl_getAppCommandArgCount(); index += 3) {
+ std::string arg(getArgument(index));
+ if (arg.compare("--protector") != 0) {
+ 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) {
+ std::cerr
+ << "Failure instantiating protector \""
+ << getArgument(index + 1) << "\", \"" << getArgument(index + 2)
+ << "\": " << e.what() << std::endl;
+ std::exit(EXIT_FAILURE);
+ }
+ }
+ if (rtl_getAppCommandArgCount() - index != 1) {
+ usageFailure();
}
- rtl::OUString path;
- rtl_getAppCommandArg(0, &path.pData);
CppUnit::PlugInManager manager;
- manager.load(
- rtl::OUStringToOString(path, osl_getThreadTextEncoding()).getStr());
+ manager.load(getArgument(index));
CppUnit::TestRunner runner;
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
- CppUnit::TestResult result;
CppUnit::TestResultCollector collector;
result.addListener(&collector);
runner.run(result);
diff --git a/sal/cppunittester/makefile.mk b/sal/cppunittester/makefile.mk
index 61fe7868c9f3..657b8f804504 100644
--- a/sal/cppunittester/makefile.mk
+++ b/sal/cppunittester/makefile.mk
@@ -44,7 +44,7 @@ CFLAGSCXX += $(CPPUNIT_CFLAGS)
OBJFILES = $(APP1OBJS)
-APP1OBJS = $(OBJ)/cppunittester.obj
+APP1OBJS = $(OBJ)/cast.obj $(OBJ)/cppunittester.obj
APP1RPATH = NONE
APP1STDLIBS = $(CPPUNITLIB) $(SALLIB)
APP1TARGET = cppunittester
diff --git a/sal/inc/cppunittester/protectorfactory.hxx b/sal/inc/cppunittester/protectorfactory.hxx
new file mode 100644
index 000000000000..c309dbe8aa85
--- /dev/null
+++ b/sal/inc/cppunittester/protectorfactory.hxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+*
+* 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_CPPUNITTESTER_PROTECTORFACTORY_HXX
+#define INCLUDED_CPPUNITTESTER_PROTECTORFACTORY_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+namespace CppUnit { class Protector; }
+
+namespace cppunittester {
+
+// The type of CppUnit::Protector factory functions that can be plugged into
+// cppunittester:
+extern "C" typedef CppUnit::Protector * SAL_CALL ProtectorFactory();
+
+}
+
+#endif
diff --git a/sal/prj/d.lst b/sal/prj/d.lst
index 3ce270bbbfc4..253d7ea7f718 100644
--- a/sal/prj/d.lst
+++ b/sal/prj/d.lst
@@ -1,9 +1,11 @@
+mkdir: %_DEST%\inc%_EXT%\cppunittester
mkdir: %_DEST%\inc%_EXT%\sal
mkdir: %_DEST%\inc%_EXT%\osl
mkdir: %_DEST%\inc%_EXT%\rtl
mkdir: %_DEST%\inc%_EXT%\systools
mkdir: %_DEST%\inc%_EXT%\systools\win32
+..\inc\cppunittester\protectorfactory.hxx %_DEST%\inc%_EXT%\protectorfactory.hxx
..\%__SRC%\inc\rtlbootstrap.mk %_DEST%\inc%_EXT%\rtlbootstrap.mk
..\inc\sal\*.h %_DEST%\inc%_EXT%\sal\*.h
..\%__SRC%\inc\sal\typesizes.h %_DEST%\inc%_EXT%\sal\typesizes.h