From 17d7f58185ca915f55eca1b13e72113c0e1a2598 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 9 Dec 2004 14:04:06 +0000 Subject: [PATCH] Replaced puzzling fake examples by unit test fake example. Updated documentation. Added C++isms to fake library header files. --- org.glite.lb.client-interface/interface/consumer_fake.h | 8 ++++++++ org.glite.lb.client-interface/interface/producer_fake.h | 8 ++++++++ org.glite.lb.client/Makefile | 16 ++++++---------- org.glite.lb.client/doc/README-fake | 12 +++--------- org.glite.lb.client/examples/consumer_fake.c | 8 +++++--- 5 files changed, 30 insertions(+), 22 deletions(-) diff --git a/org.glite.lb.client-interface/interface/consumer_fake.h b/org.glite.lb.client-interface/interface/consumer_fake.h index 50105f3..c3fc28f 100644 --- a/org.glite.lb.client-interface/interface/consumer_fake.h +++ b/org.glite.lb.client-interface/interface/consumer_fake.h @@ -5,6 +5,10 @@ #ifndef WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H #define WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H +#ifdef __cplusplus +extern "C" { +#endif + #include "glite/lb/context-int.h" typedef int (edg_wll_QueryEvents_cb_f)(edg_wll_Context context, edg_wll_Event **events); @@ -15,4 +19,8 @@ int edg_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb); void edg_wll_UnregisterTestQueryEvents(); void edg_wll_UnregisterTestQueryListener(); +#ifdef __cplusplus +} +#endif + #endif /* WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H */ diff --git a/org.glite.lb.client-interface/interface/producer_fake.h b/org.glite.lb.client-interface/interface/producer_fake.h index f5dfcff..69ce184 100644 --- a/org.glite.lb.client-interface/interface/producer_fake.h +++ b/org.glite.lb.client-interface/interface/producer_fake.h @@ -5,6 +5,10 @@ #ifndef WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H #define WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H +#ifdef __cplusplus +extern "C" { +#endif + typedef int (edg_wll_Logging_cb_f)(edg_wll_Context context); int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb); @@ -12,4 +16,8 @@ int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb); void edg_wll_UnregisterTestLogging(); void edg_wll_UnregisterTestLoggingProxy(); +#ifdef __cplusplus +} +#endif + #endif /* WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H */ diff --git a/org.glite.lb.client/Makefile b/org.glite.lb.client/Makefile index de7c305..6fd7a20 100644 --- a/org.glite.lb.client/Makefile +++ b/org.glite.lb.client/Makefile @@ -135,9 +135,8 @@ PLUSLIB:=libglite_lb_clientpp_${nothrflavour}.la THRPLUSLIB:=libglite_lb_clientpp_${thrflavour}.la TOOLS:=dump load purge -EXAMPLES:=log_usertag_proxy job_reg feed_shark notify query_ext query_seq_code -FAKE_EXAMPLES:=job_log_fake job_reg_fake logevent_fake -FAKE_EXAMPLES_SOURCES:=job_log.c job_reg.c +EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code +FAKE_EXAMPLES:=job_log_fake version_info=-version-info `echo ${version} | cut -d. -f1,2 | tr . :` @@ -162,19 +161,16 @@ ${THRPLUSLIB}: ${PLUSTHROBJS} logevent: logevent.o args.o ${LINK} -o $@ logevent.o args.o ${LIB} ${EXT_LIB} ${GLOBUS_LIBS} -logevent_fake: logevent_fake.o args.o - ${LINK} -o $@ logevent_fake.o args.o ${FAKELIB} ${EXT_LIB} ${GLOBUS_LIBS} - ${TOOLS} ${EXAMPLES}: %: %.o ${LINK} -o $@ $< ${LIB} ${EXT_LIB} ${GLOBUS_LIBS} -${FAKE_EXAMPLES_SOURCES:.c=_fake}: %: %.o ${FAKELIB} - ${LINK} -o $@ $< ${FAKELIB} ${EXT_LIB} ${GLOBUS_LIBS} +${FAKE_EXAMPLES}: %: %.o ${FAKELIB} + ${LINK} -o $@ $< ${FAKELIB} ${TEST_LIBS} ${EXT_LIB} ${GLOBUS_LIBS} ${TOOLS}: ${LIB} -${FAKE_EXAMPLES_SOURCES:.c=_fake.o}: %_fake.o: %.c - ${COMPILE} ${GLOBUSINC} -DUSE_CALLBACKS -c $< -o $@ +${FAKE_EXAMPLES:=.o}: %.o: %.cpp + ${COMPILE} ${GLOBUSINC} ${TEST_INC} -c $< -o $@ ${PLUSOBJS}: %.o: %.cpp ${CXXCOMPILE} ${GLOBUSINC} -c $< diff --git a/org.glite.lb.client/doc/README-fake b/org.glite.lb.client/doc/README-fake index e2593ae..5a751ba 100644 --- a/org.glite.lb.client/doc/README-fake +++ b/org.glite.lb.client/doc/README-fake @@ -121,12 +121,6 @@ There is no ant equivalent, hence the following procedure is required: make fake -* TODO (MATOUCI): v examples/ musi byt jednak priklady, ktere se linkuji s normalni -* knihovnou a funguji plnohodnotne dle ocekavani, a navic neco jako -* fake_job_log, ktery bude prikladem unittestu (opravdu s pouzitim cppUnitu -* atd.) nejake funkce z jinak opravdoveho job_log (asi bude treba ji -* pro tyto ucely vytahnout z main()u). - -In the example examples/job_log.c is showed how to use callbacks and their -registration. Examples examples/job_reg.c and src/logevent.c are original L&B -examples which are just linked with the fake library too. +An example of unit test using the fake library is the file +examples/job_log_fake.cpp. There is showed how to use callbacks and their +registration. diff --git a/org.glite.lb.client/examples/consumer_fake.c b/org.glite.lb.client/examples/consumer_fake.c index 1eaeb45..060d55d 100644 --- a/org.glite.lb.client/examples/consumer_fake.c +++ b/org.glite.lb.client/examples/consumer_fake.c @@ -71,9 +71,11 @@ int edg_wll_QueryEvents( edg_wll_ResetError(context); - // get asked event type or use _EVENT_CHKPT + // determine type of the returned events, ignore _QUERY_OP_*: + // - asked event type for _QUERY_ATTR_EVENT_TYPE + // - _EVENT_CHKPT for other i = 0; - while (event_conditions[i].attr != EDG_WLL_QUERY_ATTR_UNDEF && (event_conditions[i].attr != EDG_WLL_QUERY_ATTR_EVENT_TYPE || event_conditions[i].op != EDG_WLL_QUERY_OP_EQUAL)) i++; + while (event_conditions[i].attr != EDG_WLL_QUERY_ATTR_UNDEF && (event_conditions[i].attr != EDG_WLL_QUERY_ATTR_EVENT_TYPE)) i++; if (event_conditions[i].attr == EDG_WLL_QUERY_ATTR_UNDEF) event_code = EDG_WLL_EVENT_CHKPT; else @@ -92,7 +94,7 @@ int edg_wll_QueryEvents( if (job_conditions[i].attr == EDG_WLL_QUERY_ATTR_JOBID && job_conditions[i].op == EDG_WLL_QUERY_OP_EQUAL) { jobid = job_conditions[i].value.j; for (j = 0; j < NUM_EVENTS; j++) { - if ((err = edg_wlc_JobIdDup(jobid, &(*events)[i].any.jobId)) != 0) goto error; + if ((err = edg_wlc_JobIdDup(jobid, &(*events)[i].any.jobId)) != 0) goto error; } break; } -- 1.8.2.3