31 #include <sys/types.h>
37 #include <glib-object.h>
38 #include <glib/gstdio.h>
40 #include <cashobjects.h>
43 #include "../gnc-backend-xml.h"
44 #include "../io-gncxml-v2.h"
46 #include <test-stuff.h>
47 #include <unittest-support.h>
49 #include <test-file-stuff.h>
51 #define GNC_LIB_NAME "gncmod-backend-xml"
54 remove_files_pattern(
const char *begining,
const char *ending)
59 remove_locks(
const char *filename)
65 to_remove = g_strdup_printf(
"%s.LCK", filename);
66 if (g_stat(to_remove, &buf) != -1)
73 remove_files_pattern(filename,
".LCK");
77 test_load_file(
const char *filename)
83 gchar *logdomain =
"backend.xml";
84 guint loglevel = G_LOG_LEVEL_WARNING;
86 g_log_set_handler (logdomain, loglevel,
87 (GLogFunc)test_checked_handler, &check);
89 session = qof_session_new();
91 remove_locks(filename);
93 ignore_lock = (g_strcmp0(g_getenv(
"SRCDIR"),
".") != 0);
96 qof_session_load(session, NULL);
99 root = gnc_book_get_root_account(book);
100 do_test (gnc_account_get_book (root) == book,
101 "book and root account don't match");
104 "session load xml2", __FILE__, __LINE__,
105 "qof error=%d for file [%s]",
113 main (
int argc,
char ** argv)
115 const char *location = g_getenv(
"GNC_TEST_FILES");
116 int files_tested = 0;
120 cashobjects_register();
122 " loading gnc-backend-xml GModule failed");
126 location =
"test-files/xml2";
131 if ((xml2_dir = g_dir_open(location, 0, NULL)) == NULL)
133 failure(
"unable to open xml2 directory");
139 while ((entry = g_dir_read_name(xml2_dir)) != NULL)
141 if (g_str_has_suffix(entry,
".gml2"))
143 gchar *to_open = g_build_filename(location, entry, (gchar*)NULL);
144 if (!g_file_test(to_open, G_FILE_TEST_IS_DIR))
146 test_load_file(to_open);
154 g_dir_close(xml2_dir);
156 if (files_tested == 0)
158 failure(
"handled 0 files in test-load-xml2");
161 print_test_results();
void qof_session_save(QofSession *session, QofPercentageFunc percentage_func)
void xaccLogDisable(void)
QofBook * qof_session_get_book(const QofSession *session)
QofBackendError qof_session_get_error(QofSession *session)
All type declarations for the whole Gnucash engine.
gboolean qof_load_backend_library(const gchar *directory, const gchar *module_name)
Load a QOF-compatible backend shared library.
API for the transaction logger.
void qof_close(void)
Safely close down the Query Object Framework.
void qof_session_begin(QofSession *session, const char *book_id, gboolean ignore_lock, gboolean create, gboolean force)
void qof_session_end(QofSession *session)
void qof_init(void)
Initialise the Query Object Framework.