From 58eeff0e2b240e0ae6cb111e71f9365d7aec44de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Wed, 8 Sep 2004 13:38:03 +0000 Subject: [PATCH] query event unit test (not complete yet) --- org.glite.lb.server/Makefile | 24 +++++- .../project/configure.properties.xml | 4 + org.glite.lb.server/src/get_events.h | 8 ++ org.glite.lb.server/test/test_query_events.cpp | 86 ++++++++++++++++++++++ 4 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 org.glite.lb.server/test/test_query_events.cpp diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index 23e6061..98abe3c 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -21,9 +21,12 @@ ares_prefix=/opt/ares YACC=bison -y -VPATH=${top_srcdir}/src +VPATH=${top_srcdir}/src:${top_srcdir}/test AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 +TEST_LIBS:=-L${cppunit}/lib -lcppunit +TEST_INC:=-I${cppunit}/include + SUFFIXES = .T DEBUG:=-g -O0 @@ -41,6 +44,7 @@ CFLAGS:= -DNO_VOMS -DNO_GACL \ -I${globus_prefix}/include/${nothrflavour} LINK:=libtool --mode=link ${CC} ${LDFLAGS} +LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} INSTALL:=libtool --mode=install install # assisst & gss due to VOMS only @@ -86,8 +90,17 @@ default all: compile compile: glite_lb_bkserverd glite_lb_bkindex -check: - echo No unit tests so far. +check: + -echo check.query not complete yet + +check.query: test_query_events + ./test_query_events + +query_events_objs:=`echo ${SERVER_OBJS} | sed 's/lbs_db\.o//;s/bkserverd\.o//'` + +test_query_events: test_query_events.o + ${LINKXX} -o $@ test_query_events.o ${query_events_objs} \ + ${TEST_LIBS} ${COMMON_LIB} ${EXT_LIBS} doc: @@ -132,3 +145,8 @@ clean: mv y.tab.h $*.h ${CC} -c ${CFLAGS} $*.c rm $*.c + + +test_query_events.o: %.o: %.cpp + ${CXX} -c ${CFLAGS} ${GLOBUSINC} ${TEST_INC} $< + diff --git a/org.glite.lb.server/project/configure.properties.xml b/org.glite.lb.server/project/configure.properties.xml index a1fbfdb..66ea055 100644 --- a/org.glite.lb.server/project/configure.properties.xml +++ b/org.glite.lb.server/project/configure.properties.xml @@ -20,6 +20,9 @@ Revision history: $Log$ + Revision 1.1 2004/07/07 12:08:09 akrenek + *** empty log message *** + Revision 1.2 2004/07/06 20:47:11 flammer Moved to configure.properties.xml @@ -52,6 +55,7 @@ nothrflavour=${with.globus.nothr.flavor} expat_prefix=${with.expat.prefix} ares_prefix=${with.ares.prefix} mysql_prefix=${with.mysql.prefix} +cppunit=${with.cppunit.prefix} diff --git a/org.glite.lb.server/src/get_events.h b/org.glite.lb.server/src/get_events.h index 590b61e..cfa07c1 100644 --- a/org.glite.lb.server/src/get_events.h +++ b/org.glite.lb.server/src/get_events.h @@ -3,6 +3,10 @@ /* Internal functions for getting event sets from the LB database */ #include "lbs_db.h" +#ifdef __cplusplus +extern "C" { +#endif + #if 0 /* rel 1 */ char *edg_wll_jobid_to_user( edg_wll_Context, char *); void edg_wll_set_event_field_warn( edg_wll_Event *, char *, char *); @@ -22,3 +26,7 @@ int edg_wll_QueryJobsServer(edg_wll_Context, const edg_wll_QueryRec **, int, edg void edg_wll_SortEvents(edg_wll_Event *); int edg_wll_compare_seq(const char *, const char *); +#ifdef __cplusplus +} +#endif + diff --git a/org.glite.lb.server/test/test_query_events.cpp b/org.glite.lb.server/test/test_query_events.cpp new file mode 100644 index 0000000..00fb6e8 --- /dev/null +++ b/org.glite.lb.server/test/test_query_events.cpp @@ -0,0 +1,86 @@ +#include + +#include +#include +#include +#include + +#include +#include + +#include "lbs_db.h" +#include "get_events.h" + +using namespace std; + +class QueryEventsTest: public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(QueryEventsTest); + CPPUNIT_TEST(oneJob); + CPPUNIT_TEST_SUITE_END(); + +private: + edg_wll_Context ctx; + +public: + void oneJob(); + + void setUp() { + edg_wll_InitContext(&ctx); + ctx->mysql = (void *) this; /* XXX */ + } + +}; + +void QueryEventsTest::oneJob() +{ + edg_wll_QueryRec job[2]; + const edg_wll_QueryRec *jobs[2] = { job,NULL} ; + edg_wll_Event *events; + + job[0].attr = EDG_WLL_QUERY_ATTR_JOBID; + job[0].op = EDG_WLL_QUERY_OP_EQUAL ; + edg_wlc_JobIdParse("https://fake.server/fake_job",&job[0].value.j); + job[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + + CPPUNIT_ASSERT(!edg_wll_QueryEventsServer(ctx,1,jobs,NULL,&events)); +} + +extern "C" { + +int edg_wll_ExecStmt(edg_wll_Context ctx,char *qry,edg_wll_Stmt *stmt) +{ + cout << qry << endl; + return 0; +} + +int edg_wll_FetchRow(edg_wll_Stmt stmt, char **cols) +{ + return 0; +} + +void edg_wll_FreeStmt(edg_wll_Stmt *) {} + +int debug; + +int edg_wll_QueryColumns(edg_wll_Stmt stmt, char**cols) {} +char *edg_wll_TimeToDB(long t) {} + +time_t edg_wll_DBToTime(char *c) {} +edg_wll_ErrorCode edg_wll_DBConnect(edg_wll_Context ctx, char*str) {} + + + + +} + +CPPUNIT_TEST_SUITE_REGISTRATION(QueryEventsTest); + +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