Merge Richard Cohen's 'valgrind-test-fixes' into stable.

This commit is contained in:
John Ralls
2023-06-22 13:24:56 -07:00
7 changed files with 50 additions and 38 deletions

View File

@@ -528,9 +528,8 @@ test_gnc_float_txn_get_other_float_split (FlFixture *fixture, gconstpointer pDat
void gnc_float_txn_to_txn_swap_accounts (const FloatingTxn *ft, Transaction *txn, Account *acct1, Account *acct2, gboolean do_commit)// C: 1 Local: 1:0:0 void gnc_float_txn_to_txn_swap_accounts (const FloatingTxn *ft, Transaction *txn, Account *acct1, Account *acct2, gboolean do_commit)// C: 1 Local: 1:0:0
*/ */
static void static void
test_gnc_float_txn_to_txn_swap_accounts (FlFixture *fixture, gconstpointer pData) impl_test_gnc_float_txn_to_txn_swap_accounts (FlFixture *fixture, const SwapCommitPrefs *prefs)
{ {
SwapCommitPrefs *prefs = (SwapCommitPrefs*)pData;
Transaction *txn = xaccMallocTransaction (fixture->book); Transaction *txn = xaccMallocTransaction (fixture->book);
Account *sw_acct1 = NULL, *sw_acct2 = NULL; Account *sw_acct1 = NULL, *sw_acct2 = NULL;
Account *exp_acct1 = fixture->acc1, *exp_acct2 = fixture->acc2; Account *exp_acct1 = fixture->acc1, *exp_acct2 = fixture->acc2;
@@ -591,11 +590,37 @@ test_gnc_float_txn_to_txn_swap_accounts (FlFixture *fixture, gconstpointer pData
xaccTransDestroy (txn); xaccTransDestroy (txn);
} }
static void
test_gnc_float_txn_to_txn_swap_accounts_noswap_nocommit (FlFixture *fixture, gconstpointer pData)
{
SwapCommitPrefs prefs = {FALSE, FALSE};
impl_test_gnc_float_txn_to_txn_swap_accounts(fixture, &prefs);
}
static void
test_gnc_float_txn_to_txn_swap_accounts_noswap_commit (FlFixture *fixture, gconstpointer pData)
{
SwapCommitPrefs prefs = {FALSE, TRUE};
impl_test_gnc_float_txn_to_txn_swap_accounts(fixture, &prefs);
}
static void
test_gnc_float_txn_to_txn_swap_accounts_swap_commit (FlFixture *fixture, gconstpointer pData)
{
SwapCommitPrefs prefs = {TRUE, TRUE};
impl_test_gnc_float_txn_to_txn_swap_accounts(fixture, &prefs);
}
static void
test_gnc_float_txn_to_txn_swap_accounts_swap_nocommit (FlFixture *fixture, gconstpointer pData)
{
SwapCommitPrefs prefs = {TRUE, FALSE};
impl_test_gnc_float_txn_to_txn_swap_accounts(fixture, &prefs);
}
void void
test_suite_split_register_copy_ops (void) test_suite_split_register_copy_ops (void)
{ {
SwapCommitPrefs prefs;
GNC_TEST_ADD (suitename, "gnc split to float split", Fixture, NULL, setup, test_gnc_split_to_float_split, teardown); GNC_TEST_ADD (suitename, "gnc split to float split", Fixture, NULL, setup, test_gnc_split_to_float_split, teardown);
GNC_TEST_ADD (suitename, "gnc float split to split", Fixture, NULL, setup, test_gnc_float_split_to_split, teardown); GNC_TEST_ADD (suitename, "gnc float split to split", Fixture, NULL, setup, test_gnc_float_split_to_split, teardown);
GNC_TEST_ADD (suitename, "gnc float txn to float txn", Fixture, NULL, setup, test_gnc_txn_to_float_txn, teardown); GNC_TEST_ADD (suitename, "gnc float txn to float txn", Fixture, NULL, setup, test_gnc_txn_to_float_txn, teardown);
@@ -603,14 +628,9 @@ test_suite_split_register_copy_ops (void)
GNC_TEST_ADD (suitename, "gnc float txn get float split", FlFixture, NULL, flsetup, test_gnc_float_txn_get_float_split, flteardown); GNC_TEST_ADD (suitename, "gnc float txn get float split", FlFixture, NULL, flsetup, test_gnc_float_txn_get_float_split, flteardown);
GNC_TEST_ADD (suitename, "gnc float txn get other float split", FlFixture, NULL, flsetup, test_gnc_float_txn_get_other_float_split, flteardown); GNC_TEST_ADD (suitename, "gnc float txn get other float split", FlFixture, NULL, flsetup, test_gnc_float_txn_get_other_float_split, flteardown);
prefs.swap_accts = FALSE; GNC_TEST_ADD (suitename, "gnc float txn to txn noswap nocommit", FlFixture, NULL, flsetup, test_gnc_float_txn_to_txn_swap_accounts_noswap_nocommit, flteardown);
prefs.docommit = FALSE; GNC_TEST_ADD (suitename, "gnc float txn to txn noswap commit", FlFixture, NULL, flsetup, test_gnc_float_txn_to_txn_swap_accounts_noswap_commit, flteardown);
GNC_TEST_ADD (suitename, "gnc float txn to txn noswap nocommit", FlFixture, &prefs, flsetup, test_gnc_float_txn_to_txn_swap_accounts, flteardown); GNC_TEST_ADD (suitename, "gnc float txn to txn swap commit", FlFixture, NULL, flsetup, test_gnc_float_txn_to_txn_swap_accounts_swap_commit, flteardown);
prefs.docommit = TRUE; GNC_TEST_ADD (suitename, "gnc float txn to txn swap nocommit", FlFixture, NULL, flsetup, test_gnc_float_txn_to_txn_swap_accounts_swap_nocommit, flteardown);
GNC_TEST_ADD (suitename, "gnc float txn to txn noswap commit", FlFixture, &prefs, flsetup, test_gnc_float_txn_to_txn_swap_accounts, flteardown);
prefs.swap_accts = TRUE;
GNC_TEST_ADD (suitename, "gnc float txn to txn swap commit", FlFixture, &prefs, flsetup, test_gnc_float_txn_to_txn_swap_accounts, flteardown);
prefs.docommit = FALSE;
GNC_TEST_ADD (suitename, "gnc float txn to txn swap nocommit", FlFixture, &prefs, flsetup, test_gnc_float_txn_to_txn_swap_accounts, flteardown);
} }

View File

@@ -248,7 +248,7 @@ test_dom_tree_to_guid (void)
"dom_tree_to_guid"); "dom_tree_to_guid");
xmlFreeNode (test_node); xmlFreeNode (test_node);
g_free (test_guid1); guid_free (test_guid1);
guid_free (test_guid2); guid_free (test_guid2);
} }
} }

