diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-07-12 23:20:04 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-07-12 23:20:04 +0200 |
commit | a441d2f44ca233c9d3f0228e76b3072e9cdb7fda (patch) | |
tree | 1daedd331468d22477842fdb083b2dd5f2a2b3c1 | |
parent | 701352f84ddd204d738407c29a4b6e501694a59c (diff) | |
download | crawler-a441d2f44ca233c9d3f0228e76b3072e9cdb7fda.tar.gz crawler-a441d2f44ca233c9d3f0228e76b3072e9cdb7fda.tar.bz2 |
fixed tests and added a libfetch test
-rw-r--r-- | libfetch/GNUmakefile | 13 | ||||
-rw-r--r-- | makefiles/gmake/help.mk | 4 | ||||
-rw-r--r-- | makefiles/gmake/platform.mk | 52 | ||||
-rw-r--r-- | makefiles/gmake/sub.mk | 2 | ||||
-rw-r--r-- | tests/GNUmakefile | 2 | ||||
-rw-r--r-- | tests/libfetch/GNUmakefile | 36 | ||||
-rw-r--r-- | tests/libfetch/test1.c | 36 |
7 files changed, 131 insertions, 14 deletions
diff --git a/libfetch/GNUmakefile b/libfetch/GNUmakefile index 75598b8..181270d 100644 --- a/libfetch/GNUmakefile +++ b/libfetch/GNUmakefile @@ -5,7 +5,8 @@ SUBDIRS = -include $(TOPDIR)/makefiles/gmake/platform.mk INCLUDE_CFLAGS = \ - -DHAVE_CONFIG_H=0 -D_XOPEN_SOURCE=600 + -DHAVE_CONFIG_H=0 -D_XOPEN_SOURCE=600 -DFTP_COMBINE_CWDS \ + -DINET6 INCLUDE_LDFLAGS = \ @@ -14,6 +15,16 @@ INCLUDE_DIRS = \ INCLUDE_LIBS = \ +# openssl +ifeq ($(WITH_SSL),1) + +INCLUDE_CFLAGS += \ + -DWITH_SSL + +INCLUDE_LIBS += \ + $(OPENSSL_LIBS) +endif + OBJS = \ common.o \ fetch.o \ diff --git a/makefiles/gmake/help.mk b/makefiles/gmake/help.mk index b5ffa62..2b5f07a 100644 --- a/makefiles/gmake/help.mk +++ b/makefiles/gmake/help.mk @@ -17,6 +17,8 @@ make check-po check sanity of gettext files Available optional features: +WITH_SSL=1 use OpenSSL additionally for communication encryption + frontier implementations: WITH_SYSTEM_SQLITE3=1 use the system version of sqlite3 @@ -37,4 +39,4 @@ Some more obscure options: ENABLE_NLS=0 Don't build gettext NLS support (default is on) Example: -make WITH_SQLITE3=1 WITH_PGSQL=1 WITH_LIBXML2=1 +make WITH_SSL=1 WITH_SQLITE3=1 WITH_PGSQL=1 WITH_LOCAL_LIBFETCH=1 WITH_LIBXML2=1 diff --git a/makefiles/gmake/platform.mk b/makefiles/gmake/platform.mk index 6ad041e..ad29eb9 100644 --- a/makefiles/gmake/platform.mk +++ b/makefiles/gmake/platform.mk @@ -21,21 +21,11 @@ # set up defaults for the build switches WITH_SSL ?= 0 -WITH_LUA ?= 0 -WITH_SASL ?= 0 -WITH_PAM ?= 0 WITH_SYSTEM_SQLITE3 ?= 0 WITH_LOCAL_SQLITE3 ?= 0 WITH_PGSQL ?= 0 WITH_LIBXML2 ?= 0 -WITH_LIBXSLT ?= 0 -WITH_SYSTEM_LIBHPDF ?= 0 -WITH_LOCAL_LIBHPDF ?= 0 -WITH_QT ?= 0 -WITH_LIBGMP ?= 0 -WITH_EXAMPLES ?= 1 ENABLE_NLS ?= 1 -RUN_TESTS ?= 1 # variables guessed by 'guess_env' PLATFORM ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --platform "$(CC)" "$(CURDIR)" $(TOPDIR)) @@ -272,3 +262,45 @@ endif PLATFORM_COMPILE_FLAGS += $(INCLUDE_FLAGS_NET) +# OpenSSL +######### + +ifeq ($(WITH_SSL),1) + +ifeq "$(PLATFORM)" "LINUX" + +OPENSSL_LIBS ?= -lssl -lcrypto + +endif + +ifeq "$(PLATFORM)" "SUNOS" +ifeq "$(OS_MAJOR_VERSION)" "5" +ifeq "$(OS_MINOR_VERSION)" "10" +OPENSSL_DIR ?= /usr/local/ssl +OPENSSL_LIBS ?= -lssl -lcrypto +endif +endif +endif + +ifeq "$(PLATFORM)" "FREEBSD" +ifeq "$(OS_MAJOR_VERSION)" "8" +OPENSSL_LIBS ?= -lssl -lcrypto +endif +ifeq "$(OS_MAJOR_VERSION)" "9" +OPENSSL_LIBS ?= -lssl -lcrypto +endif +endif + +ifeq "$(PLATFORM)" "OPENBSD" +ifeq "$(OS_MAJOR_VERSION)" "5" +OPENSSL_LIBS ?= -lssl -lcrypto +endif +endif + +ifeq "$(PLATFORM)" "NETBSD" +ifeq "$(OS_MAJOR_VERSION)" "5" +OPENSSL_LIBS ?= -lssl -lcrypto +endif +endif + +endif diff --git a/makefiles/gmake/sub.mk b/makefiles/gmake/sub.mk index 5e4bf63..787fb0b 100644 --- a/makefiles/gmake/sub.mk +++ b/makefiles/gmake/sub.mk @@ -19,7 +19,7 @@ $(SUBDIRS): $(MAKE) -C $@ all .PHONY: test local_test -test: all local_test +test: all $(TEST_BINS) $(TEST_CPP_BINS) local_test @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ (set -e; $(MAKE) -C $$d test || exit 1); done) diff --git a/tests/GNUmakefile b/tests/GNUmakefile index 934e454..d6e5040 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -1,6 +1,6 @@ TOPDIR = .. -SUBDIRS = curl psql sqlite +SUBDIRS = libfetch curl psql sqlite -include $(TOPDIR)/makefiles/gmake/sub.mk diff --git a/tests/libfetch/GNUmakefile b/tests/libfetch/GNUmakefile new file mode 100644 index 0000000..a8d7495 --- /dev/null +++ b/tests/libfetch/GNUmakefile @@ -0,0 +1,36 @@ +TOPDIR = ../.. + +SUBDIRS = + +INCLUDE_DIRS = \ + -I$(TOPDIR)/libfetch + +INCLUDE_LDFLAGS = + +INCLUDE_LIBS = \ + $(TOPDIR)/libfetch/libfetch.a + +# openssl +ifeq ($(WITH_SSL),1) + +INCLUDE_CFLAGS += \ + -DWITH_SSL + +INCLUDE_LIBS += \ + $(OPENSSL_LIBS) +endif + +TEST_BINS = \ + test1$(EXE) + +OBJS = + +-include $(TOPDIR)/makefiles/gmake/sub.mk + +local_all: + +local_clean: + +local_distclean: + +local_test: diff --git a/tests/libfetch/test1.c b/tests/libfetch/test1.c new file mode 100644 index 0000000..fd28563 --- /dev/null +++ b/tests/libfetch/test1.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <fetch.h> + +int main( int argc, char *argv[] ) +{ + char *urlstring; + fetchIO *io; + char buf[1024]; + ssize_t res; + + if( argc != 2 ) { + fputs( "Usage: test1 <url>\n", stderr ); + exit( EXIT_FAILURE ); + } + + urlstring = argv[1]; + + fetchTimeout = 2; + + io = fetchGetURL( urlstring, "" ); + if( io == NULL ) { + fprintf( stderr, "ERROR: %s\n", fetchLastErrString ); + exit( EXIT_FAILURE ); + } + + while( ( res = fetchIO_read( io, buf, sizeof( buf ) ) ) != 0 ) { + puts( buf ); + } + + fetchIO_close( io ); + + exit( EXIT_SUCCESS ); +} |