From d5a9994ae97dd98e976069e4711b4428df9a0166 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 5 Dec 2010 17:31:26 +0100 Subject: [PATCH] Add test running our wildfire sample code --- libcitadel/tests/Makefile.in | 8 ++- libcitadel/tests/run_tests.sh | 27 ++++---- libcitadel/tests/wildfire_test.c | 111 +++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 libcitadel/tests/wildfire_test.c diff --git a/libcitadel/tests/Makefile.in b/libcitadel/tests/Makefile.in index 78570bf65..32c7f1f48 100644 --- a/libcitadel/tests/Makefile.in +++ b/libcitadel/tests/Makefile.in @@ -14,7 +14,7 @@ top_builddir=`pwd` # End of configuration section -TARGETS=stringbuf_test stringbuf_IO_test stringbuf_conversion_test hashlist_test mimeparser_test mime_xdg_lookup_test +TARGETS=stringbuf_test stringbuf_IO_test stringbuf_conversion_test hashlist_test mimeparser_test mime_xdg_lookup_test wildfire_test all: $(TARGETS) @@ -66,6 +66,12 @@ mime_xdg_lookup_test: $(LIBOBJS) mime_xdg_lookup_type.o -o mime_xdg_lookup_test +wildfire_test: $(LIBOBJS) wildfire_test.o + $(CC) $(LDFLAGS) $(LIBOBJS) $(LIBS) \ + wildfire_test.o \ + ../.libs/libcitadel.a \ + -o wildfire_test + .c.o: $(CC) $(CFLAGS) $(DEFS) -c $< diff --git a/libcitadel/tests/run_tests.sh b/libcitadel/tests/run_tests.sh index d5f9ca21d..2c9c1e21a 100755 --- a/libcitadel/tests/run_tests.sh +++ b/libcitadel/tests/run_tests.sh @@ -24,14 +24,26 @@ RUN_TEST= #./stringbuf_IO_test -p 6666 -i 0.0.0.0 -s2 -n14 & #cat posttest.txt |nc 127.0.0.1 6666 +echo running wildfire tests +$RUN_TEST ./wildfire_test +echo running XDG-mimetype lookup tests + +for i in ../../webcit/static/bgcolor.gif ../../webcit/static/resizecorner.png ../../webcit/static/roomops.js ./mimeparser_test.c; do + $RUN_TEST ./mime_xdg_lookup_test -f $i -x -i /usr/share/icons/gnome/24x24/mimetypes + $RUN_TEST ./mime_xdg_lookup_test -f $i -i /usr/share/icons/gnome/24x24/mimetypes +done + +for i in test.txt test.css test.htc test.jpg test.png test.ico test.vcf test.html test.htm test.wml test.wmls test.wmlc test.wmlsc test.wbmp test.blarg a.1 a; do + $RUN_TEST ./mime_xdg_lookup_test -f $i -x -i /usr/share/icons/gnome/24x24/mimetypes +done echo running hashlist test $RUN_TEST ./hashlist_test echo running strbuf conversion tests -./stringbuf_conversion_test -cat testdata/emailaddresses/email_recipientstrings.txt |$RUN_TEST stringbuf_conversion_test -i +$RUN_TEST ./stringbuf_conversion_test +cat testdata/emailaddresses/email_recipientstrings.txt |$RUN_TEST ./stringbuf_conversion_test -i echo running general stringbuffer tests $RUN_TEST ./stringbuf_test @@ -40,6 +52,7 @@ $RUN_TEST ./stringbuf_test echo running mimeparser tests for i in testdata/mime/*; do + $RUN_TEST ./mimeparser_test -f $i $RUN_TEST ./mimeparser_test -p -f $i $RUN_TEST ./mimeparser_test -p -d -f $i for j in `./mimeparser_test -p -d -f $i |grep part=|sed "s;part=.*|.*|\([0-9\.]*\)|.*|.*|.*|.*|;\1;"`; do @@ -47,14 +60,4 @@ for i in testdata/mime/*; do done done -echo running XDG-mimetype lookup tests - -for i in ../../webcit/static/bgcolor.gif ../../webcit/static/resizecorner.png ../../webcit/static/roomops.js ./mimeparser_test.c; do - $RUN_TEST ./mime_xdg_lookup_test -f $i -x -i /usr/share/icons/gnome/24x24/mimetypes - $RUN_TEST ./mime_xdg_lookup_test -f $i -i /usr/share/icons/gnome/24x24/mimetypes -done - -for i in test.txt test.css test.htc test.jpg test.png test.ico test.vcf test.html test.htm test.wml test.wmls test.wmlc test.wmlsc test.wbmp test.blarg a.1 a; do - $RUN_TEST ./mime_xdg_lookup_test -f $i -x -i /usr/share/icons/gnome/24x24/mimetypes -done diff --git a/libcitadel/tests/wildfire_test.c b/libcitadel/tests/wildfire_test.c new file mode 100644 index 000000000..e77c263b0 --- /dev/null +++ b/libcitadel/tests/wildfire_test.c @@ -0,0 +1,111 @@ +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + + +#include "../lib/libcitadel.h" + +static void CreateWildfireSampleMessage(StrBuf *OutBuf) +{ + JsonValue *Error; + + StrBuf *Buf; + StrBuf *Header; + StrBuf *Json; + int n = 1; + + Header = NewStrBuf(); + Json = NewStrBuf(); + + Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO); + SerializeJson(Json, Error, 1); + WildFireSerializePayload(Json, Header, &n, NULL); + StrBufAppendBuf(OutBuf, Header, 0); + FlushStrBuf(Json); + FlushStrBuf(Header); + + Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Warn message"), eWARN); + SerializeJson(Json, Error, 1); + WildFireSerializePayload(Json, Header, &n, NULL); + StrBufAppendBuf(OutBuf, Header, 0); + FlushStrBuf(Json); + FlushStrBuf(Header); + + Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Error message"), eERROR); + SerializeJson(Json, Error, 1); + WildFireSerializePayload(Json, Header, &n, NULL); + StrBufAppendBuf(OutBuf, Header, 0); + FlushStrBuf(Json); + FlushStrBuf(Header); + + Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO); + SerializeJson(Json, Error, 1); + WildFireSerializePayload(Json, Header, &n, NULL); + StrBufAppendBuf(OutBuf, Header, 0); + FlushStrBuf(Json); + FlushStrBuf(Header); + + Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO); + SerializeJson(Json, Error, 1); + WildFireSerializePayload(Json, Header, &n, NULL); + StrBufAppendBuf(OutBuf, Header, 0); + FlushStrBuf(Json); + FlushStrBuf(Header); + + + Buf = NewStrBufPlain(HKEY("test error message")); + Error = WildFireException(HKEY(__FILE__), __LINE__, Buf, 1); + SerializeJson(Json, Error, 1); + WildFireSerializePayload(Json, Header, &n, NULL); + StrBufAppendBuf(OutBuf, Header, 0); + + FlushStrBuf(Json); + FlushStrBuf(Header); + +} + +int main(int argc, char* argv[]) +{ + StrBuf *WFBuf; + StrBuf *OutBuf; + StrBuf *Info; + int nWildfireHeaders; + + StartLibCitadel(8); + printf("%s == %d?\n", libcitadel_version_string(), libcitadel_version_number()); + + + WildFireInitBacktrace(argv[0], 0); + + WFBuf = NewStrBuf(); + OutBuf = NewStrBuf(); + Info = NewStrBufPlain(HKEY("this is just a test message")); + SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); + SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); + SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); + SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); + SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); + SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); + SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); + + WildFireSerializePayload(WFBuf, OutBuf, &nWildfireHeaders, NULL); + + CreateWildfireSampleMessage(OutBuf); + printf("%s\n\n", ChrPtr(OutBuf)); + + FreeStrBuf(&WFBuf); + FreeStrBuf(&OutBuf); + FreeStrBuf(&Info); + ShutDownLibCitadel(); + return 0; +} -- 2.39.2