初步修复

This commit is contained in:
Cussrro 2024-12-19 09:48:26 +08:00
parent 8fc4357cc6
commit e4714f3f0e
46705 changed files with 12004901 additions and 0 deletions

View file

@ -0,0 +1,121 @@
#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
#include <cppunit/Portability.h>
#include <string>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
CPPUNIT_NS_BEGIN
/*! \brief Manages dynamic libraries.
*
* The Dynamic Library Manager provides a platform independent way to work with
* dynamic library. It load a specific dynamic library, and can returns specific
* symbol exported by the dynamic library.
*
* If an error occurs, a DynamicLibraryManagerException is thrown.
*
* \internal Implementation of the OS independent methods is in
* DynamicLibraryManager.cpp.
*
* \internal Porting to a new platform:
* - Adds platform detection in config/SelectDllLoader.h. Should define a specific
* macro for that platform of the form: CPPUNIT_HAVE_XYZ_DLL_LOADER, where
* XYZ is the platform.
* - Makes a copy of UnixDynamicLibraryManager.cpp and named it after the platform.
* - Updated the 'guard' in your file (CPPUNIT_HAVE_XYZ_DLL_LOADER) so that it is
* only processed if the matching platform has been detected.
* - Change the implementation of methods doLoadLibrary(), doReleaseLibrary(),
* doFindSymbol() in your copy. Those methods usually maps directly to OS calls.
* - Adds the file to the project.
*/
class DynamicLibraryManager
{
public:
typedef void *Symbol;
typedef void *LibraryHandle;
/*! \brief Loads the specified library.
* \param libraryFileName Name of the library to load.
* \exception DynamicLibraryManagerException if a failure occurs while loading
* the library (fail to found or load the library).
*/
DynamicLibraryManager( const std::string &libraryFileName );
/// Releases the loaded library..
~DynamicLibraryManager();
/*! \brief Returns a pointer on the specified symbol exported by the library.
* \param symbol Name of the symbol exported by the library.
* \return Pointer on the symbol. Should be casted to the actual type. Never \c NULL.
* \exception DynamicLibraryManagerException if the symbol is not found.
*/
Symbol findSymbol( const std::string &symbol );
private:
/*! Loads the specified library.
* \param libraryName Name of the library to load.
* \exception DynamicLibraryManagerException if a failure occurs while loading
* the library (fail to found or load the library).
*/
void loadLibrary( const std::string &libraryName );
/*! Releases the loaded library.
*
* \warning Must NOT throw any exceptions (called from destructor).
*/
void releaseLibrary();
/*! Loads the specified library.
*
* May throw any exceptions (indicates failure).
* \param libraryName Name of the library to load.
* \return Handle of the loaded library. \c NULL indicates failure.
*/
LibraryHandle doLoadLibrary( const std::string &libraryName );
/*! Releases the loaded library.
*
* The handle of the library to free is in \c m_libraryHandle. It is never
* \c NULL.
* \warning Must NOT throw any exceptions (called from destructor).
*/
void doReleaseLibrary();
/*! Returns a pointer on the specified symbol exported by the library.
*
* May throw any exceptions (indicates failure).
* \param symbol Name of the symbol exported by the library.
* \return Pointer on the symbol. \c NULL indicates failure.
*/
Symbol doFindSymbol( const std::string &symbol );
/*! Returns detailed information about doLoadLibrary() failure.
*
* Called just after a failed call to doLoadLibrary() to get extra
* error information.
*
* \return Detailed information about the failure of the call to
* doLoadLibrary() that just failed.
*/
std::string getLastErrorDetail() const;
/// Prevents the use of the copy constructor.
DynamicLibraryManager( const DynamicLibraryManager &copy );
/// Prevents the use of the copy operator.
void operator =( const DynamicLibraryManager &copy );
private:
LibraryHandle m_libraryHandle;
std::string m_libraryName;
};
CPPUNIT_NS_END
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H

View file

@ -0,0 +1,53 @@
#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <stdexcept>
#include <string>
CPPUNIT_NS_BEGIN
/*! \brief Exception thrown by DynamicLibraryManager when a failure occurs.
*
* Use getCause() to know what function caused the failure.
*
*/
class DynamicLibraryManagerException : public std::runtime_error
{
public:
enum Cause
{
/// Failed to load the dynamic library
loadingFailed =0,
/// Symbol not found in the dynamic library
symbolNotFound
};
/// Failed to load the dynamic library or Symbol not found in the dynamic library.
DynamicLibraryManagerException( const std::string &libraryName,
const std::string &errorDetail,
Cause cause );
~DynamicLibraryManagerException() throw()
{
}
Cause getCause() const;
const char *what() const throw();
private:
std::string m_message;
Cause m_cause;
};
CPPUNIT_NS_END
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H

