Kaydet (Commit) 58eb3fb2 authored tarafından sb's avatar sb

debuglevels: #i117073# added cppunittester --protector support; added…

debuglevels: #i117073# added cppunittester --protector support; added unoexceptionprotector and use it in installationtest.mk; reverted changes to smoketest.cxx obsoleted by these additions
üst 4dcc14fa
/*************************************************************************
*
* 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;
}
/*************************************************************************
*
* 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
......@@ -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);
......
......@@ -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
......
/*************************************************************************
*
* 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
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment