diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-08-20 09:12:44 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-08-20 09:12:44 +0200 |
commit | e2289e28a55f0f340103cf0cc99d08fc63f48887 (patch) | |
tree | 617e56816b2c8488aedcc7a4bffd7724b3eab6cf | |
parent | d9094a67ac5cfe0ca392746b62ac8fe9b18a8785 (diff) | |
download | crawler-e2289e28a55f0f340103cf0cc99d08fc63f48887.tar.gz crawler-e2289e28a55f0f340103cf0cc99d08fc63f48887.tar.bz2 |
added a module test (Windows)
-rwxr-xr-x[-rw-r--r--] | TODOS | 7 | ||||
-rw-r--r-- | tests/GNUmakefile | 2 | ||||
-rw-r--r-- | tests/Makefile.W32 | 2 | ||||
-rwxr-xr-x | tests/modules/Base.hpp | 10 | ||||
-rwxr-xr-x | tests/modules/GNUmakefile | 27 | ||||
-rwxr-xr-x | tests/modules/Makefile.W32 | 36 | ||||
-rwxr-xr-x | tests/modules/exec_test | 8 | ||||
-rwxr-xr-x | tests/modules/exec_test.cmd | 15 | ||||
-rwxr-xr-x | tests/modules/test1.MUST | 1 | ||||
-rwxr-xr-x | tests/modules/test1.cpp | 31 | ||||
-rwxr-xr-x | tests/modules/testmod/GNUmakefile | 39 | ||||
-rwxr-xr-x | tests/modules/testmod/Makefile.W32 | 46 | ||||
-rwxr-xr-x | tests/modules/testmod/TestMod.cpp | 12 | ||||
-rwxr-xr-x | tests/modules/testmod/TestMod.hpp | 20 | ||||
-rwxr-xr-x | tests/utils/Makefile.W32 | 1 |
15 files changed, 252 insertions, 5 deletions
@@ -1,7 +1,8 @@ - singleton with registered pointers, so they can be shared between loadable modules on Windows, example is the logger singleton currently -- common spooling code in RewindInputStream must be extracted and - used in a cascade of streams (or streambufs?) +- rewrite logger as proper singleton - use traits in rewindinputstream, alternative wrappers for char/string traits depending on underlying io stream - +- spooling in RIS: + - thread-safe tempnames + - Windows, respect environment variables like TEMP diff --git a/tests/GNUmakefile b/tests/GNUmakefile index 4b3f5dc..440ba18 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -1,7 +1,7 @@ TOPDIR = .. SUBDIRS = \ - utils url streamhtmlparser libfetch curl psql sqlite typedetect \ + utils modules url streamhtmlparser libfetch curl psql sqlite typedetect \ fetcher -include $(TOPDIR)/makefiles/gmake/sub.mk diff --git a/tests/Makefile.W32 b/tests/Makefile.W32 index 748a309..d5ac96b 100644 --- a/tests/Makefile.W32 +++ b/tests/Makefile.W32 @@ -1,7 +1,7 @@ TOPDIR = .. SUBDIRS = \ - utils winhttp url streamhtmlparser \ + utils modules winhttp url streamhtmlparser \ fetcher !INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk diff --git a/tests/modules/Base.hpp b/tests/modules/Base.hpp new file mode 100755 index 0000000..688bc4c --- /dev/null +++ b/tests/modules/Base.hpp @@ -0,0 +1,10 @@ +#ifndef __BASE_H +#define __BASE_H + +class Base +{ + public: + virtual void hello( ) = 0; +}; + +#endif diff --git a/tests/modules/GNUmakefile b/tests/modules/GNUmakefile new file mode 100755 index 0000000..5466d1c --- /dev/null +++ b/tests/modules/GNUmakefile @@ -0,0 +1,27 @@ +TOPDIR = ../.. + +SUBDIRS = testmod + +INCLUDE_DIRS = \ + -I. -I$(TOPDIR)/src + +INCLUDE_LDFLAGS = + +INCLUDE_LIBS = + +TEST_CPP_BINS = \ + test1$(EXE) + +OBJS = + +-include $(TOPDIR)/makefiles/gmake/sub.mk + +local_all: + +local_clean: + -@rm -f *.RES *.DIFF + +local_distclean: + +local_test: +# @./exec_test test1 "TypeList and TypeTraits" diff --git a/tests/modules/Makefile.W32 b/tests/modules/Makefile.W32 new file mode 100755 index 0000000..3830e31 --- /dev/null +++ b/tests/modules/Makefile.W32 @@ -0,0 +1,36 @@ +TOPDIR = ..\.. + +SUBDIRS = testmod + +!INCLUDE $(TOPDIR)\makefiles\nmake\platform.mk + +INCLUDE_CXXFLAGS = \ + /D_WIN32_WINNT=0x504 + +INCLUDE_DIRS = \ + /I. \ + /I$(TOPDIR)\src + +INCLUDE_LDFLAGS = \ + +INCLUDE_LIBS = \ + $(TOPDIR)\src\crawler.lib + +TEST_CPP_BINS = \ + test1.exe + +OBJS = + +!INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk + +test1.exe: test1.obj + +local_all: + +local_clean: + @-erase -f *.RES *.DIFF *.ERR 2>NUL + +local_distclean: + +local_test: + @-exec_test test1 "Module loader" diff --git a/tests/modules/exec_test b/tests/modules/exec_test new file mode 100755 index 0000000..d2d606f --- /dev/null +++ b/tests/modules/exec_test @@ -0,0 +1,8 @@ +#!/bin/sh + +BINARY=$1 +TITLE=$2 + +printf "$BINARY: $TITLE .. " +./$BINARY >$BINARY.RES 2>&1 +diff $BINARY.MUST $BINARY.RES > $BINARY.DIFF && printf "OK\n" || printf "ERROR\n" diff --git a/tests/modules/exec_test.cmd b/tests/modules/exec_test.cmd new file mode 100755 index 0000000..81a6222 --- /dev/null +++ b/tests/modules/exec_test.cmd @@ -0,0 +1,15 @@ +@echo off
+
+set BINARY=%1
+set TITLE=%2
+
+%BINARY% >%BINARY%.OUT 2>%BINARY%.ERR
+..\..\utils\win32\dos2unix <%BINARY%.OUT >%BINARY%.RES
+erase /q %BINARY%.OUT
+echo n | comp %BINARY%.MUST %BINARY%.RES > %BINARY%.DIFF 2>NUL
+if ERRORLEVEL 1 GOTO FAIL
+echo %BINARY%: %TITLE%.. OK
+goto END
+:FAIL
+echo %BINARY%: %TITLE% .. ERROR
+:END
diff --git a/tests/modules/test1.MUST b/tests/modules/test1.MUST new file mode 100755 index 0000000..ce01362 --- /dev/null +++ b/tests/modules/test1.MUST @@ -0,0 +1 @@ +hello diff --git a/tests/modules/test1.cpp b/tests/modules/test1.cpp new file mode 100755 index 0000000..6b9229f --- /dev/null +++ b/tests/modules/test1.cpp @@ -0,0 +1,31 @@ +#include "ModuleLoader.hpp" +#include "Base.hpp" + +#include <vector> +#include <string> +#include <iostream> + +using namespace std; + +int main( void ) +{ + try { + vector<string> modules; +#ifndef _WIN32 + modules.push_back( "./testmod/mod_test.so" ); +#else + modules.push_back( ".\\testmod\\mod_test.dll" ); +#endif + ModuleLoader<Base> loader( modules ); + + Base *obj = loader.create( "testmod" ); + obj->hello( ); + loader.destroy( obj ); + + } catch( exception &e ) { + cerr << "Module loader error: " << e.what( ); + return 1; + } + + return 0; +} diff --git a/tests/modules/testmod/GNUmakefile b/tests/modules/testmod/GNUmakefile new file mode 100755 index 0000000..5211655 --- /dev/null +++ b/tests/modules/testmod/GNUmakefile @@ -0,0 +1,39 @@ +TOPDIR = ../../.. + +SUBDIRS = + +-include $(TOPDIR)/makefiles/gmake/platform.mk + +INCLUDE_DIRS = \ + -I. -I$(TOPDIR)/src + +INCLUDE_CXXFLAGS = \ + +INCLUDE_LDFLAGS = \ + +INCLUDE_LIBS = \ + $(TOPDIR)/src/libcrawler.a + +DYNAMIC_MODULE = \ + mod_test.so + +STATIC_LIB = \ + libtest.a + +CPP_OBJS = \ + TestMod.o + +-include $(TOPDIR)/makefiles/gmake/sub.mk + +local_all: + +local_clean: + +local_distclean: + +local_install: + +local_uninstall: + +local_test: + diff --git a/tests/modules/testmod/Makefile.W32 b/tests/modules/testmod/Makefile.W32 new file mode 100755 index 0000000..e01c220 --- /dev/null +++ b/tests/modules/testmod/Makefile.W32 @@ -0,0 +1,46 @@ +TOPDIR = ..\..\.. + +SUBDIRS = + +!INCLUDE $(TOPDIR)\makefiles\nmake\platform.mk + +INCLUDE_CXXFLAGS = \ + /D_WIN32_WINNT=0x504 + +INCLUDE_DIRS = \ + /I. \ + /I$(TOPDIR)\src \ + /I.. + +INCLUDE_LDFLAGS = \ + +INCLUDE_LIBS = \ + $(TOPDIR)\src\crawler.lib + +DYNAMIC_MODULE = \ + mod_test.dll + +STATIC_LIB = \ + test.lib + +CPP_OBJS = \ + TestMod.obj + +SHARED_CPP_OBJS = \ + TestMod.dllobj + +!INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk + +$(STATIC_LIB): $(CPP_OBJS) + $(LINK) /lib /nologo /out:$@ $(STATIC_LDFLAGS) $? + +$(DYNAMIC_MODULE): $(SHARED_CPP_OBJS) + $(LINK) /dll /nologo /out:$@ $(LDFLAGS) $(LIBS) $? + +local_all: $(STATIC_LIB) $(DYNAMIC_MODULE) + +local_clean: + +local_distclean: + +local_test: diff --git a/tests/modules/testmod/TestMod.cpp b/tests/modules/testmod/TestMod.cpp new file mode 100755 index 0000000..0728b87 --- /dev/null +++ b/tests/modules/testmod/TestMod.cpp @@ -0,0 +1,12 @@ +#include "TestMod.hpp" + +#include <iostream> + +using namespace std; + +void Derived::hello( ) +{ + cout << "hello" << endl; +} + +REGISTER_MODULE( "testmod", Base, Derived ) diff --git a/tests/modules/testmod/TestMod.hpp b/tests/modules/testmod/TestMod.hpp new file mode 100755 index 0000000..f4886cd --- /dev/null +++ b/tests/modules/testmod/TestMod.hpp @@ -0,0 +1,20 @@ +#ifndef __TESTMOD_H +#define __TESTMOD_H + +#include "Base.hpp" + +#include "ModuleRegistry.hpp" + +class Derived : public Base +{ + public: + Derived( ) { } + + virtual ~Derived( ) { } + + virtual void hello( ); +}; + +DECLARE_MODULE( Base ) + +#endif diff --git a/tests/utils/Makefile.W32 b/tests/utils/Makefile.W32 index a3b0b92..6f18d9c 100755 --- a/tests/utils/Makefile.W32 +++ b/tests/utils/Makefile.W32 @@ -26,6 +26,7 @@ OBJS = test1.exe: test1.obj test2.exe: test2.obj +test3.exe: test3.obj local_all: |