View file

@ -0,0 +1,9 @@
libcppunitincludedir = $(includedir)/cppunit/plugin
libcppunitinclude_HEADERS = \
DynamicLibraryManager.h \
DynamicLibraryManagerException.h \
TestPlugIn.h \
TestPlugInDefaultImpl.h \
PlugInManager.h \
PlugInParameters.h

View file

@ -0,0 +1,437 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = include/cppunit/plugin
DIST_COMMON = $(libcppunitinclude_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = \
$(top_srcdir)/config/ac_create_prefix_config_h.m4 \
$(top_srcdir)/config/ac_cxx_have_sstream.m4 \
$(top_srcdir)/config/ac_cxx_have_strstream.m4 \
$(top_srcdir)/config/ac_cxx_namespaces.m4 \
$(top_srcdir)/config/ac_cxx_rtti.m4 \
$(top_srcdir)/config/ac_cxx_string_compare_string_first.m4 \
$(top_srcdir)/config/ac_dll.m4 \
$(top_srcdir)/config/ax_cxx_gcc_abi_demangle.m4 \
$(top_srcdir)/config/ax_cxx_have_isfinite.m4 \
$(top_srcdir)/config/bb_enable_doxygen.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libcppunitincludedir)"
libcppunitincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(libcppunitinclude_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_BINARY_AGE = @CPPUNIT_BINARY_AGE@
CPPUNIT_INTERFACE_AGE = @CPPUNIT_INTERFACE_AGE@
CPPUNIT_MAJOR_VERSION = @CPPUNIT_MAJOR_VERSION@
CPPUNIT_MICRO_VERSION = @CPPUNIT_MICRO_VERSION@
CPPUNIT_MINOR_VERSION = @CPPUNIT_MINOR_VERSION@
CPPUNIT_VERSION = @CPPUNIT_VERSION@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DOT = @DOT@
DOXYGEN = @DOXYGEN@
DSYMUTIL = @DSYMUTIL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBADD_DL = @LIBADD_DL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
enable_dot = @enable_dot@
enable_html_docs = @enable_html_docs@
enable_latex_docs = @enable_latex_docs@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
libcppunitincludedir = $(includedir)/cppunit/plugin
libcppunitinclude_HEADERS = \
DynamicLibraryManager.h \
DynamicLibraryManagerException.h \
TestPlugIn.h \
TestPlugInDefaultImpl.h \
PlugInManager.h \
PlugInParameters.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/cppunit/plugin/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu include/cppunit/plugin/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-libcppunitincludeHEADERS: $(libcppunitinclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(libcppunitincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libcppunitincludedir)"
@list='$(libcppunitinclude_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(libcppunitincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(libcppunitincludedir)/$$f'"; \
$(libcppunitincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(libcppunitincludedir)/$$f"; \
done
uninstall-libcppunitincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(libcppunitinclude_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(libcppunitincludedir)/$$f'"; \
rm -f "$(DESTDIR)$(libcppunitincludedir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(libcppunitincludedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-libcppunitincludeHEADERS
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-libcppunitincludeHEADERS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-libcppunitincludeHEADERS install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-libcppunitincludeHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -0,0 +1,113 @@
#ifndef CPPUNIT_PLUGIN_PLUGINMANAGER_H
#define CPPUNIT_PLUGIN_PLUGINMANAGER_H
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( push )
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
#endif
#include <cppunit/plugin/PlugInParameters.h>
struct CppUnitTestPlugIn;
CPPUNIT_NS_BEGIN
class DynamicLibraryManager;
class TestResult;
class XmlOutputter;
/*! \brief Manges TestPlugIn.
*/
class CPPUNIT_API PlugInManager
{
public:
/*! Constructs a PlugInManager object.
*/
PlugInManager();
/// Destructor.
virtual ~PlugInManager();
/*! \brief Loads the specified plug-in.
*
* After being loaded, the CppUnitTestPlugIn::initialize() is called.
*
* \param libraryFileName Name of the file that contains the TestPlugIn.
* \param parameters List of string passed to the plug-in.
* \return Pointer on the DynamicLibraryManager associated to the library.
* Valid until the library is unloaded. Never \c NULL.
* \exception DynamicLibraryManagerException is thrown if an error occurs during loading.
*/
void load( const std::string &libraryFileName,
const PlugInParameters &parameters = PlugInParameters() );
/*! \brief Unloads the specified plug-in.
* \param libraryFileName Name of the file that contains the TestPlugIn passed
* to a previous call to load().
*/
void unload( const std::string &libraryFileName );
/*! \brief Gives a chance to each loaded plug-in to register TestListener.
*
* For each plug-in, call CppUnitTestPlugIn::addListener().
*/
void addListener( TestResult *eventManager );
/*! \brief Gives a chance to each loaded plug-in to unregister TestListener.
* For each plug-in, call CppUnitTestPlugIn::removeListener().
*/
void removeListener( TestResult *eventManager );
/*! \brief Provides a way for the plug-in to register some XmlOutputterHook.
*/
void addXmlOutputterHooks( XmlOutputter *outputter );
/*! \brief Called when the XmlOutputter is destroyed.
*
* Can be used to free some resources allocated by addXmlOutputterHooks().
*/
void removeXmlOutputterHooks();
protected:
/*! \brief (INTERNAL) Information about a specific plug-in.
*/
struct PlugInInfo
{
std::string m_fileName;
DynamicLibraryManager *m_manager;
CppUnitTestPlugIn *m_interface;
};
/*! Unloads the specified plug-in.
* \param plugIn Information about the plug-in.
*/
void unload( PlugInInfo &plugIn );
private:
/// Prevents the use of the copy constructor.
PlugInManager( const PlugInManager &copy );
/// Prevents the use of the copy operator.
void operator =( const PlugInManager &copy );
private:
typedef CppUnitDeque<PlugInInfo> PlugIns;
PlugIns m_plugIns;
};
CPPUNIT_NS_END
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( pop )
#endif
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_PLUGINMANAGER_H

View file

@ -0,0 +1,36 @@
#ifndef CPPUNIT_PLUGIN_PARAMETERS
#define CPPUNIT_PLUGIN_PARAMETERS
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <cppunit/portability/CppUnitDeque.h>
#include <string>
CPPUNIT_NS_BEGIN
/*! \brief Test plug-ins parameters.
*/
class CPPUNIT_API PlugInParameters
{
public:
/// Constructs plug-in parameters from the specified command-line.
PlugInParameters( const std::string &commandLine = "" );
virtual ~PlugInParameters();
/// Returns the command line that was passed on construction.
std::string getCommandLine() const;
private:
std::string m_commandLine;
};
CPPUNIT_NS_END
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_PARAMETERS

View file

@ -0,0 +1,200 @@
#ifndef CPPUNIT_PLUGIN_TESTPLUGIN
#define CPPUNIT_PLUGIN_TESTPLUGIN
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <cppunit/plugin/PlugInParameters.h>
CPPUNIT_NS_BEGIN
class Test;
class TestFactoryRegistry;
class TestResult;
class XmlOutputter;
CPPUNIT_NS_END
/*! \file
*/
/*! \brief Test plug-in interface.
* \ingroup WritingTestPlugIn
*
* This class define the interface implemented by test plug-in. A pointer to that
* interface is returned by the function exported by the test plug-in.
*
* Plug-in are loaded/unloaded by PlugInManager. When a plug-in is loaded,
* initialize() is called. Before unloading the plug-in, the PlugInManager
* call uninitialize().
*
* addListener() and removeListener() are called respectively before and after
* the test run.
*
* addXmlOutputterHooks() and removeXmlOutputterHooks() are called respectively
* before and after writing the XML output using a XmlOutputter.
*
* \see CPPUNIT_PLUGIN_IMPLEMENT, CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL
* \see CppUnit::TestPlugInDefaultImpl, CppUnit::XmlOutputter.
*/
struct CppUnitTestPlugIn
{
/*! \brief Called just after loading the dynamic library.
*
* Override this method to add additional suite to the registry, though this
* is preferably done using the macros (CPPUNIT_TEST_SUITE_REGISTRATION...).
* If you are creating a custom listener to extends the plug-in runner,
* you can use this to configure the listener using the \a parameters.
*
* You could also use the parameters to specify some global parameter, such
* as test datas location, database name...
*
* N.B.: Parameters interface is not define yet, and the plug-in runner does
* not yet support plug-in parameter.
*/
virtual void initialize( CPPUNIT_NS::TestFactoryRegistry *registry,
const CPPUNIT_NS::PlugInParameters &parameters ) =0;
/*! \brief Gives a chance to the plug-in to register TestListener.
*
* Override this method to add a TestListener for the test run. This is useful
* if you are writing a custom TestListener, but also if you need to
* setUp some global resource: listen to TestListener::startTestRun(),
* and TestListener::endTestRun().
*/
virtual void addListener( CPPUNIT_NS::TestResult *eventManager ) =0;
/*! \brief Gives a chance to the plug-in to remove its registered TestListener.
*
* Override this method to remove a TestListener that has been added.
*/
virtual void removeListener( CPPUNIT_NS::TestResult *eventManager ) =0;
/*! \brief Provides a way for the plug-in to register some XmlOutputterHook.
*/
virtual void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter ) =0;
/*! \brief Called when the XmlOutputter is destroyed.
*
* Can be used to free some resources allocated by addXmlOutputterHooks().
*/
virtual void removeXmlOutputterHooks() = 0;
/*! \brief Called just before unloading the dynamic library.
*
* Override this method to unregister test factory added in initialize().
* This is necessary to keep the TestFactoryRegistry 'clean'. When
* the plug-in is unloaded from memory, the TestFactoryRegistry will hold
* reference on test that are no longer available if they are not
* unregistered.
*/
virtual void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry ) =0;
virtual ~CppUnitTestPlugIn() {}
};
/*! \brief Name of the function exported by a test plug-in.
* \ingroup WritingTestPlugIn
*
* The signature of the exported function is:
* \code
* CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void);
* \endcode
*/
#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn
/*! \brief Type of the function exported by a plug-in.
* \ingroup WritingTestPlugIn
*/
typedef CppUnitTestPlugIn *(*TestPlugInSignature)();
/*! \brief Implements the function exported by the test plug-in
* \ingroup WritingTestPlugIn
*/
#define CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( TestPlugInInterfaceType ) \
CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void) \
{ \
static TestPlugInInterfaceType plugIn; \
return &plugIn; \
} \
typedef char __CppUnitPlugInExportFunctionDummyTypeDef // dummy typedef so it can end with ';'
// Note: This include should remain after definition of CppUnitTestPlugIn
#include <cppunit/plugin/TestPlugInDefaultImpl.h>
/*! \def CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
* \brief Implements the 'main' function for the plug-in.
*
* This macros implements the main() function for dynamic library.
* For example, WIN32 requires a DllMain function, while some Unix
* requires a main() function. This macros takes care of the implementation.
*/
// Win32
#if defined(CPPUNIT_HAVE_WIN32_DLL_LOADER)
#if !defined(APIENTRY)
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#define NOUSER
#define NOKERNEL
#define NOSOUND
#define NOMINMAX
#define BLENDFUNCTION void // for mingw & gcc
#include <windows.h>
#endif
#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
BOOL APIENTRY DllMain( HANDLE hModule, \
DWORD ul_reason_for_call, \
LPVOID lpReserved ) \
{ \
return TRUE; \
} \
typedef char __CppUnitPlugInImplementMainDummyTypeDef
// Unix
#elif defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) || defined(CPPUNIT_HAVE_UNIX_SHL_LOADER)
#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
int main( int argc, char *argv[] ) \
{ \
return 0; \
} \
typedef char __CppUnitPlugInImplementMainDummyTypeDef
// Other
#else // other platforms don't require anything specifics
#endif
/*! \brief Implements and exports the test plug-in interface.
* \ingroup WritingTestPlugIn
*
* This macro exports the test plug-in function using the subclass,
* and implements the 'main' function for the plug-in using
* CPPUNIT_PLUGIN_IMPLEMENT_MAIN().
*
* When using this macro, CppUnit must be linked as a DLL (shared library).
* Otherwise, tests registered to the TestFactoryRegistry in the DLL will
* not be visible to the DllPlugInTester.
*
* \see CppUnitTestPlugIn
* \see CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL(), CPPUNIT_PLUGIN_IMPLEMENT_MAIN().
*/
#define CPPUNIT_PLUGIN_IMPLEMENT() \
CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( CPPUNIT_NS::TestPlugInDefaultImpl ); \
CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_TESTPLUGIN

