From a867831b3a394b805eefad19c3867f5ff15e68f4 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Wed, 21 Oct 2015 07:56:45 +0200 Subject: [PATCH] Makefile for testers and fix test_handlers.c --- testers/Makefile | 33 +++++++++++++++++++++++++++++++++ testers/test_handler.c | 22 ++++++++++++---------- 2 files changed, 45 insertions(+), 10 deletions(-) create mode 100755 testers/Makefile diff --git a/testers/Makefile b/testers/Makefile new file mode 100755 index 0000000..a0975ca --- /dev/null +++ b/testers/Makefile @@ -0,0 +1,33 @@ +TRLIBS = -ltrbase \ + -ltrhashing \ + -ltrio \ + -ltrdata \ + -ltrevent \ + -ltrcomm + +LIBS = $(TRLIBS) \ + -lcrypto \ + -lssl \ + -lrt \ + -luuid + +PROHRAMS = testserver2 \ + testtcp \ + testudp + +all: $(PROHRAMS) + +testserver2: testserver2.o test_handler.o + $(CC) $(LDFLAGS) -std=c99 $(LIBS) -o $@ $< test_handler.o + +testtcp: testclient.o + $(CC) $(LDFLAGS) -std=c99 $(LIBS) -o $@ $< + +testudp: testudp.o + $(CC) $(LDFLAGS) -std=c99 $(LIBS) -o $@ $< + +testudp.o: testclient.c + $(CC) $(CFLAGS) -DUDP=1 -std=c99 -c -o $@ $< + +%.o: %.c + $(CC) $(CFLAGS) -std=c99 -c -o $@ $< diff --git a/testers/test_handler.c b/testers/test_handler.c index 1d6a163..0e65ee4 100644 --- a/testers/test_handler.c +++ b/testers/test_handler.c @@ -9,8 +9,9 @@ static TR_EventDone -testHandlerHeartbeat(TR_EventHandler this, TR_Event event) -{ +testHandlerHeartbeat(void * _this, TR_Event event) +{ + TR_EventHandler this = _this; double size = (double)((TestHandler)this)->size; double size_msg = ((TestHandler)this)->size ? size / ((TestHandler)this)->handled @@ -35,12 +36,13 @@ testHandlerHeartbeat(TR_EventHandler this, TR_Event event) ((TestHandler)this)->size = 0; return TR_EVENT_DONE; -} +} static TR_EventDone -testHandlerNewMessage(TR_EventHandler this, TR_Event event) -{ +testHandlerNewMessage(void * _this, TR_Event event) +{ + TR_EventHandler this = _this; TR_Event _event; TR_ProtoMessageRaw message = event->data; @@ -55,16 +57,16 @@ testHandlerNewMessage(TR_EventHandler this, TR_Event event) TR_eventHandlerIssueEvent((TR_EventHandler)this, _event); return TR_EVENT_DONE; -} +} static TR_EventDone -testHandlerClose(TR_EventHandler this, TR_Event event) -{ +testHandlerClose(void * _this, TR_Event event) +{ // puts("close"); return TR_EVENT_PENDING; -} +} #if 0 static @@ -89,7 +91,7 @@ testHandlerCtor(void * _this, va_list * params) static void -testHandlerDtor(void * _this, va_list * params) +testHandlerDtor(void * _this) { TR_PARENTCALL(TestHandler, _this, TR_Class, dtor); }