First attempt to producer test
authorJan Pospíšil <honik@ntc.zcu.cz>
Tue, 31 Aug 2004 16:32:31 +0000 (16:32 +0000)
committerJan Pospíšil <honik@ntc.zcu.cz>
Tue, 31 Aug 2004 16:32:31 +0000 (16:32 +0000)
org.glite.lb.client/Makefile
org.glite.lb.client/project/configure.properties.xml
org.glite.lb.client/test/prod_proto_test.c [new file with mode: 0644]
org.glite.lb.client/test/producer_test.cpp [new file with mode: 0644]

index ae3cc23..ab7d686 100644 (file)
@@ -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
index 1005c5c..17c4c40 100644 (file)
@@ -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}
                        </echo>
            </target>
        </project>
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 (file)
index 0000000..e0214fe
--- /dev/null
@@ -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 (file)
index 0000000..b717b85
--- /dev/null
@@ -0,0 +1,60 @@
+#include <iostream>
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <errno.h>
+#include <assert.h>
+#include <string.h>
+
+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;
+}