Add test running our wildfire sample code
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 5 Dec 2010 16:31:26 +0000 (17:31 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 5 Dec 2010 16:31:26 +0000 (17:31 +0100)
libcitadel/tests/Makefile.in
libcitadel/tests/run_tests.sh
libcitadel/tests/wildfire_test.c [new file with mode: 0644]

index 78570bf652f1a97cd789d496b2d4fce072b72b6b..32c7f1f48508115962e344978a8927e168d99e30 100644 (file)
@@ -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  $<
index d5f9ca21d0a0ea97ee3745dca3c83d10df150f45..2c9c1e21ab174c9cb59c8ba1f3479cb5f0caff8a 100755 (executable)
@@ -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 (file)
index 0000000..e77c263
--- /dev/null
@@ -0,0 +1,111 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+
+#include <fcntl.h>
+
+#include <unistd.h>
+#include <stddef.h>
+
+
+#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;
+}