From 7a797e6a2b40dd10a88600789355388af59b7dea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Tue, 31 Aug 2004 16:32:31 +0000 Subject: [PATCH] First attempt to producer test --- org.glite.lb.client/Makefile | 29 ++++++++--- .../project/configure.properties.xml | 4 ++ org.glite.lb.client/test/prod_proto_test.c | 33 ++++++++++++ org.glite.lb.client/test/producer_test.cpp | 60 ++++++++++++++++++++++ 4 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 org.glite.lb.client/test/prod_proto_test.c create mode 100644 org.glite.lb.client/test/producer_test.cpp diff --git a/org.glite.lb.client/Makefile b/org.glite.lb.client/Makefile index ae3cc23..ab7d686 100644 --- a/org.glite.lb.client/Makefile +++ b/org.glite.lb.client/Makefile @@ -19,21 +19,24 @@ ares_prefix=/opt/ares -include Makefile.inc -VPATH=${top_srcdir}/src +VPATH=${top_srcdir}/src:${top_srcdir}/test AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 SUFFIXES = .T +DEBUG:=-g -O0 -Wall + GLOBUSINC:= -I${globus_prefix}/include/${nothrflavour} GLOBUSTHRINC:= -I${globus_prefix}/include/${thrflavour} -DEBUG:=-g -O0 CFLAGS:=${DEBUG} \ -I${top_srcdir}/src -I${top_srcdir}/interface \ -I${stagedir}/include \ -I${glite_location}/include \ -I${expat_prefix}/include \ - -I${ares_prefix}/include + -I${ares_prefix}/include \ + ${COVERAGE_FLAGS} + CXXFLAGS:=${CFLAGS} @@ -51,14 +54,19 @@ EXPAT_LIBS:=-L${expat_prefix}/lib \ ARES_LIBS:=-L${ares_prefix}/lib \ -lares -LDFLAGS:=-L${stagedir}/lib - EXT_LIB:= ${EXPAT_LIBS} \ ${ARES_LIBS} +TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit +TEST_INC:=-I${cppunit_prefix}/include + +LDFLAGS:=-L${stagedir}/lib \ + ${COVERAGE_FLAGS} + COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} CXXCOMPILE:=libtool --mode=compile ${CXX} ${CXXFLAGS} LINK:=libtool --mode=link ${CC} ${LDFLAGS} +LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} INSTALL:=libtool --mode=install install LIBOBJS:=connection.o consumer.o notification.o prod_proto.o \ @@ -134,9 +142,16 @@ default: all compile all: ${LIB} ${THRLIB} ${TOOLS} logevent ${PLUSLIB} ${THRPLUSLIB} -check: - echo No unit tests so far. +check: check.producer + +check.producer: producer_test +producer_test: producer_test.o prod_proto_test.o + ${LINKXX} -o $@ ${LIB} ${TEST_LIBS} $+ + +producer_test.o: %.o: %.cpp + ${CXX} -c ${CXXFLAGS} ${TEST_INC} $< + stage: compile $(MAKE) install PREFIX=${stagedir} dist: distsrc distbin diff --git a/org.glite.lb.client/project/configure.properties.xml b/org.glite.lb.client/project/configure.properties.xml index 1005c5c..17c4c40 100644 --- a/org.glite.lb.client/project/configure.properties.xml +++ b/org.glite.lb.client/project/configure.properties.xml @@ -20,6 +20,9 @@ Revision history: $Log$ + Revision 1.2 2004/07/06 20:47:11 flammer + Moved to configure.properties.xml + --> @@ -48,6 +51,7 @@ thrflavour=${with.globus.thr.flavor} nothrflavour=${with.globus.nothr.flavor} expat_prefix=${with.expat.prefix} ares_prefix=${with.ares.prefix} +cppunit_prefix=${with.cppunit.prefix} diff --git a/org.glite.lb.client/test/prod_proto_test.c b/org.glite.lb.client/test/prod_proto_test.c new file mode 100644 index 0000000..e0214fe --- /dev/null +++ b/org.glite.lb.client/test/prod_proto_test.c @@ -0,0 +1,33 @@ +#define edg_wll_gss_read_full(a,b,c,d,e,f) test_edg_wll_gss_read_full(a,b,c,d,e,f) +#define edg_wll_gss_write_full(a,b,c,d,e,f) test_edg_wll_gss_write_full(a,b,c,d,e,f) +#define edg_wll_GssConnection int + +#include "prod_proto.h" +#include "glite/lb/producer.h" +#include "glite/lb/escape.h" +#include "glite/lb/lb_gss.h" + +int +test_edg_wll_gss_read_full(int *fd, + void *buf, + size_t bufsize, + struct timeval *timeout, + size_t *total, + edg_wll_GssStatus *code) +{ + return(0); +} + +int +test_edg_wll_gss_write_full(int *fd, + const void *buf, + size_t bufsize, + struct timeval *timeout, + size_t *total, + edg_wll_GssStatus *code) +{ + *total = write(*fd, buf, bufsize); + return(*total < 0 ? *total : 0); +} + +#include "prod_proto.c" diff --git a/org.glite.lb.client/test/producer_test.cpp b/org.glite.lb.client/test/producer_test.cpp new file mode 100644 index 0000000..b717b85 --- /dev/null +++ b/org.glite.lb.client/test/producer_test.cpp @@ -0,0 +1,60 @@ +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +int edg_wll_log_proto_client(int *,char *,char *,int,int); +} + +class ProducerTest: public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(ProducerTest); + CPPUNIT_TEST(testProtoClient); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp() { + pipe(pd); + } + + void tearDown() { + close(pd[0]); + close(pd[1]); + } + + void testProtoClient() { + int ret=0; + CPPUNIT_ASSERT( ret == 0 ); + } + +private: + int pd[2]; + + int log_proto_server(int con, char *logline) { + } +}; + + +CPPUNIT_TEST_SUITE_REGISTRATION( ProducerTest ); + +int +main (int ac,const char *av[]) +{ + CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); + CppUnit::TextUi::TestRunner runner; + + runner.addTest(suite); + return runner.run() ? 0 : 1; +} -- 1.8.2.3