mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix sometime crash in test-xml-pricedb
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23439 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1ead96dc1a
commit
da89f13f23
@ -41,34 +41,31 @@
|
||||
#include "test-stuff.h"
|
||||
#include "test-engine-stuff.h"
|
||||
#include "test-file-stuff.h"
|
||||
#include "io-gncxml-v2.h"
|
||||
|
||||
static QofSession *session;
|
||||
|
||||
struct pricedb_data_struct
|
||||
{
|
||||
GNCPriceDB *db;
|
||||
int value;
|
||||
};
|
||||
typedef struct pricedb_data_struct pricedb_data;
|
||||
static int iter;
|
||||
|
||||
static gboolean
|
||||
test_add_pricedb (const char *tag, gpointer globaldata, gpointer data)
|
||||
{
|
||||
pricedb_data *gdata = globaldata;
|
||||
sixtp_gdv2 *gdata = globaldata;
|
||||
GNCPriceDB *db = gnc_pricedb_get_db (gdata->book);
|
||||
|
||||
do_test_args (gnc_pricedb_equal(data, gdata->db),
|
||||
do_test_args (gnc_pricedb_equal(data, db),
|
||||
"gnc_pricedb_sixtp_parser_create",
|
||||
__FILE__, __LINE__, "%d", gdata->value);
|
||||
__FILE__, __LINE__, "%d", iter);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
test_db (int i, GNCPriceDB *db)
|
||||
test_db (GNCPriceDB *db)
|
||||
{
|
||||
xmlNodePtr test_node;
|
||||
gchar *filename1;
|
||||
int fd;
|
||||
QofBook *book = qof_instance_get_book (QOF_INSTANCE (db));
|
||||
|
||||
test_node = gnc_pricedb_dom_tree_create (db);
|
||||
|
||||
@ -92,10 +89,8 @@ test_db (int i, GNCPriceDB *db)
|
||||
|
||||
{
|
||||
sixtp *parser;
|
||||
pricedb_data data;
|
||||
|
||||
data.db = db;
|
||||
data.value = i;
|
||||
load_counter lc;
|
||||
sixtp_gdv2 data = {book, lc, NULL, NULL, FALSE};
|
||||
|
||||
parser = sixtp_new ();
|
||||
|
||||
@ -105,14 +100,14 @@ test_db (int i, GNCPriceDB *db)
|
||||
NULL, NULL))
|
||||
{
|
||||
failure_args ("sixtp_add_some_sub_parsers failed",
|
||||
__FILE__, __LINE__, "%d", i);
|
||||
__FILE__, __LINE__, "%d", iter);
|
||||
}
|
||||
else if (!gnc_xml_parse_file (parser, filename1, test_add_pricedb,
|
||||
(gpointer)&data,
|
||||
qof_session_get_book (session)))
|
||||
{
|
||||
failure_args ("gnc_xml_parse_file returned FALSE",
|
||||
__FILE__, __LINE__, "%d", i);
|
||||
__FILE__, __LINE__, "%d", iter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,22 +119,20 @@ test_db (int i, GNCPriceDB *db)
|
||||
static void
|
||||
test_generation (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
for (iter = 0; iter < 20; iter++)
|
||||
{
|
||||
GNCPriceDB *db;
|
||||
g_message("i=%d", i);
|
||||
g_message("iter=%d", iter);
|
||||
session = qof_session_new();
|
||||
db = get_random_pricedb (qof_session_get_book (session));
|
||||
if (!db)
|
||||
{
|
||||
failure_args ("gnc_random_price_db returned NULL",
|
||||
__FILE__, __LINE__, "%d", i);
|
||||
__FILE__, __LINE__, "%d", iter);
|
||||
return;
|
||||
}
|
||||
if (gnc_pricedb_get_num_prices (db))
|
||||
test_db (i, db);
|
||||
test_db (db);
|
||||
|
||||
gnc_pricedb_destroy (db);
|
||||
qof_session_end(session);
|
||||
|
Loading…
Reference in New Issue
Block a user