diff --git a/Makefile.am b/Makefile.am index e12d51a0..4a2922f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -507,6 +507,9 @@ noinst_PROGRAMS += \ examples/nmsg-packet2pcap \ examples/print_version + +AM_TESTS_ENVIRONMENT = export USE_JSON="$(use_json_c)"; + TESTS += tests/group-operator-source-tests/test.sh TESTS += tests/json-utf8-tests/test.sh TESTS += tests/nmsg-dns-tests/test.sh diff --git a/configure.ac b/configure.ac index 950ea322..67e1dc0a 100644 --- a/configure.ac +++ b/configure.ac @@ -35,6 +35,9 @@ AC_SUBST(NMSG_PATCHLEVEL_VERSION) AC_SUBST(NMSG_VERSION) AC_SUBST(NMSG_VERSION_NUMBER) +use_json_c=$(test "x$with_json_c" != "xno" && echo "true" || echo "false") +AC_SUBST(use_json_c) + AC_PROG_LN_S AC_CONFIG_FILES([Makefile doc/doxygen/Doxyfile nmsg/libnmsg.pc nmsg/version.h]) diff --git a/src/io.c b/src/io.c index 2b11cc45..febc648c 100644 --- a/src/io.c +++ b/src/io.c @@ -351,7 +351,6 @@ add_kafka_input(nmsgtool_ctx *c, const char *str_address) { _add_kafka_nmsg_input(c, addr); return; } -#ifdef HAVE_JSON_C addr = _strip_prefix_if_exists(str_address, "json:"); if (addr != NULL) { _add_kafka_json_input(c, addr); @@ -359,11 +358,6 @@ add_kafka_input(nmsgtool_ctx *c, const char *str_address) { } fprintf(stderr, "%s: Error: nmsg or json protocol must be set for Kafka topic\n", argv_program); -#else /* HAVE_JSON_C */ - fprintf(stderr, "%s: Error: nmsg protocol must be set for Kafka topic\n", - argv_program); -#endif /* HAVE_JSON_C */ - exit(EXIT_FAILURE); } void @@ -373,7 +367,6 @@ add_kafka_output(nmsgtool_ctx *c, const char *str_address) { _add_kafka_nmsg_output(c, addr); return; } -#ifdef HAVE_JSON_C addr = _strip_prefix_if_exists(str_address, "json:"); if (addr != NULL) { _add_kafka_json_output(c, addr); @@ -381,11 +374,6 @@ add_kafka_output(nmsgtool_ctx *c, const char *str_address) { } fprintf(stderr, "%s: Error: nmsg or json protocol must be set for Kafka topic\n", argv_program); -#else /* HAVE_JSON_C */ - fprintf(stderr, "%s: Error: nmsg protocol must be set for Kafka topic\n", - argv_program); -#endif /* HAVE_JSON_C */ - exit(EXIT_FAILURE); } #ifdef HAVE_LIBZMQ diff --git a/tests/group-operator-source-tests/test.sh.in b/tests/group-operator-source-tests/test.sh.in index 2a3fcc95..d8909414 100755 --- a/tests/group-operator-source-tests/test.sh.in +++ b/tests/group-operator-source-tests/test.sh.in @@ -11,6 +11,8 @@ check() { fi } +USE_JSON="@use_json_c@" + NMSG_MSGMOD_DIR="@abs_top_builddir@/nmsg/base/.libs" export NMSG_MSGMOD_DIR NMSGTOOL="@abs_top_builddir@/src/nmsgtool" @@ -26,6 +28,7 @@ rm -f ${OUTPUT}/test*out echo Testing no source results in no source ... +if [ "$USE_JSON" = "true" ]; then echo "$JSON_PAYLOAD" | $NMSGTOOL -j - > ${OUTPUT}/test-no-source.pres.out check read json base:http and create base:http presentation output head -1 ${OUTPUT}/test-no-source.pres.out | grep '\[1:4 base http\] \[00000000\] \[\] \[\] $' >/dev/null @@ -321,7 +324,95 @@ echo "$JSON_PAYLOAD" | $NMSGTOOL -j - --setgroup 4321 -J ${OUTPUT}/test-setgroup check read json base:http and create base:http json output egrep ',"group":4321,' ${OUTPUT}/test-setgroup-not-aliases.json.out >/dev/null check numeric group in json - +else +: ; check read json base:http and create base:http presentation output +: ; check no source results in 00000000 in presentation +: ; check read json base:http and create base:http json output +: ; check no source in json +: ; check read json base:http and create base:http presentation output +: ; check empty source results in 00000000 in presentation +: ; check read json base:http and create base:http json output +: ; check no source in json +: ; check read json base:http and create base:http presentation output +: ; check source presentation +: ; check read json base:http and create base:http json output +: ; check source in json +: ; check read json base:http and create base:http presentation output +: ; check previous source not in presentation +: ; check new source in presentation +: ; check read json base:http and create base:http json output +: ; check previous source not in json +: ; check new source in json +: ; check read json base:http and create base:http presentation output +: ; check no numerical operator and group in presentation +: ; check read json base:http and create base:http json output +: ; check no operator field in json +: ; check no group field in json +: ; check read json base:http and create base:http presentation output +: ; check numerical operator in presentation +: ; check read json base:http and create base:http json output +: ; check numerical operator in json +: ; check read json base:http and create base:http presentation output +: ; check numerical group in presentation +: ; check read json base:http and create base:http json output +: ; check numerical group in json +: ; check read json base:http and create base:http presentation output +: ; check no operator in presentation +: ; check read json base:http and create base:http json output +: ; check no operator in json +: ; check read json base:http and create base:http presentation output +: ; check no group in presentation +: ; check read json base:http and create base:http json output +: ; check no group in json +: ; check read json base:http and create base:http presentation output +: ; check named operator in presentation +: ; check read json base:http and create base:http json output +: ; check named operator in json +: ; check read json base:http and create base:http presentation output +: ; check named group in presentation +: ; check read json base:http and create base:http json output +: ; check named group in json +: ; check read json base:http and create base:http presentation output +: ; check named operator in presentation +: ; check read json base:http and create base:http json output +: ; check named operator in json +: ; check read json base:http and create base:http presentation output +: ; check named group in presentation +: ; check read json base:http and create base:http json output +: ; check named group in json +: ; check read json base:http and create base:http presentation output +: ; check no operator in presentation +: ; check read json base:http and create base:http json output +: ; check no operator in json +: ; check read json base:http and create base:http presentation output +: ; check no group in presentation +: ; check read json base:http and create base:http json output +: ; check no group in json +: ; check read json base:http and create base:http presentation output +: ; check named operator in presentation +: ; check read json base:http and create base:http json output +: ; check named operator in json +: ; check read json base:http and create base:http presentation output +: ; check named group in presentation +: ; check read json base:http and create base:http json output +: ; check named group in json +: ; check read json base:http and create base:http presentation output +: ; check named operator in presentation +: ; check read json base:http and create base:http json output +: ; check named operator in json +: ; check read json base:http and create base:http presentation output +: ; check named group in presentation +: ; check read json base:http and create base:http json output +: ; check named group in json +: ; check read json base:http and create base:http presentation output +: ; check numeric operator in presentation +: ; check read json base:http and create base:http json output +: ; check numeric operator in json +: ; check read json base:http and create base:http presentation output +: ; check numeric group in presentation +: ; check read json base:http and create base:http json output +: ; check numeric group in json +fi # TODO: test no source # test with broken aliases file diff --git a/tests/nmsg-dns-tests/test.sh.in b/tests/nmsg-dns-tests/test.sh.in index 24f76f77..224f3b45 100755 --- a/tests/nmsg-dns-tests/test.sh.in +++ b/tests/nmsg-dns-tests/test.sh.in @@ -18,6 +18,8 @@ NMSGTOOL="@abs_top_builddir@/src/nmsgtool" SOURCE=@abs_top_srcdir@/tests/nmsg-dns-tests/test1-dns OUTPUT=@abs_top_builddir@/tests/nmsg-dns-tests/test1-dns +USE_JSON="@use_json_c@" + # cleanup from previous run rm -f ${OUTPUT}*out @@ -37,22 +39,36 @@ check read nmsg base:dns and create nmsg output cmp -s ${SOURCE}.nmsg ${OUTPUT}.nmsg.nmsg.out check nmsg-to-nmsg +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -j ${SOURCE}.json > ${OUTPUT}.json.pres.out check read json base:dns and create presentation output cmp -s ${SOURCE}.pres ${OUTPUT}.json.pres.out check json-to-presentation +else +: +check json-to-presentation +fi +if [ "$USE_JSON" = "true" ]; then # output should be same as input $NMSGTOOL -j ${SOURCE}.json -J ${OUTPUT}.json.json.out check read json base:dns and create json output cmp -s ${SOURCE}.json ${OUTPUT}.json.json.out check json-to-json +else +: +check json-to-json +fi +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -j ${SOURCE}.json -w ${OUTPUT}.json.nmsg.out check read json base:dns and create nmsg output cmp -s ${SOURCE}.nmsg ${OUTPUT}.json.nmsg.out check json-to-nmsg - +else +: +check json-to-nmsg +fi # another test input # TODO: use a function since is repeated @@ -66,23 +82,42 @@ check read nmsg base:dns and create json output cmp -s @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.json @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.nmsg.json.out check nmsg-to-json +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -j @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.json > @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.json.pres.out check read json base:dns and create presentation output cmp -s @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.pres @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.json.pres.out check json-to-presentation +else +: +check json-to-presentation +fi +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -j @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.json -J @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.json.json.out check read json base:dns and create json output cmp -s @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.json @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.json.json.out check json-to-json - +else +: +check json-to-json +fi # NOTE: --readpres is not fully implemented for base:dns so aborts +if [ "$USE_JSON" = "true" ]; then # JSON input mistakes should result in no output $NMSGTOOL -dd -j @abs_top_srcdir@/tests/nmsg-dns-tests/test3-dns.json --writepres @abs_top_builddir@/tests/nmsg-dns-tests/test3-dns.json.pres.out 2>@abs_top_builddir@/tests/nmsg-dns-tests/test3-dns.json.pres.stderr.out check read broken json base:dns and create empty output +else +: +check broken json base:dns and create empty output +fi +if [ "$USE_JSON" = "true" ]; then grep "JSON parse error:" @abs_top_builddir@/tests/nmsg-dns-tests/test3-dns.json.pres.stderr.out >/dev/null check reports JSON parse error +else +: +check reports JSON parse error +fi test ! -s @abs_top_builddir@/tests/nmsg-dns-tests/test3-dns.json.pres.out check broken-json-to-empty-pres diff --git a/tests/nmsg-dnsobs-tests/test.sh.in b/tests/nmsg-dnsobs-tests/test.sh.in index 0ae93a11..614e5429 100755 --- a/tests/nmsg-dnsobs-tests/test.sh.in +++ b/tests/nmsg-dnsobs-tests/test.sh.in @@ -19,6 +19,8 @@ PAYLOAD="@abs_top_srcdir@/tests/nmsg-dnsobs-tests/test-dnsobs.nmsg" SOURCE=@abs_top_srcdir@/tests/nmsg-dnsobs-tests/test1-dnsobs OUTPUT=@abs_top_builddir@/tests/nmsg-dnsobs-tests/test1-dnsobs +USE_JSON="@use_json_c@" + # cleanup from previous run rm -f ${OUTPUT}*out @@ -33,26 +35,47 @@ check read nmsg base:dnsobs and create base:dnsobs nmsg output cmp -s ${SOURCE}.nmsg ${OUTPUT}.nmsg.nmsg.out check nmsg-to-nmsg +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -r ${SOURCE}.nmsg -J ${OUTPUT}.nmsg.json.out check read nmsg base:dnsobs and create base:dnsobs json output cmp -s ${SOURCE}.json ${OUTPUT}.nmsg.json.out check nmsg-to-json +else +: +check nmsg-to-json +fi + +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL --readjson ${SOURCE}.json > ${OUTPUT}.json.pres.out check read json base:dnsobs and create dnsobs presentation output cmp -s ${SOURCE}.pres ${OUTPUT}.json.pres.out check json-to-presentation +else +: +check json-to-presentation +fi +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL --readjson ${SOURCE}.json -w ${OUTPUT}.json.nmsg.out check read json base:dnsobs and create base:dnsobs nmsg output cmp -s ${SOURCE}.nmsg ${OUTPUT}.json.nmsg.out check json-to-nmsg +else +: +check json-to-nmsg +fi +if [ "$USE_JSON" = "true" ]; then # output should be same as input $NMSGTOOL --readjson ${SOURCE}.json -J ${OUTPUT}.json.json.out check read json base:dnsobs and create base:dnsobs json output cmp -s ${SOURCE}.json ${OUTPUT}.json.json.out check json-to-json +else +: +check json-to-json +fi # NOTE: --readpres is not fully implemented for base:dnsobs diff --git a/tests/nmsg-dnsqr-tests/test.sh.in b/tests/nmsg-dnsqr-tests/test.sh.in index 4cbeb3c1..dc9557c0 100755 --- a/tests/nmsg-dnsqr-tests/test.sh.in +++ b/tests/nmsg-dnsqr-tests/test.sh.in @@ -18,6 +18,8 @@ NMSGTOOL="@abs_top_builddir@/src/nmsgtool" SOURCE=@abs_top_srcdir@/tests/nmsg-dnsqr-tests/test1-dnsqr OUTPUT=@abs_top_builddir@/tests/nmsg-dnsqr-tests/test1-dnsqr +USE_JSON="@use_json_c@" + # cleanup from previous run rm -f ${OUTPUT}*out @@ -32,28 +34,48 @@ check read nmsg base:dnsqr and create nmsg output cmp -s ${SOURCE}.nmsg ${OUTPUT}.nmsg.nmsg.out check nmsg-to-nmsg +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -r ${SOURCE}.nmsg -J ${OUTPUT}.nmsg.json.out check read nmsg base:dnsqr and create json output cmp -s ${SOURCE}.json ${OUTPUT}.nmsg.json.out check nmsg-to-json +else +: +check nmsg-to-json +fi ############ +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -j ${SOURCE}.json > ${OUTPUT}.json.pres.out check read json base:dnsqr and create presentation output cmp -s ${SOURCE}.pres ${OUTPUT}.json.pres.out check json-to-presentation +else +: +check json-to-presentation +fi -# output should be same as input +if [ "$USE_JSON" = "true" ]; then +#output should be same as input $NMSGTOOL -j ${SOURCE}.json -J ${OUTPUT}.json.json.out check read json base:dnsqr and create json output cmp -s ${SOURCE}.json ${OUTPUT}.json.json.out check json-to-json +else +: +check json-to-json +fi +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -j ${SOURCE}.json -w ${OUTPUT}.json.nmsg.out check read json base:dnsqr and create nmsg output cmp -s ${SOURCE}.nmsg ${OUTPUT}.json.nmsg.out check json-to-nmsg +else +: +check json-to-nmsg +fi ############## diff --git a/tests/nmsg-http-tests/test.sh.in b/tests/nmsg-http-tests/test.sh.in index 812dba7e..d7d2441c 100755 --- a/tests/nmsg-http-tests/test.sh.in +++ b/tests/nmsg-http-tests/test.sh.in @@ -18,6 +18,8 @@ NMSGTOOL="@abs_top_builddir@/src/nmsgtool" SOURCE=@abs_top_srcdir@/tests/nmsg-http-tests/ OUTPUT=@abs_top_builddir@/tests/nmsg-http-tests/ +USE_JSON="@use_json_c@" + # cleanup from previous run rm -f ${OUTPUT}/test*-http*out @@ -76,23 +78,37 @@ echo Testing the JSON input with an empty request ... # single byte null string termination, so the message size is one byte # larger than the broken NMSG message that has no string termination. # This still results in empty request "". - +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL --readjson ${SOURCE}/test1-http-empty-request.json > ${OUTPUT}/test3-http.json.pres.out check read json base:http and create base:http presentation output cmp -s ${SOURCE}/test2-http-empty-request.pres ${OUTPUT}/test3-http.json.pres.out check json-to-presentation +else +: +check json-to-presentation +fi +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL --readjson ${SOURCE}/test1-http-empty-request.json -w ${OUTPUT}/test3-http.json.nmsg.out check read json base:http and create base:http nmsg output cmp -s ${SOURCE}/test2-http-empty-request.nmsg ${OUTPUT}/test3-http.json.nmsg.out check json-to-nmsg +else +: +check json-to-nmsg +fi +if [ "$USE_JSON" = "true" ]; then # output should be same as input $NMSGTOOL --readjson ${SOURCE}/test1-http-empty-request.json -J ${OUTPUT}/test3-http.json.json.out check read json base:http and create base:http json output # using same JSON to compare against cmp -s ${SOURCE}/test1-http-empty-request.json ${OUTPUT}/test3-http.json.json.out check json-to-json +else +: +check json-to-json +fi ######################## @@ -120,21 +136,36 @@ check nmsg-to-json echo Testing JSON input that has no request ... +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -j ${SOURCE}/test4-http-no-request.json > ${OUTPUT}/test4-http.json.pres.out check read json base:http and create base:http presentation output cmp -s ${SOURCE}/test4-http-no-request.pres ${OUTPUT}/test4-http.json.pres.out check json-to-presentation +else +: +check json-to-presentation +fi +if [ "$USE_JSON" = "true" ]; then $NMSGTOOL -j ${SOURCE}/test4-http-no-request.json -w ${OUTPUT}/test4-http.json.nmsg.out check read json base:http and create base:http nmsg output cmp -s ${SOURCE}/test4-http-no-request.nmsg ${OUTPUT}/test4-http.json.nmsg.out check json-to-nmsg +else +: +check json-to-nmsg +fi +if [ "$USE_JSON" = "true" ]; then # output should be same as input, pass through $NMSGTOOL -j ${SOURCE}/test4-http-no-request.json -J ${OUTPUT}/test4-http.json.json.out check read json base:http and create base:http json output cmp -s ${SOURCE}/test4-http-no-request.json ${OUTPUT}/test4-http.json.json.out check json-to-json +else +: +check json-to-json +fi # NOTE: --readpres is not implemented for base:http diff --git a/tests/string-tests/test.sh.in b/tests/string-tests/test.sh.in index f07d506b..95f68359 100755 --- a/tests/string-tests/test.sh.in +++ b/tests/string-tests/test.sh.in @@ -70,13 +70,19 @@ for c in $*; do # read nmsg, check presentation output check "$innmsg presentation" diff $outpres -r $innmsg - + + if [ "$USE_JSON" = "true" ]; then # read nmsg, check json output check "$innmsg json" diff $outjson -r $innmsg -J - # load json output, check against expected (but # not necessarily original) nmsg. check "$outjson load" cmp $outnmsg -j $outjson -w - + else + : + tll=true check "$innmsg json" true /dev/null + tll=true check "$outjson load" true /dev/null + fi done exit $status diff --git a/tests/test-io.c b/tests/test-io.c index 41082725..036a692f 100644 --- a/tests/test-io.c +++ b/tests/test-io.c @@ -47,6 +47,7 @@ +#ifdef HAVE_JSON_C static void dummy_callback(nmsg_message_t msg, void *user) { @@ -54,6 +55,7 @@ dummy_callback(nmsg_message_t msg, void *user) (void)(user); return; } +#endif /* Create and populate dummy base:packet message from scratch. */ static int @@ -333,6 +335,7 @@ test_ozlib(void) } /* Test the functionality of nmsg input loops. */ +#ifdef HAVE_JSON_C static int test_dummy(void) { @@ -649,7 +652,7 @@ test_multiplex(void) l_return_test_status(); } - +#endif static int ioloop_stopped = 0; @@ -727,6 +730,8 @@ typedef struct _iopair { int error; } iopair; + +#ifdef HAVE_JSON_C static size_t n_looped = 0, max_looped = 5; static void @@ -845,6 +850,7 @@ test_count(void) l_return_test_status(); } +#endif /* * Test a wide variety of nmsg input filter functions. @@ -921,6 +927,7 @@ test_io_filters2(void) l_return_test_status(); } +#ifdef HAVE_JSON_C /* Test nmsg rates and their effects on nmsg outputs with set rates. */ static int test_rate(void) @@ -1007,7 +1014,7 @@ test_rate(void) l_return_test_status(); } - +#endif static void *user_data = (void *)0xdeadbeef; static int touched_exit, touched_atstart, touched_close, num_received, touched_filter; @@ -1487,17 +1494,19 @@ main(void) { check_abort(nmsg_init() == nmsg_res_success); + #ifdef HAVE_JSON_C check_explicit2_display_only(test_dummy() == 0, "test-io/ test_dummy"); check_explicit2_display_only(test_multiplex() == 0, "test-io/ test_multiplex"); + check_explicit2_display_only(test_rate() == 0, "test-io/ test_rate"); + check_explicit2_display_only(test_count() == 0, "test-io/ test_count"); + #endif check_explicit2_display_only(test_interval() == 0, "test-io/ test_interval"); check_explicit2_display_only(test_sock() == 0, "test-io/ test_sock"); check_explicit2_display_only(test_ozlib() == 0, "test-io/ test_ozlib"); check_explicit2_display_only(test_io_filters() == 0, "test-io/ test_io_filters"); check_explicit2_display_only(test_io_filters2() == 0, "test-io/ test_io_filters2"); check_explicit2_display_only(test_io_sockspec() == 0, "test-io/ test_io_sockspec"); - check_explicit2_display_only(test_rate() == 0, "test-io/ test_rate"); check_explicit2_display_only(test_input_rate() == 0, "test-io/ test_input_rate"); - check_explicit2_display_only(test_count() == 0, "test-io/ test_count"); check_explicit2_display_only(test_blocking() == 0, "test-io/ test_blocking"); check_explicit2_display_only(test_misc() == 0, "test-io/ test_misc"); diff --git a/tests/test-kicker.sh b/tests/test-kicker.sh index 6437aa0d..0526604c 100755 --- a/tests/test-kicker.sh +++ b/tests/test-kicker.sh @@ -13,7 +13,7 @@ outfile=$outdir/test-kicker.out # by using echo as the kicker the filenames are output one at a time to stdout kicker="echo" retval=0 - +echo "Use Json: {$USE_JSON}" check() { if [ $? = "0" ]; then echo "PASS: $*" @@ -29,6 +29,7 @@ mkdir $outdir cd $outdir NMSG_MSGMOD_DIR=${NMSG_MSGMOD_DIR:-$abs_top_builddir/nmsg/base/.libs} +if [ "$USE_JSON" = "true" ]; then # Read input data with our kicked nmsgtools. $nmsgtool_test -ddddd -j $infile -c 1 -k "$kicker" > $outfile @@ -48,6 +49,11 @@ done < $outfile file_count=$(ls -1 $outdir | wc -l) [ "$file_count" -eq "1" ] # 1 to account for the kicker output file. check "file names in kicker output file match actual output filenames" +else +: +check "comparison of kicked output files" +check "file names in kicker output file match actual output filenames" +fi # Clean-up! rm -rf $outdir diff --git a/tests/test-misc.c b/tests/test-misc.c index 137cd928..b2051a67 100644 --- a/tests/test-misc.c +++ b/tests/test-misc.c @@ -670,6 +670,7 @@ test_msgmod(void) l_return_test_status(); } +#ifdef HAVE_JSON_C /* Test the filter module subsystem against a message, using our sample module */ static int test_fltmod(void) @@ -709,6 +710,7 @@ test_fltmod(void) l_return_test_status(); } +#endif static void *cb_token = (void *)0xdeadbeef; static int read_cb_success = 0, write_cb_success = 0; @@ -1285,7 +1287,9 @@ main(void) check_explicit2_display_only(test_inet_ntop() == 0, "test-misc/ test_inet_ntop"); check_explicit2_display_only(test_printf() == 0, "test-misc/ test_printf"); check_explicit2_display_only(test_msgmod() == 0, "test-misc/ test_msgmod"); + #ifdef HAVE_JSON_C check_explicit2_display_only(test_fltmod() == 0, "test-misc/ test_fltmod"); + #endif check_explicit2_display_only(test_ipdg() == 0, "test-misc/ test_ipdg"); check_explicit2_display_only(test_alias() == 0, "test-misc/ test_alias"); check_explicit2_display_only(test_strbuf() == 0, "test-misc/ test_strbuf"); diff --git a/tests/test-parse.c b/tests/test-parse.c index 8886f49a..47eeb643 100644 --- a/tests/test-parse.c +++ b/tests/test-parse.c @@ -35,6 +35,9 @@ #include "nmsg/base/http.pb-c.h" #include "wdns.h" + +#ifdef HAVE_JSON_C + #define NAME "test-parse" #define QUOTE(...) #__VA_ARGS__ @@ -373,14 +376,18 @@ test_serialize(void) l_return_test_status(); } +#endif + int main(void) { - check_abort(nmsg_init() == nmsg_res_success); + #ifdef HAVE_JSON_C + check_abort(nmsg_init() == nmsg_res_success); - check_explicit2_display_only(test_json() == 0, "test-parse / test_json"); - check_explicit2_display_only(test_serialize() == 0, "test-parse / test_serialize"); - check_explicit2_display_only(test_json_nmsg_json() == 0, "test-parse / test_json_nmsg_json"); + check_explicit2_display_only(test_json() == 0, "test-parse / test_json"); + check_explicit2_display_only(test_serialize() == 0, "test-parse / test_serialize"); + check_explicit2_display_only(test_json_nmsg_json() == 0, "test-parse / test_json_nmsg_json"); - g_check_test_status(false); + g_check_test_status(false); + #endif } diff --git a/tests/test-sample.sh b/tests/test-sample.sh index 71f81f36..b6fe9f85 100755 --- a/tests/test-sample.sh +++ b/tests/test-sample.sh @@ -30,6 +30,7 @@ check() { echo "Testing sample filter: " +if [ "$USE_JSON" = "true" ]; then # Create a listener and a writer on the same socket. $nmsgtool_test -ddddd -F ${MODULE_PATHNAME},"count=$sample_entry_count" -j $infile -J $outfile @@ -37,6 +38,11 @@ $nmsgtool_test -ddddd -F ${MODULE_PATHNAME},"count=$sample_entry_count" -j $infi line_count=$(wc -l $outfile | awk '{print $1}') [ "$line_count" -eq "$desired_entry_count" ] check "comparison of sample-filtered json output" +else +: +check "comparison of sample-filtered json output" +fi + # Cleanup! rm $outfile