COMPILE:=libtool --mode=compile ${CC} ${CFLAGS}
CXXCOMPILE:=libtool --mode=compile ${CXX} ${CXXFLAGS}
LINK:=libtool --mode=link ${CC} ${LDFLAGS}
-LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS}
+LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS}
INSTALL:=libtool --mode=install install
LIBOBJS:=connection.o consumer.o notification.o prod_proto.o \
producer.o uiwrap.o statistics.o
-# TODO: restructuring - do we really need FAKE versions? maybe remove all FAKEs here
-FAKELIBOBJS:=consumer_fake.o producer_fake.o
PLUSOBJS:=Event.o Job.o JobStatus.o Notification.o ServerConnection.o
HDRS:=consumer.h notification.h statistics.h prod_proto.h connection.h \
Job.h Notification.h ServerConnection.h
-FAKE_HDRS:=consumer_fake.h producer_fake.h
GEN_HDRS:=JobStatus.h producer.h
LIBTHROBJS:=${LIBOBJS:.o=.thr.o}
PLUSLOBJS:=${PLUSOBJS:.o=.lo}
PLUSTHRLOBJS:=${PLUSOBJS:.o=.thr.lo}
-FAKELIBTHROBJS:=${FAKELIBOBJS:.o=.thr.o}
-FAKELIBLOBJS:=${FAKELIBOBJS:.o=.lo}
-FAKELIBTHRLOBJS:=${FAKELIBOBJS:.o=.thr.lo}
-
LIB:=libglite_lb_client_${nothrflavour}.la
THRLIB:=libglite_lb_client_${thrflavour}.la
-FAKELIB:=libglite_lb_client_fake_${nothrflavour}.la
-FAKETHRLIB:=libglite_lb_client_fake_${thrflavour}.la
PLUSLIB:=libglite_lb_clientpp_${nothrflavour}.la
THRPLUSLIB:=libglite_lb_clientpp_${thrflavour}.la
EXAMPLES_CL_THR_SRC:=user_jobs_threaded.c
EXAMPLES_CL_THR:=${EXAMPLES_CL_THR_SRC:.c=}
-FAKE_EXAMPLES:=job_log_fake
-
MAN_GZ:=glite-lb-logevent.1.gz
MAN8_GZ:=glite-lb-dump.8.gz glite-lb-load.8.gz glite-lb-purge.8.gz
MAN = $(MAN_GZ:.gz=)
${COMMON_LIB_THR} ${TRIO_LIB} \
-lglite_security_gss_${thrflavour}
-${FAKELIB}: ${FAKELIBOBJS}
- ${LINK} ${version_info} -o $@ ${FAKELIBLOBJS} -rpath ${PREFIX}/lib \
- ${COMMON_LIB} \
- -lglite_security_gss_${nothrflavour}
-
-${FAKETHRLIB}: ${FAKELIBTHROBJS}
- ${LINK} ${version_info} -o $@ ${FAKELIBTHRLOBJS} -rpath ${PREFIX}/lib \
- ${COMMON_LIB_THR} \
- -lglite_security_gss_${thrflavour}
-
${PLUSLIB}: ${PLUSOBJS} ${LIB}
${LINKXX} ${version_info} -o $@ ${PLUSLOBJS} -rpath ${PREFIX}/lib ${LIB} ${PLUS_EXTRA_LIB}
${EXAMPLES_CL_THR}: %: %.o
${LINK} -o $@ $< ${THRLIB} ${COMMON_LIB_THR} ${EXT_LIB}
-${FAKE_EXAMPLES}: %: %.o ${FAKELIB}
- ${LINK} -o $@ $< ${FAKELIB} ${TEST_LIBS} ${EXT_LIB}
-
${TOOLS}: ${LIB}
-${FAKE_EXAMPLES:=.o}: %.o: %.cpp
- ${COMPILE} ${TEST_INC} -c $< -o $@
-
notify_supp.o ${PLUSOBJS}: %.o: %.cpp
${CXXCOMPILE} -c $<
${EXAMPLES_PLUS}: %: %.o
${LINKXX} -o $@ $< ${PLUSLIB}
-${LIBOBJS} ${FAKELIBOBJS}: %.o: %.c
+${LIBOBJS}: %.o: %.c
${COMPILE} -c $<
-${LIBTHROBJS} ${FAKELIBTHROBJS}: %.thr.o: %.c
+${LIBTHROBJS}: %.thr.o: %.c
${COMPILE} -o $@ -c $<
-logevent_fake.o: logevent.c
- ${COMPILE} -c $< -o $@
-
${MAN_GZ}: ${MAN}
rm -f ${MAN_GZ} ${MAN}
cp $? .
examples: ${EXAMPLES} ${EXAMPLES_PLUS} ${EXAMPLES_CL} ${EXAMPLES_CL_THR} ${sh_PROGS}
-fake: ${FAKE_EXAMPLES}
-
check: compile
# shut up check.producer
man: ${MAN_GZ} ${MAN8_GZ}
-# XXX is fake needed?
-# stage: compile ${FAKELIB} ${FAKETHRLIB}
stage: compile
$(MAKE) install PREFIX=${stagedir}
- ${INSTALL} -m 644 ${FAKELIB} ${FAKETHRLIB} ${stagedir}/lib
# TODO: restructuring - cleanup the documentation
doc: generate
${INSTALL} -m 644 ${LIB} ${THRLIB} ${PREFIX}/lib
endif
${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version}
- ${INSTALL} -m 644 ${top_srcdir}/doc/README-fake ${top_srcdir}/doc/README-notify ${PREFIX}/share/doc/${package}-${version}
+ ${INSTALL} -m 644 ${top_srcdir}/doc/README-notify ${PREFIX}/share/doc/${package}-${version}
(cd ${top_srcdir}/interface && ${INSTALL} -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix})
${INSTALL} -m 644 ${GEN_HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix}
ifndef LB_STANDALONE
${INSTALL} -m 644 ${MAN8_GZ} ${PREFIX}/share/man/man8
clean:
- rm -rvf *.o *.lo .libs lib* *.c *.cpp *.h *.dox producer_test C/ CPP/
+ rm -rvf *.o *.lo .libs lib* *.c *.cpp *.h *.dox producer_test notify C/ CPP/
rm -rvf ${LIB} ${THRLIB} ${TOOLS} logevent ${PLUSLIB} ${THRPLUSLIB} ${MAN_GZ} ${MAN8_GZ}
rm -rvf ${EXAMPLES} ${EXAMPLES_CL} ${EXAMPLES_CL_THR} ${sh_PROGS}
rm -vf ${globalprefix} ${lbprefix}
JobStatus.h: StatusAttrNames.pl
-.PHONY: default all compile examples fake check stage install clean check_version
+.PHONY: default all compile examples check stage install clean check_version
+++ /dev/null
-Fake library
-------------
-
-Fake library is a substitute library designed for usage in unit tests of
-programs which use L&B. The library implements a subset of L&B client API.
-Implemented functions are dummy in the sense that they do not produce any
-sideefect and they do not require any running services.
-
-Main purpose of the library is WMS unit testing, so it should contain all L&B
-function calls used in WMS.
-
-List of implemented functions:
-
- 1) consumer API
-
- edg_wll_QueryEvents
- edg_wll_QueryListener
- edg_wll_JobLog
- edg_wll_QuerySequenceCode
-
- 2) producer API
-
- edg_wll_Log* (functions for logging all event types)
- edg_wll_LogEvent
- edg_wll_LogEventSync
- edg_wll_LogEventProxy
- edg_wll_LogFlush
- edg_wll_LogFlushAll
- edg_wll_SetLoggingJob
- edg_wll_SetLoggingJobProxy
- edg_wll_RegisterJobSync
- edg_wll_RegisterJob
- edg_wll_RegisterSubjob
- edg_wll_RegisterSubjobs
- edg_wll_ChangeACL
-
-
-Function calls always try to return some meaningful data. However, for testing
-purposes a fine control on the returned value is usually required (e.g. to
-cover both success and failure of the called function). Therefore the library
-enables to set function error codes and/or adjust returned data. This is done
-via callbacks. Callbacks are activated right before function end when all
-pre-set data are available.
-
-Callbacks must be registered before using the library call. It is possible to
-have only one registered callback for each registration type at once (see
-below). Callback registration is global, it IS NOT thread safe. Otherwise
-the library is thread safe in the same way as standard L&B library --
-functions may be called by multiple threads simultaneously provided that
-more threads do not operate on a single L&B context at the same time.
-
-The following code fragments represent an example of unit test of a function
-calling e.g. edg_wll_LogMatch()
-
-#include "glite/lb/producer_fake.h"
-
-int fail_EAGAIN_callback(edg_wll_Context ctx)
-{
- return edg_wll_SetError(ctx,EAGAIN,"failure reason");
-}
-
-unit_test()
-{
- /* sucessfull logging, edg_wll_LogMatch() called from
- * tested_function() returns OK */
-
- tested_function();
- /* check results here */
-
- /* failing with EAGAIN */
- edg_wll_RegisterTestLogging(fail_EAGAIN_callback);
- tested_function();
- /* check results here */
-}
-
-The consumer API (QueryEvents, QueryListener) fake implementations
-prepare some result set which is returned to the caller. The callback
-function may also adjust this set for particular purposes of the unit test.
-
-List of the callbacks and registering functions:
-
- 1) cosumer API
-
- typedef int (edg_wll_QueryEvents_cb_f)
- (edg_wll_Context context, edg_wll_Event **events);
- typedef int (edg_wll_QueryListener_cb_f)
- (edg_wll_Context context, char **host, uint16_t *port);
-
- int edg_wll_RegisterTestQueryEvents(edg_wll_QueryEvents_cb_f *cb);
- int edg_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb);
-
- 2) producer API
-
- typedef int (edg_wll_Logging_cb_f)(edg_wll_Context context);
-
- int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb);
- int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb);
-
-
-It possible to unregister registered callbacks using following functions:
-
- void edg_wll_UnregisterTestQueryEvents();
- void edg_wll_UnregisterTestQueryListener();
- void edg_wll_UnregisterTestLogging();
- void edg_wll_UnregisterTestLoggingProxy();
-
-
-Library name is libglite_lb_client_fake_gcc32dbg[pthr].so. It is built
-in the org.glite.lb.client module, staged (so that it is available
-for WMS unit tests run during the build process) but currenlty
-neither installed nor included in RPM.
-
-Unit test programs should linked with this library instead of the original
-libglite_lb_client_gcc32dbg[pthr].so. You can find examples of fake library
-usage in org.glite.lb.client. The Makefile target 'fake' builds these examples.
-There is no ant equivalent, hence the following procedure is required:
-
- cd org.glite.lb.client
- ant init
- cd build
- make fake
-
-
-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.
+++ /dev/null
-/*
- * fake implementation of the consumer API
- */
-
-#include <stddef.h>
-#include <string.h>
-
-#include "glite/lb/consumer.h"
-#include "glite/lb/context-int.h"
-#include "consumer_fake.h"
-
-
-#define NUM_EVENTS 3
-
-
-static edg_wll_QueryEvents_cb_f *QueryEvents_cb = NULL;
-static edg_wll_QueryListener_cb_f *QueryListener_cb = NULL;
-
-
-/* register the query callback */
-int edg_wll_RegisterTestQueryEvents(edg_wll_QueryEvents_cb_f *cb) {
- if (QueryEvents_cb) return 0;
-
- QueryEvents_cb = cb;
- return 1;
-}
-
-
-/* register the listener callback */
-int edg_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb) {
- if (QueryListener_cb) return 0;
-
- QueryListener_cb = cb;
- return 1;
-}
-
-
-/* unregister the query callback */
-void edg_wll_UnregisterTestQueryEvents() {
- QueryEvents_cb = NULL;
-}
-
-
-/* unregister the listener callback */
-void edg_wll_UnregisterTestQueryListener() {
- QueryEvents_cb = NULL;
-}
-
-
-/* (belongs to common/src/events.c.T) */
-static void edg_wll_PrepareEvent(edg_wll_EventCode eventcode, edg_wll_Event *event) {
- edg_wll_Event *tmpevent;
-
- // hide not clean code here :-)
- tmpevent = edg_wll_InitEvent(eventcode);
- memcpy(event, tmpevent, sizeof(edg_wll_Event));
- free(tmpevent);
-}
-
-
-/* fake implementation of QueryEvents() */
-int edg_wll_QueryEvents(
- edg_wll_Context context,
- const edg_wll_QueryRec *job_conditions,
- const edg_wll_QueryRec *event_conditions,
- edg_wll_Event **events
-) {
- edg_wll_EventCode event_code;
- int i, j, err;
- edg_wlc_JobId jobid;
-
- edg_wll_ResetError(context);
-
- // 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)) i++;
- if (event_conditions[i].attr == EDG_WLL_QUERY_ATTR_UNDEF)
- event_code = EDG_WLL_EVENT_CHKPT;
- else
- event_code = event_conditions[i].value.i;
-
- // create events
- *events = calloc(NUM_EVENTS + 1, sizeof(edg_wll_Event));
- for (i = 0; i < NUM_EVENTS; i++) {
- edg_wll_PrepareEvent(event_code, &(*events)[i]);
- }
- (*events)[NUM_EVENTS].type = EDG_WLL_EVENT_UNDEF;
-
- // adjust events according to the query parameters
- i = 0;
- while (job_conditions[i].attr != EDG_WLL_QUERY_ATTR_UNDEF) {
- 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;
- }
- break;
- }
- i++;
- }
-
- // adjusting callback
- if (QueryEvents_cb)
- QueryEvents_cb(context, events);
-
- if ((err = edg_wll_Error(context, NULL, NULL)) == 0) return 0;
-
-error:
- i = 0;
- while ((*events)[i].type != EDG_WLL_EVENT_UNDEF) {
- edg_wll_FreeEvent(&(*events)[i]);
- i++;
- }
- free(*events);
-
- return edg_wll_SetError(context, err, NULL);
-}
-
-
-/* fake implementation of QueryListener() */
-int edg_wll_QueryListener(
- edg_wll_Context context,
- edg_wlc_JobId jobId,
- const char *name,
- char **host,
- uint16_t *port
-) {
- edg_wll_ResetError(context);
-
- if (QueryListener_cb) return QueryListener_cb(context, host, port);
- else {
- *host = strdup("localhost");
- *port = 12345;
-
- return edg_wll_Error(context, NULL, NULL);
- }
-}
-
-
-/* cut'nd pasted from consumer.c */
-int edg_wll_JobLog(
- edg_wll_Context ctx,
- edg_wlc_JobId job,
- edg_wll_Event **eventsOut)
-{
- edg_wll_QueryRec j[2], e[2];
-
- memset(j,0,sizeof j);
- memset(e,0,sizeof e);
-
- j[0].attr = EDG_WLL_QUERY_ATTR_JOBID;
- j[0].op = EDG_WLL_QUERY_OP_EQUAL;
- j[0].value.j = job;
-
- e[0].attr = EDG_WLL_QUERY_ATTR_LEVEL;
- e[0].op = EDG_WLL_QUERY_OP_LESS;
- e[0].value.i = ctx->p_level + 1;
-
- return edg_wll_QueryEvents(ctx,j,e,eventsOut);
-}
+++ /dev/null
-/*
- * fake implementation of the producer API
- */
-
-#include "glite/lb/producer.h"
-#include "glite/lb/context-int.h"
-#include "producer_fake.h"
-
-#define FAKE_VERSION 1
-
-#include "../src/producer.c"
-
-
-static edg_wll_Logging_cb_f *Logging_cb = NULL;
-static edg_wll_Logging_cb_f *LoggingProxy_cb = NULL;
-
-
-/* register the logging callback */
-int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb) {
- if (Logging_cb) return 0;
-
- Logging_cb = cb;
- return 1;
-}
-
-
-/* register the proxy logging callback */
-int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb) {
- if (LoggingProxy_cb) return 0;
-
- LoggingProxy_cb = cb;
- return 1;
-}
-
-
-/* unregister the logging callback */
-void edg_wll_UnregisterTestLogging() {
- Logging_cb = NULL;
-}
-
-
-/* unregister the proxy logging callback */
-void edg_wll_UnregisterTestLoggingProxy() {
- LoggingProxy_cb = NULL;
-}
-
-
-/* "fake" implementation of function sending formated UML string */
-int edg_wll_DoLogEvent(edg_wll_Context context, edg_wll_LogLine logLine) {
- if (Logging_cb)
- return Logging_cb(context);
- else
- return edg_wll_Error(context, NULL, NULL);
-}
-
-
-/* "fake" implementation of function sending formated ULM string */
-int edg_wll_DoLogEventProxy(edg_wll_Context context, edg_wll_LogLine logline) {
- if (Logging_cb)
- return Logging_cb(context);
- else
- return edg_wll_Error(context, NULL, NULL);
-}
+++ /dev/null
-#ifndef GLITE_LB_CONSUMER_FAKE_H
-#define GLITE_LB_CONSUMER_FAKE_H
-
-/*
- * fake implementation of the consumer API
- */
-
-#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);
-typedef int (edg_wll_QueryListener_cb_f)(edg_wll_Context context, char **host, uint16_t *port);
-
-int edg_wll_RegisterTestQueryEvents(edg_wll_QueryEvents_cb_f *cb);
-int edg_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb);
-void edg_wll_UnregisterTestQueryEvents();
-void edg_wll_UnregisterTestQueryListener();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GLITE_LB_CONSUMER_FAKE_H */
+++ /dev/null
-#ifndef GLITE_LB_PRODUCER_FAKE_H
-#define GLITE_LB_PRODUCER_FAKE_H
-
-/*
- * fake implementation of the producer API
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "glite/lb/context.h"
-
-typedef int (edg_wll_Logging_cb_f)(edg_wll_Context context);
-
-int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb);
-int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb);
-void edg_wll_UnregisterTestLogging();
-void edg_wll_UnregisterTestLoggingProxy();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GLITE_LB_PRODUCER_FAKE_H */