summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2012-09-07 08:44:50 +0200
committerAndreas Baumann <abaumann@yahoo.com>2012-09-07 08:44:50 +0200
commit703e5e1a088820d3a2d6d50281e761a99e35c6d8 (patch)
treee46f84bf6f08e4576381b3864d4b2178473708fc /tests
parent374c902e272f06833cfc67e3b8bd86cc7ae7cd3c (diff)
downloadcrawler-703e5e1a088820d3a2d6d50281e761a99e35c6d8.tar.gz
crawler-703e5e1a088820d3a2d6d50281e761a99e35c6d8.tar.bz2
fixed all tests and rewrote module test
Diffstat (limited to 'tests')
-rwxr-xr-xtests/modules/Common.hpp26
-rwxr-xr-xtests/modules/GNUmakefile10
-rwxr-xr-xtests/modules/exec_test2
-rwxr-xr-xtests/modules/libcommon/Common.cpp27
-rwxr-xr-xtests/modules/libcommon/Common.hpp26
-rwxr-xr-xtests/modules/libcommon/CommonExportable.hpp26
-rwxr-xr-xtests/modules/libcommon/GNUmakefile35
-rwxr-xr-xtests/modules/libcommon/Makefile.W3240
-rwxr-xr-xtests/modules/testmod2/GNUmakefile3
-rwxr-xr-xtests/modules/testmod3/GNUmakefile3
-rw-r--r--tests/typedetect/GNUmakefile1
-rw-r--r--tests/url/GNUmakefile3
-rwxr-xr-xtests/utils/test3.cpp2
13 files changed, 168 insertions, 36 deletions
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 <iostream>
-#include <string>
-
-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 <iostream>
+#include <string>
+
+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 <string>
+
+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( )
{