View file

@ -0,0 +1,52 @@
#ifndef CPPUNIT_PLUGIN_TESTPLUGINADAPTER
#define CPPUNIT_PLUGIN_TESTPLUGINADAPTER
#include <cppunit/Portability.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <cppunit/plugin/TestPlugIn.h>
CPPUNIT_NS_BEGIN
class TestSuite;
/*! \brief Default implementation of test plug-in interface.
* \ingroup WritingTestPlugIn
*
* Override getSuiteName() to specify the suite name. Default is "All Tests".
*
* CppUnitTestPlugIn::getTestSuite() returns a suite that contains
* all the test registered to the default test factory registry
* ( TestFactoryRegistry::getRegistry() ).
*
*/
class CPPUNIT_API TestPlugInDefaultImpl : public CppUnitTestPlugIn
{
public:
TestPlugInDefaultImpl();
virtual ~TestPlugInDefaultImpl();
void initialize( TestFactoryRegistry *registry,
const PlugInParameters &parameters );
void addListener( TestResult *eventManager );
void removeListener( TestResult *eventManager );
void addXmlOutputterHooks( XmlOutputter *outputter );
void removeXmlOutputterHooks();
void uninitialize( TestFactoryRegistry *registry );
};
CPPUNIT_NS_END
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
#endif // CPPUNIT_PLUGIN_TESTPLUGINADAPTER