View File

@@ -204,12 +204,7 @@ get_random_time (void)
GncGUID* GncGUID*
get_random_guid(void) get_random_guid(void)
{ {
GncGUID *ret; return guid_new();
ret = g_new(GncGUID, 1);
guid_replace(ret);
return ret;
} }
/* ========================================================== */ /* ========================================================== */
@@ -1502,14 +1497,9 @@ get_random_guids(int max)
} }
static void static void
free_random_guids(GList *guids) free_guids(GList *guids)
{ {
GList *node; g_list_free_full (guids, (GDestroyNotify)guid_free);
for (node = guids; node; node = node->next)
g_free (node->data);
g_list_free (guids);
} }
static QofQueryOp static QofQueryOp
@@ -1676,7 +1666,7 @@ get_random_query(void)
guids, guids,
compare_param<QofGuidMatch>(QOF_GUID_MATCH_NONE), compare_param<QofGuidMatch>(QOF_GUID_MATCH_NONE),
get_random_queryop ()); get_random_queryop ());
free_random_guids (guids); free_guids (guids);
break; break;
case 2: /*PR_ACTION */ case 2: /*PR_ACTION */
@@ -1737,7 +1727,7 @@ get_random_query(void)
guid, guid,
get_random_id_type (), get_random_id_type (),
get_random_queryop ()); get_random_queryop ());
g_free (guid); guid_free (guid);
break; break;
case 8: /* PR_KVP */ case 8: /* PR_KVP */
@@ -2031,9 +2021,7 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
} }
xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_ANY, QOF_QUERY_AND); xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_ANY, QOF_QUERY_AND);
for (node = list; node; node = node->next) free_guids (list);
g_free (node->data);
g_list_free (list);
} }
if (query_types & GUID_QT) if (query_types & GUID_QT)

