From 316300e38a70897e33879df500509fe4aa76dc7e Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 22 Sep 2007 13:32:42 +0000 Subject: Create a library of utility functions for the testsuite to use Make test/binding.c include stdio.h itself rather than relying on other things to include it. svn path=/trunk/dom/; revision=3568 --- test/Makefile | 18 +++-- test/binding.c | 2 + test/lib/Makefile | 69 +++++++++++++++++++ test/lib/exceptions.h | 34 +++++++++ test/lib/list.c | 85 +++++++++++++++++++++++ test/lib/list.h | 44 ++++++++++++ test/lib/testassert.c | 25 +++++++ test/lib/testassert.h | 22 ++++++ test/lib/testobject.c | 116 +++++++++++++++++++++++++++++++ test/lib/testobject.h | 22 ++++++ test/lib/utils.c | 34 +++++++++ test/lib/utils.h | 35 ++++++++++ test/list.c | 85 ----------------------- test/list.h | 44 ------------ test/testutils.h | 187 ++------------------------------------------------ 15 files changed, 507 insertions(+), 315 deletions(-) create mode 100644 test/lib/Makefile create mode 100644 test/lib/exceptions.h create mode 100644 test/lib/list.c create mode 100644 test/lib/list.h create mode 100644 test/lib/testassert.c create mode 100644 test/lib/testassert.h create mode 100644 test/lib/testobject.c create mode 100644 test/lib/testobject.h create mode 100644 test/lib/utils.c create mode 100644 test/lib/utils.h delete mode 100644 test/list.c delete mode 100644 test/list.h diff --git a/test/Makefile b/test/Makefile index fd17232..d298648 100644 --- a/test/Makefile +++ b/test/Makefile @@ -22,6 +22,9 @@ CFLAGS += -I${TOP}/src/ -I${TOP}/bindings/xml/ -I$(CURDIR) LDFLAGS += `${PKGCONFIG} ${PKGCONFIGFLAGS} --libs libxml-2.0` +# Libraries we link against +LIBS = -L./lib -ldebug -ldom-libxml-debug -ldom-debug + # Release output RELEASE = @@ -39,14 +42,17 @@ XMLOBJS = $(addprefix xml/bin/, $(notdir $(XMLFILES:.xml=))) OTHEROBJS = binding OBJS = $(OTHEROBJS) $(XMLOBJS) -.PHONY: clean debug export release setup test +.PHONY: clean debug export release setup test transform # Targets release: + @${MAKE} -C lib release debug: + @${MAKE} -C lib debug clean: + @${MAKE} -C lib clean ifneq (${OBJS}, ) -@${RM} ${RMFLAGS} $(addsuffix ${EXEEXT}, $(OTHEROBJS)) -@${RM} ${RMFLAGS} -r xml/c/ @@ -54,15 +60,18 @@ ifneq (${OBJS}, ) endif distclean: + @${MAKE} -C lib distclean -@${RM} ${RMFLAGS} log setup: + @${MAKE} -C lib setup @${MKDIR} ${MKDIRFLAGS} $(CURDIR)/xml/c @${MKDIR} ${MKDIRFLAGS} $(CURDIR)/xml/bin export: + @${MAKE} -C lib export -test: $(OBJS) +test: release debug $(OBJS) @${PERL} testrunner.pl ${EXEEXT} transform: $(CFILES) @@ -71,7 +80,7 @@ transform: $(CFILES) xml/bin/%: xml/c/%.c @${ECHO} ${ECHOFLAGS} "==> $<" @${CC} -c -g ${CFLAGS} -o $@.o $< - @${LD} -g -o $@ $@.o ${LDFLAGS} -ldom-libxml-debug -ldom-debug + @${LD} -g -o $@ $@.o ${LDFLAGS} $(LIBS) @${RM} ${RMFLAGS} $@.o xml/c/%.c: xml/tests/%.xml @@ -80,5 +89,6 @@ xml/c/%.c: xml/tests/%.xml %: %.c @${ECHO} ${ECHOFLAGS} "==> $<" @${CC} -c -g ${CFLAGS} -o $@.o $< - @${LD} -g -o $@ $@.o ${LDFLAGS} -ldom-libxml-debug -ldom-debug + @${LD} -g -o $@ $@.o ${LDFLAGS} $(LIBS) @${RM} ${RMFLAGS} $@.o + diff --git a/test/binding.c b/test/binding.c index a06763c..ac76733 100644 --- a/test/binding.c +++ b/test/binding.c @@ -1,3 +1,5 @@ +#include + #include #include "testutils.h" diff --git a/test/lib/Makefile b/test/lib/Makefile new file mode 100644 index 0000000..22a06e9 --- /dev/null +++ b/test/lib/Makefile @@ -0,0 +1,69 @@ +# Makefile for DOM testcase utility library +# +# Toolchain is exported by top-level makefile +# +# Top-level makefile also exports the following variables: +# +# COMPONENT Name of component +# EXPORT Absolute path of export directory +# TOP Absolute path of source tree root +# +# The top-level makefile requires the following targets to exist: +# +# clean Clean source tree +# debug Create a debug binary +# distclean Fully clean source tree, back to pristine condition +# export Export distributable components to ${EXPORT} +# release Create a release binary +# setup Perform any setup required prior to compilation +# test Execute any test cases + +# Manipulate include paths +CFLAGS += -I$(TOP) -I$(CURDIR) + +# Release output +RELEASE = libdebug.a + +# Debug output +DEBUG = libdebug-debug.a + +# Objects +OBJS = list testassert testobject utils + +.PHONY: clean debug export release setup test + +# Targets +release: $(addprefix Release/, $(addsuffix .o, $(OBJS))) + @${AR} ${ARFLAGS} $(RELEASE) Release/* + +debug: $(addprefix Debug/, $(addsuffix .o, $(OBJS))) + @${AR} ${ARFLAGS} $(DEBUG) Debug/* + +clean: +ifneq (${OBJS}, ) + -@${RM} ${RMFLAGS} $(addprefix Release/, $(addsuffix .o, ${OBJS})) + -@${RM} ${RMFLAGS} $(addprefix Debug/, $(addsuffix .o, ${OBJS})) +endif + -@${RM} ${RMFLAGS} $(RELEASE) $(DEBUG) + +distclean: + -@${RM} ${RMFLAGS} -r Release + -@${RM} ${RMFLAGS} -r Debug + +setup: + @${MKDIR} ${MKDIRFLAGS} Release + @${MKDIR} ${MKDIRFLAGS} Debug + +export: + +test: + +# Pattern rules +Release/%.o: %.c + @${ECHO} ${ECHOFLAGS} "==> $<" + @${CC} -c ${CFLAGS} -DNDEBUG -o $@ $< + +Debug/%.o: %.c + @${ECHO} ${ECHOFLAGS} "==> $<" + @${CC} -c -g ${CFLAGS} -o $@ $< + diff --git a/test/lib/exceptions.h b/test/lib/exceptions.h new file mode 100644 index 0000000..1c6b8e2 --- /dev/null +++ b/test/lib/exceptions.h @@ -0,0 +1,34 @@ +#ifndef exceptions_h_ +#define exceptions_h_ + +#include + +#include + +/* Usage: + TRY + THROW(DOM_NOT_FOUND_ERR); + THROW_IF_ERR(dom_document_get_doctype(...)); + CATCH(ex) + printf("exception: %d\n", ex); + ENDTRY +*/ +#define TRY __exvalue=setjmp(__exbuf); \ + if (__exvalue==0) { +#define CATCH(x) } else { \ + int x = __exvalue; +#define ENDTRY } +#define THROW(x) longjmp(__exbuf, x) + +#define THROW_IF_ERR(x) \ + do { \ + int err = x; \ + if (err != DOM_NO_ERR) \ + THROW(err); \ + } while (0) + +jmp_buf __exbuf; +int __exvalue; + +#endif + diff --git a/test/lib/list.c b/test/lib/list.c new file mode 100644 index 0000000..0b2965f --- /dev/null +++ b/test/lib/list.c @@ -0,0 +1,85 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 James Shaw + */ + + +#include +#include +#include + +#include "list.h" +#include "testassert.h" + +struct list* list_new(void) +{ + struct list* list = malloc(sizeof(struct list)); + assert(list != NULL); + list->size = 0; + list->head = NULL; + list->tail = NULL; + return list; +} + +void list_destroy(struct list* list) +{ + struct list_elt* elt = list->head; + while (elt != NULL) { + struct list_elt* nextElt = elt->next; + free(elt); + elt = nextElt; + } + free(list); +} + +void list_add(struct list* list, void* data) +{ + struct list_elt* elt = malloc(sizeof(struct list_elt)); + assert(elt != NULL); + elt->data = data; + elt->next = NULL; + struct list_elt* tail = list->tail; + + /* if tail was set, make its 'next' ptr point to elt */ + if (tail != NULL) { + tail->next = elt; + } + + /* make elt the new tail */ + list->tail = elt; + + if (list->head == NULL) { + list->head = elt; + } + + /* inc the size of the list */ + list->size++; +} + +bool list_contains(struct list* list, void* data, list_compare_func comparator) +{ + struct list_elt* elt = list->head; + while (elt != NULL) { + if (comparator(elt->data, data) == 0) { + return true; + } + elt = elt->next; + } + return false; +} + +bool list_contains_all(struct list* superList, struct list* subList, + list_compare_func comparator) +{ + struct list_elt* elt = subList->head; + while (elt != NULL) { + if (!list_contains(superList, elt->data, comparator)) { + return false; + } + elt = elt->next; + } + return true; +} + diff --git a/test/lib/list.h b/test/lib/list.h new file mode 100644 index 0000000..a0a6c6a --- /dev/null +++ b/test/lib/list.h @@ -0,0 +1,44 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 James Shaw + */ + +#ifndef list_h_ +#define list_h_ + +struct list_elt { + void* data; + struct list_elt* next; +}; + +struct list { + unsigned int size; + struct list_elt* head; + struct list_elt* tail; +}; + +struct list* list_new(void); +void list_destroy(struct list* list); + +typedef int (*list_compare_func)(const void* a, const void* b); + +/** + * Add data to the tail of the list. + */ +void list_add(struct list* list, void* data); + +/** + * Tests if data is equal to any element in the list. + */ +bool list_contains(struct list* list, void* data, + int (*comparator)(const void* a, const void* b)); + +/** + * Tests if superlist contains all elements in sublist. Order is not important. + */ +bool list_contains_all(struct list* superList, struct list* subList, + list_compare_func comparator); + +#endif diff --git a/test/lib/testassert.c b/test/lib/testassert.c new file mode 100644 index 0000000..2a31ff3 --- /dev/null +++ b/test/lib/testassert.c @@ -0,0 +1,25 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 John-Mark Bell + */ + +#include +#include + +#include "testassert.h" +#include "utils.h" + +void __assert2(const char *expr, const char *function, + const char *file, int line) +{ + UNUSED(function); + UNUSED(file); + + printf("FAIL - %s at line %d\n", expr, line); + + exit(EXIT_FAILURE); +} + + diff --git a/test/lib/testassert.h b/test/lib/testassert.h new file mode 100644 index 0000000..329feff --- /dev/null +++ b/test/lib/testassert.h @@ -0,0 +1,22 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 John-Mark Bell + */ + +#ifndef testassert_h_ +#define testassert_h_ + +/* Redefine assert, so we can simply use the standard assert mechanism + * within testcases and exit with the right output for the testrunner + * to do the right thing. */ +void __assert2(const char *expr, const char *function, + const char *file, int line); + +#define assert(expr) \ + ((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0))) + + +#endif + diff --git a/test/lib/testobject.c b/test/lib/testobject.c new file mode 100644 index 0000000..e9d3d06 --- /dev/null +++ b/test/lib/testobject.c @@ -0,0 +1,116 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 John-Mark Bell + */ + +#include +#include + +#include "bindings/xml/xmlbinding.h" +#include "bindings/xml/xmlparser.h" + +#include "testassert.h" +#include "testobject.h" +#include "utils.h" + +struct TestObject { + xml_parser *parser; + struct dom_document *doc; +}; + +TestObject *test_object_create(int argc, char **argv, + const char *uri, bool will_be_modified) +{ + static bool xml_parser_initialised; + + char fnbuf[1024]; +#define CHUNK_SIZE 4096 + uint8_t buf[CHUNK_SIZE]; + FILE *fp; + size_t len; + TestObject *ret; + + UNUSED(will_be_modified); + + if (argc != 2) { + printf("Usage: %s \n", argv[0]); + exit(EXIT_FAILURE); + } + + if (xml_parser_initialised == false) { + assert(xml_dom_binding_initialise(myrealloc, NULL) == XML_OK); + + xml_parser_initialised = true; + } + + snprintf(fnbuf, sizeof fnbuf, "%s/%s", argv[1], uri); + + ret = malloc(sizeof(TestObject)); + if (ret == NULL) + return NULL; + + ret->parser = xml_parser_create(NULL, "UTF-8", myrealloc, NULL, + mymsg, NULL); + if (ret->parser == NULL) { + free(ret); + return NULL; + } + + fp = fopen(fnbuf, "r"); + if (fp == NULL) { + xml_parser_destroy(ret->parser); + free(ret); + return NULL; + } + + fseek(fp, 0, SEEK_END); + len = ftell(fp); + fseek(fp, 0, SEEK_SET); + + while (len > CHUNK_SIZE) { + fread(buf, 1, CHUNK_SIZE, fp); + + assert(xml_parser_parse_chunk(ret->parser, buf, + CHUNK_SIZE) == XML_OK); + + len -= CHUNK_SIZE; + } + + if (len > 0) { + fread(buf, 1, len, fp); + + assert(xml_parser_parse_chunk(ret->parser, buf, + len) == XML_OK); + + len = 0; + } + + assert(xml_parser_completed(ret->parser) == XML_OK); + + fclose(fp); + + ret->doc = xml_parser_get_document(ret->parser); + + xml_parser_destroy(ret->parser); + ret->parser = NULL; + + return ret; + +#undef CHUNK_SIZE +} + +struct dom_document *test_object_get_doc(TestObject *obj) +{ + return obj->doc; +} + +const char *test_object_get_mimetype(TestObject *obj) +{ + UNUSED(obj); + + return "text/xml"; +} + + diff --git a/test/lib/testobject.h b/test/lib/testobject.h new file mode 100644 index 0000000..c72b39f --- /dev/null +++ b/test/lib/testobject.h @@ -0,0 +1,22 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 John-Mark Bell + */ + +#ifndef testobject_h_ +#define testobject_h_ + +#include + +struct TestObject; +typedef struct TestObject TestObject; + +TestObject *test_object_create(int argc, char **argv, + const char *uri, bool will_be_modified); +struct dom_document *test_object_get_doc(TestObject *obj); +const char *test_object_get_mimetype(TestObject *obj); + +#endif + diff --git a/test/lib/utils.c b/test/lib/utils.c new file mode 100644 index 0000000..739933f --- /dev/null +++ b/test/lib/utils.c @@ -0,0 +1,34 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 John-Mark Bell + */ + +#include +#include +#include + +#include "utils.h" + +void *myrealloc(void *ptr, size_t len, void *pw) +{ + UNUSED(pw); + + return realloc(ptr, len); +} + +void mymsg(uint32_t severity, void *ctx, const char *msg, ...) +{ + va_list l; + + UNUSED(ctx); + + va_start(l, msg); + + fprintf(stderr, "%d: ", severity); + vfprintf(stderr, msg, l); + fprintf(stderr, "\n"); +} + + diff --git a/test/lib/utils.h b/test/lib/utils.h new file mode 100644 index 0000000..b57db36 --- /dev/null +++ b/test/lib/utils.h @@ -0,0 +1,35 @@ +/* + * This file is part of libdom test suite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 John-Mark Bell + */ + +#ifndef utils_h_ +#define utils_h_ + +#include +#include + +#ifndef max +#define max(a,b) ((a)>(b)?(a):(b)) +#endif + +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif + +#ifndef SLEN +/* Calculate length of a string constant */ +#define SLEN(s) (sizeof((s)) - 1) /* -1 for '\0' */ +#endif + +#ifndef UNUSED +#define UNUSED(x) ((x) = (x)) +#endif + +void *myrealloc(void *ptr, size_t len, void *pw); +void mymsg(uint32_t severity, void *ctx, const char *msg, ...); + +#endif + diff --git a/test/list.c b/test/list.c deleted file mode 100644 index 2c742fa..0000000 --- a/test/list.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is part of libdom test suite. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2007 James Shaw - */ - -#include - -#include -#include -#include - -#include "list.h" - -struct list* list_new(void) -{ - struct list* list = malloc(sizeof(struct list)); - assert(list != NULL); - list->size = 0; - list->head = NULL; - list->tail = NULL; - return list; -} - -void list_destroy(struct list* list) -{ - struct list_elt* elt = list->head; - while (elt != NULL) { - struct list_elt* nextElt = elt->next; - free(elt); - elt = nextElt; - } - free(list); -} - -void list_add(struct list* list, void* data) -{ - struct list_elt* elt = malloc(sizeof(struct list_elt)); - assert(elt != NULL); - elt->data = data; - elt->next = NULL; - struct list_elt* tail = list->tail; - - /* if tail was set, make its 'next' ptr point to elt */ - if (tail != NULL) { - tail->next = elt; - } - - /* make elt the new tail */ - list->tail = elt; - - if (list->head == NULL) { - list->head = elt; - } - - /* inc the size of the list */ - list->size++; -} - -bool list_contains(struct list* list, void* data, list_compare_func comparator) -{ - struct list_elt* elt = list->head; - while (elt != NULL) { - if (comparator(elt->data, data) == 0) { - return true; - } - elt = elt->next; - } - return false; -} - -bool list_contains_all(struct list* superList, struct list* subList, - list_compare_func comparator) -{ - struct list_elt* elt = subList->head; - while (elt != NULL) { - if (!list_contains(superList, elt->data, comparator)) { - return false; - } - elt = elt->next; - } - return true; -} - diff --git a/test/list.h b/test/list.h deleted file mode 100644 index a0a6c6a..0000000 --- a/test/list.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of libdom test suite. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2007 James Shaw - */ - -#ifndef list_h_ -#define list_h_ - -struct list_elt { - void* data; - struct list_elt* next; -}; - -struct list { - unsigned int size; - struct list_elt* head; - struct list_elt* tail; -}; - -struct list* list_new(void); -void list_destroy(struct list* list); - -typedef int (*list_compare_func)(const void* a, const void* b); - -/** - * Add data to the tail of the list. - */ -void list_add(struct list* list, void* data); - -/** - * Tests if data is equal to any element in the list. - */ -bool list_contains(struct list* list, void* data, - int (*comparator)(const void* a, const void* b)); - -/** - * Tests if superlist contains all elements in sublist. Order is not important. - */ -bool list_contains_all(struct list* superList, struct list* subList, - list_compare_func comparator); - -#endif diff --git a/test/testutils.h b/test/testutils.h index 6e07660..9fa8241 100644 --- a/test/testutils.h +++ b/test/testutils.h @@ -1,188 +1,11 @@ #ifndef dom_test_testutils_h_ #define dom_test_testutils_h_ -#include -#include -#include -#include -#include -#include +#include "lib/exceptions.h" +#include "lib/list.h" +#include "lib/testassert.h" +#include "lib/testobject.h" +#include "lib/utils.h" -#include "exceptions.h" -#include "utils.h" -#include "xmlbinding.h" -#include "xmlparser.h" - -#ifndef UNUSED -#define UNUSED(x) ((x) = (x)) #endif -/* Usage: - TRY - THROW(DOM_NOT_FOUND_ERR); - THROW_IF_ERR(dom_document_get_doctype(...)); - CATCH(ex) - printf("exception: %d\n", ex); - ENDTRY -*/ -#define TRY __exvalue=setjmp(__exbuf); \ - if (__exvalue==0) { -#define CATCH(x) } else { \ - int x = __exvalue; -#define ENDTRY } -#define THROW(x) longjmp(__exbuf, x) - -#define THROW_IF_ERR(x) \ - do { \ - int err = x; \ - if (err != DOM_NO_ERR) \ - THROW(err); \ - } while (0) - -jmp_buf __exbuf; -int __exvalue; - -/* Redefine assert, so we can simply use the standard assert mechanism - * within testcases and exit with the right output for the testrunner - * to do the right thing. */ -void __assert2(const char *expr, const char *function, - const char *file, int line); - -void __assert2(const char *expr, const char *function, - const char *file, int line) -{ - UNUSED(function); - UNUSED(file); - - printf("FAIL - %s at line %d\n", expr, line); - - exit(EXIT_FAILURE); -} - -#define assert(expr) \ - ((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0))) - -static void *myrealloc(void *ptr, size_t len, void *pw) -{ - UNUSED(pw); - - return realloc(ptr, len); -} - -static void mymsg(uint32_t severity, void *ctx, const char *msg, ...) -{ - va_list l; - - UNUSED(ctx); - - va_start(l, msg); - - fprintf(stderr, "%d: ", severity); - vfprintf(stderr, msg, l); - fprintf(stderr, "\n"); -} - -typedef struct TestObject { - xml_parser *parser; - struct dom_document *doc; -} TestObject; - -TestObject *test_object_create(int argc, char **argv, - const char *uri, bool will_be_modified); -struct dom_document *test_object_get_doc(TestObject *obj); -const char *test_object_get_mimetype(TestObject *obj); - -TestObject *test_object_create(int argc, char **argv, - const char *uri, bool will_be_modified) -{ - static bool xml_parser_initialised; - - char fnbuf[1024]; -#define CHUNK_SIZE 4096 - uint8_t buf[CHUNK_SIZE]; - FILE *fp; - size_t len; - TestObject *ret; - - UNUSED(will_be_modified); - - if (argc != 2) { - printf("Usage: %s \n", argv[0]); - exit(EXIT_FAILURE); - } - - if (xml_parser_initialised == false) { - assert(xml_dom_binding_initialise(myrealloc, NULL) == XML_OK); - - xml_parser_initialised = true; - } - - snprintf(fnbuf, sizeof fnbuf, "%s/%s", argv[1], uri); - - ret = malloc(sizeof(TestObject)); - if (ret == NULL) - return NULL; - - ret->parser = xml_parser_create(NULL, "UTF-8", myrealloc, NULL, - mymsg, NULL); - if (ret->parser == NULL) { - free(ret); - return NULL; - } - - fp = fopen(fnbuf, "r"); - if (fp == NULL) { - xml_parser_destroy(ret->parser); - free(ret); - return NULL; - } - - fseek(fp, 0, SEEK_END); - len = ftell(fp); - fseek(fp, 0, SEEK_SET); - - while (len > CHUNK_SIZE) { - fread(buf, 1, CHUNK_SIZE, fp); - - assert(xml_parser_parse_chunk(ret->parser, buf, - CHUNK_SIZE) == XML_OK); - - len -= CHUNK_SIZE; - } - - if (len > 0) { - fread(buf, 1, len, fp); - - assert(xml_parser_parse_chunk(ret->parser, buf, - len) == XML_OK); - - len = 0; - } - - assert(xml_parser_completed(ret->parser) == XML_OK); - - fclose(fp); - - ret->doc = xml_parser_get_document(ret->parser); - - xml_parser_destroy(ret->parser); - ret->parser = NULL; - - return ret; - -#undef CHUNK_SIZE -} - -struct dom_document *test_object_get_doc(TestObject *obj) -{ - return obj->doc; -} - -const char *test_object_get_mimetype(TestObject *obj) -{ - UNUSED(obj); - - return "text/xml"; -} - -#endif -- cgit v1.2.3