From 703e5e1a088820d3a2d6d50281e761a99e35c6d8 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 7 Sep 2012 08:44:50 +0200 Subject: fixed all tests and rewrote module test --- tests/modules/Common.hpp | 26 ------------------ tests/modules/GNUmakefile | 10 ++++--- tests/modules/exec_test | 2 +- tests/modules/libcommon/Common.cpp | 27 +++++++++++++++++++ tests/modules/libcommon/Common.hpp | 26 ++++++++++++++++++ tests/modules/libcommon/CommonExportable.hpp | 26 ++++++++++++++++++ tests/modules/libcommon/GNUmakefile | 35 ++++++++++++++++++++++++ tests/modules/libcommon/Makefile.W32 | 40 ++++++++++++++++++++++++++++ tests/modules/testmod2/GNUmakefile | 3 ++- tests/modules/testmod3/GNUmakefile | 3 ++- tests/typedetect/GNUmakefile | 1 + tests/url/GNUmakefile | 3 ++- tests/utils/test3.cpp | 2 -- 13 files changed, 168 insertions(+), 36 deletions(-) delete mode 100755 tests/modules/Common.hpp create mode 100755 tests/modules/libcommon/Common.cpp create mode 100755 tests/modules/libcommon/Common.hpp create mode 100755 tests/modules/libcommon/CommonExportable.hpp create mode 100755 tests/modules/libcommon/GNUmakefile create mode 100755 tests/modules/libcommon/Makefile.W32 (limited to 'tests') diff --git a/tests/modules/Common.hpp b/tests/modules/Common.hpp deleted file mode 100755 index e5c0624..0000000 --- a/tests/modules/Common.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __COMMON_H -#define __COMMON_H - -#include "Singleton.hpp" -#include "Exportable.hpp" - -#include -#include - -using namespace std; - -class Common : public Singleton< Common > -{ - private: - string m_name; - - public: - Common( ) : m_name( "noname" ) { cout << "Created common object" << endl; } - virtual ~Common( ) { cout << "Destroyed common object" << endl; } - void setName( string name ) { m_name = name; } - void print( string s ) { cout << m_name << ": " << s << endl; } -}; - -SINGLETON_EXTERN template class SINGLETON_EXPORT Singleton< Common >; - -#endif diff --git a/tests/modules/GNUmakefile b/tests/modules/GNUmakefile index ba0040b..e00e9c9 100755 --- a/tests/modules/GNUmakefile +++ b/tests/modules/GNUmakefile @@ -1,18 +1,20 @@ TOPDIR = ../.. -SUBDIRS = testmod testmod2 testmod3 +SUBDIRS = libcommon testmod testmod2 testmod3 INCLUDE_DIRS = \ -I. -I$(TOPDIR)/src \ -I$(TOPDIR)/include/module \ - -I$(TOPDIR)/include/util + -I$(TOPDIR)/include/util \ + -I$(TOPDIR)/tests/modules/libcommon INCLUDE_LDFLAGS = \ - -L$(TOPDIR)/src/logger + -L$(TOPDIR)/src/logger \ + -L$(TOPDIR)/tests/modules/libcommon INCLUDE_LIBS = \ $(TOPDIR)/src/libcrawler.a \ - -llogger + -llogger -lcommon TEST_CPP_BINS = \ test1$(EXE) \ diff --git a/tests/modules/exec_test b/tests/modules/exec_test index 626d298..096a7ba 100755 --- a/tests/modules/exec_test +++ b/tests/modules/exec_test @@ -4,5 +4,5 @@ BINARY=$1 TITLE=$2 printf "$BINARY: $TITLE .. " -LD_LIBRARY_PATH=../../src:../../src/logger ./$BINARY >$BINARY.RES 2>&1 +LD_LIBRARY_PATH=../../src:../../src/logger:libcommon ./$BINARY >$BINARY.RES 2>&1 diff $BINARY.MUST $BINARY.RES > $BINARY.DIFF && printf "OK\n" || printf "ERROR\n" diff --git a/tests/modules/libcommon/Common.cpp b/tests/modules/libcommon/Common.cpp new file mode 100755 index 0000000..82a4ae1 --- /dev/null +++ b/tests/modules/libcommon/Common.cpp @@ -0,0 +1,27 @@ +#include "Common.hpp" + +#include +#include + +using namespace std; + +Common::Common( ) + : m_name( "noname" ) +{ + cout << "Created common object" << endl; +} + +Common::~Common( ) +{ + cout << "Destroyed common object" << endl; +} + +void Common::setName( string name ) +{ + m_name = name; +} + +void Common::print( string s ) +{ + cout << m_name << ": " << s << endl; +} diff --git a/tests/modules/libcommon/Common.hpp b/tests/modules/libcommon/Common.hpp new file mode 100755 index 0000000..22ca5a2 --- /dev/null +++ b/tests/modules/libcommon/Common.hpp @@ -0,0 +1,26 @@ +#ifndef __COMMON_H +#define __COMMON_H + +#include "Singleton.hpp" +#include "CommonExportable.hpp" + +#include + +using namespace std; + +class Common : public Singleton< Common > +{ + public: + DECLARE_SINGLETON( Common ) + + public: + Common( ); + virtual ~Common( ); + void setName( string name ); + void print( string s ); + + private: + string m_name; +}; + +#endif diff --git a/tests/modules/libcommon/CommonExportable.hpp b/tests/modules/libcommon/CommonExportable.hpp new file mode 100755 index 0000000..15abf62 --- /dev/null +++ b/tests/modules/libcommon/CommonExportable.hpp @@ -0,0 +1,26 @@ +#ifndef __COMMON_EXPORTABLE_H +#define __COMMON_EXPORTABLE_H + +#ifndef _WIN32 + +#define COMMON_DLL_VISIBLE + +#else + +#ifdef SHARED + +#ifdef BUILDING_COMMON +#define COMMON_DLL_VISIBLE __declspec(dllexport) +#else +#define COMMON_DLL_VISIBLE __declspec(dllimport) +#endif + +#else + +#define COMMON_DLL_VISIBLE + +#endif // BUILDING_COMMON + +#endif // _WIN32 + +#endif diff --git a/tests/modules/libcommon/GNUmakefile b/tests/modules/libcommon/GNUmakefile new file mode 100755 index 0000000..bb2df86 --- /dev/null +++ b/tests/modules/libcommon/GNUmakefile @@ -0,0 +1,35 @@ +TOPDIR = ../../.. + +SUBDIRS = + +INCLUDE_DIRS = \ + -I. -I$(TOPDIR)/src \ + -I$(TOPDIR)/include/module \ + -I$(TOPDIR)/include/util + +INCLUDE_LDFLAGS = \ + -L$(TOPDIR)/src/logger + +INCLUDE_LIBS = \ + $(TOPDIR)/src/libcrawler.a \ + -llogger + +STATIC_LIB = libcommon.a + +DYNAMIC_LIB = libcommon.so +DYNAMIC_LIB_MAJOR = 0 +DYNAMIC_LIB_MINOR = 0 +DYNAMIC_LIB_PATCH = 0 + +CPP_OBJS = \ + Common.o + +-include $(TOPDIR)/makefiles/gmake/sub.mk + +local_all: + +local_clean: + +local_distclean: + +local_test: diff --git a/tests/modules/libcommon/Makefile.W32 b/tests/modules/libcommon/Makefile.W32 new file mode 100755 index 0000000..3dc28b6 --- /dev/null +++ b/tests/modules/libcommon/Makefile.W32 @@ -0,0 +1,40 @@ +TOPDIR = ..\.. + +SUBDIRS = testmod testmod2 testmod3 + +!INCLUDE $(TOPDIR)\makefiles\nmake\platform.mk + +INCLUDE_CXXFLAGS = \ + /D_WIN32_WINNT=0x504 \ + /DBUILDING_CRAWLER /DBUILDING_UTIL + +INCLUDE_DIRS = \ + /I. \ + /I$(TOPDIR)\src + +INCLUDE_LDFLAGS = \ + +INCLUDE_LIBS = \ + $(TOPDIR)\src\crawler.lib + +OBJS = + +!INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk + +test1.exe: test1.obj +test2.exe: test2.obj +test3.exe: test3.obj + +# must build test2.lib first becase it contains DDL exports for the +# Common singleton +local_all: test2.exe + +local_clean: + @-erase -f *.RES *.DIFF *.ERR 2>NUL + +local_distclean: + +local_test: + @-exec_test test1 "Module loader" + @-exec_test test2 "Module loader with singleton" + @-exec_test test3 "Load module in module" diff --git a/tests/modules/testmod2/GNUmakefile b/tests/modules/testmod2/GNUmakefile index 5e4630f..2511adb 100755 --- a/tests/modules/testmod2/GNUmakefile +++ b/tests/modules/testmod2/GNUmakefile @@ -7,7 +7,8 @@ SUBDIRS = INCLUDE_DIRS = \ -I. -I$(TOPDIR)/src -I.. \ -I$(TOPDIR)/include/module \ - -I$(TOPDIR)/include/util + -I$(TOPDIR)/include/util \ + -I$(TOPDIR)/tests/modules/libcommon INCLUDE_CXXFLAGS = \ diff --git a/tests/modules/testmod3/GNUmakefile b/tests/modules/testmod3/GNUmakefile index 643fd6a..be1b104 100755 --- a/tests/modules/testmod3/GNUmakefile +++ b/tests/modules/testmod3/GNUmakefile @@ -7,7 +7,8 @@ SUBDIRS = INCLUDE_DIRS = \ -I. -I$(TOPDIR)/src -I.. \ -I$(TOPDIR)/include/module \ - -I$(TOPDIR)/include/util + -I$(TOPDIR)/include/util \ + -I$(TOPDIR)/tests/modules/libcommon INCLUDE_CXXFLAGS = \ diff --git a/tests/typedetect/GNUmakefile b/tests/typedetect/GNUmakefile index 065d95b..d8656fa 100644 --- a/tests/typedetect/GNUmakefile +++ b/tests/typedetect/GNUmakefile @@ -9,6 +9,7 @@ INCLUDE_DIRS = \ -I$(TOPDIR)/src \ -I$(TOPDIR)/include/util \ -I$(TOPDIR)/include/module \ + -I$(TOPDIR)/include/crawler \ -I$(TOPDIR)/src/modules/typedetect/libmagic \ -I$(TOPDIR)/src/modules/fetcher/file \ -I$(TOPDIR)/src/modules/fetcher/libfetch \ diff --git a/tests/url/GNUmakefile b/tests/url/GNUmakefile index e99e178..1325f30 100644 --- a/tests/url/GNUmakefile +++ b/tests/url/GNUmakefile @@ -10,7 +10,8 @@ INCLUDE_DIRS = \ -I$(TOPDIR)/src/modules/urlnormalizer/simpleurl \ -I$(TOPDIR)/src/modules/urlnormalizer/googleurl \ -I$(TOPDIR)/include/module \ - -I$(TOPDIR)/include/util + -I$(TOPDIR)/include/util \ + -I$(TOPDIR)/include/crawler INCLUDE_LDFLAGS = \ -L$(TOPDIR)/src \ diff --git a/tests/utils/test3.cpp b/tests/utils/test3.cpp index a07365a..70ac676 100755 --- a/tests/utils/test3.cpp +++ b/tests/utils/test3.cpp @@ -15,8 +15,6 @@ class Logger : public Singleton< Logger > cout << s << endl; } - friend class Singleton< Logger >; - protected: Logger( ) { -- cgit v1.2.3-54-g00ecf