View File

@@ -87,12 +87,13 @@ test_customer (void)
test_bool_fcn (book, "Active", gncCustomerSetActive, gncCustomerGetActive); test_bool_fcn (book, "Active", gncCustomerSetActive, gncCustomerGetActive);
do_test (gncCustomerGetAddr (customer) != NULL, "Addr");
do_test (gncCustomerGetShipAddr (customer) != NULL, "ShipAddr");
guid_replace (&guid); guid_replace (&guid);
customer = gncCustomerCreate (book); customer = gncCustomerCreate (book);
count++; count++;
do_test (gncCustomerGetAddr (customer) != NULL, "Addr");
do_test (gncCustomerGetShipAddr (customer) != NULL, "ShipAddr");
gncCustomerSetGUID (customer, &guid); gncCustomerSetGUID (customer, &guid);
do_test (guid_equal (&guid, gncCustomerGetGUID (customer)), "guid compare"); do_test (guid_equal (&guid, gncCustomerGetGUID (customer)), "guid compare");
} }

View File

@@ -94,11 +94,12 @@ test_employee (void)
test_bool_fcn (book, "Active", gncEmployeeSetActive, gncEmployeeGetActive); test_bool_fcn (book, "Active", gncEmployeeSetActive, gncEmployeeGetActive);
do_test (gncEmployeeGetAddr (employee) != NULL, "Addr");
guid_replace (&guid); guid_replace (&guid);
employee = gncEmployeeCreate (book); employee = gncEmployeeCreate (book);
count++; count++;
do_test (gncEmployeeGetAddr (employee) != NULL, "Addr");
gncEmployeeSetGUID (employee, &guid); gncEmployeeSetGUID (employee, &guid);
do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(employee))), "guid compare"); do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(employee))), "guid compare");
} }

View File

@@ -70,6 +70,7 @@ TEST (KvpValueTest, Copy)
v2 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {*v1}}; v2 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {*v1}};
EXPECT_EQ (compare (*v1, *v2), 0); EXPECT_EQ (compare (*v1, *v2), 0);
guid = guid_new ();
v1 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {guid}}; v1 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {guid}};
v2 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {*v1}}; v2 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {*v1}};
/*This should delete the guid*/ /*This should delete the guid*/

View File

@@ -94,11 +94,12 @@ test_vendor (void)
//test_bool_fcn (book, "TaxIncluded", gncVendorSetTaxIncluded, gncVendorGetTaxIncluded); //test_bool_fcn (book, "TaxIncluded", gncVendorSetTaxIncluded, gncVendorGetTaxIncluded);
test_bool_fcn (book, "Active", gncVendorSetActive, gncVendorGetActive); test_bool_fcn (book, "Active", gncVendorSetActive, gncVendorGetActive);
do_test (gncVendorGetAddr (vendor) != NULL, "Addr");
guid_replace (&guid); guid_replace (&guid);
vendor = gncVendorCreate (book); vendor = gncVendorCreate (book);
count++; count++;
do_test (gncVendorGetAddr (vendor) != NULL, "Addr");
gncVendorSetGUID (vendor, &guid); gncVendorSetGUID (vendor, &guid);
do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(vendor))), "guid compare"); do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(vendor))), "guid compare");
} }