At 06/30/2011 10:10 PM, Daniel P. Berrange Write:
While investigating some memory leaks it was unclear whether the
JSON code correctly free'd all memory during parsing. Add a test
case which can be run under valgrind to clearly demonstrate that
the parser is leak free.
* tests/Makefile.am: Add 'jsontest'
* tests/jsontest.c: A few simple JSON parsing tests
---
tests/Makefile.am | 14 +++++++
tests/jsontest.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 125 insertions(+), 0 deletions(-)
create mode 100644 tests/jsontest.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7db9d1f..3bde22e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,6 +14,7 @@ INCLUDES = \
$(SASL_CFLAGS) \
$(SELINUX_CFLAGS) \
$(APPARMOR_CFLAGS) \
+ $(YAJL_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(WARN_CFLAGS)
@@ -29,6 +30,7 @@ LDADDS = \
$(SASL_LIBS) \
$(SELINUX_LIBS) \
$(APPARMOR_LIBS) \
+ $(YAJL_LIBS) \
$(WARN_CFLAGS) \
../src/libvirt_test.la \
../gnulib/lib/libgnu.la \
@@ -112,6 +114,10 @@ if WITH_CIL
check_PROGRAMS += object-locking
endif
+if HAVE_YAJL
+check_PROGRAMS += jsontest
+endif
+
check_PROGRAMS += networkxml2xmltest
check_PROGRAMS += networkxml2argvtest
@@ -195,6 +201,10 @@ TESTS = virshtest \
virnetsockettest \
$(test_scripts)
+if HAVE_YAJL
+TESTS += jsontest
+endif
+
if WITH_XEN
TESTS += xml2sexprtest \
sexpr2xmltest \
@@ -443,6 +453,10 @@ hashtest_SOURCES = \
hashtest.c hashdata.h testutils.h testutils.c
hashtest_LDADD = $(LDADDS)
+jsontest_SOURCES = \
+ jsontest.c jsondata.h testutils.h testutils.c
jsondata.h does not exist. It will break building.
From 5d8ba96b29df4276fb0a81e10d65fef919789d65 Mon Sep 17 00:00:00 2001
From: Wen Congyang <wency(a)cn.fujitsu.com>
Date: Fri, 1 Jul 2011 10:43:39 +0800
Subject: [PATCH] fix builing error while enabling json
---
tests/Makefile.am | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 38a353f..5d1efb3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -455,7 +455,7 @@ hashtest_SOURCES = \
hashtest_LDADD = $(LDADDS)
jsontest_SOURCES = \
- jsontest.c jsondata.h testutils.h testutils.c
+ jsontest.c testutils.h testutils.c
jsontest_LDADD = $(LDADDS)
if WITH_LIBVIRTD
--
1.7.1