* src/engine/engine-helpers.c: turn off scheme garbage collection

during query->scm and scm->query conversion.  It shaves about 50%
	  off the test-scm-query-string tests.
	* src/engine/test-core/test-engine-stuff.c:  add some code to help
	  track down what the get_random_query() is doing.  Turned off by
	  default.
	* src/app-utils/test/test-scm-query-string.c: make the test
	  deterministic by seeding the RNG with a known value.  There is a
	  known "delay" at #245 with a seed of 1 on Linux systems.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9273 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2003-09-10 00:01:54 +00:00
parent fb2f55460f
commit 3331bbe954
4 changed files with 42 additions and 3 deletions

View File

@ -6,6 +6,16 @@
it.
Fixes bug #121677
* src/engine/engine-helpers.c: turn off scheme garbage collection
during query->scm and scm->query conversion. It shaves about 50%
off the test-scm-query-string tests.
* src/engine/test-core/test-engine-stuff.c: add some code to help
track down what the get_random_query() is doing. Turned off by
default.
* src/app-utils/test/test-scm-query-string.c: make the test
deterministic by seeding the RNG with a known value. There is a
known "delay" at #245 with a seed of 1 on Linux systems.
2003-09-04 Derek Atkins <derek@ihtfp.com>
Apply Nigel Titley's patch to fix #103174:

View File

@ -64,12 +64,23 @@ run_tests (void)
val2str = scm_c_eval_string ("gnc:value->string");
g_return_if_fail (SCM_PROCEDUREP (val2str));
for (i = 0; i < 100; i++) {
for (i = 0; i < 244; i++) {
q = get_random_query ();
test_query (q, val2str);
xaccFreeQuery (q);
printf("%d ", i);
fflush(stdout);
}
success ("");
{
q = get_random_query ();
test_query (q, val2str);
xaccFreeQuery (q);
printf("%d ", i);
fflush(stdout);
}
printf("\n");
}
static void
@ -86,6 +97,10 @@ main_helper (void *closure, int argc, char **argv)
/* double->string->double is not idempotent */
kvp_exclude_type (KVP_TYPE_DOUBLE);
/* Initialize to a known RNG position */
guid_init();
srand(1);
run_tests ();
print_test_results ();

View File

@ -1706,6 +1706,8 @@ gnc_query2scm (QofQuery *q)
if (!q) return SCM_BOOL_F;
++scm_block_gc;
/* terms */
pair = scm_cons (gnc_query_terms2scm (qof_query_get_terms (q)), SCM_EOL);
pair = scm_cons (scm_str2symbol ("terms"), pair);
@ -1741,6 +1743,7 @@ gnc_query2scm (QofQuery *q)
/* Reverse this list; tag it as 'query-v2' */
pair = scm_reverse (query_scm);
--scm_block_gc;
return scm_cons (scm_str2symbol ("query-v2"), pair);
}
@ -1964,6 +1967,8 @@ gnc_scm2query_v2 (SCM query_scm)
gboolean si1 = TRUE, si2 = TRUE, si3 = TRUE;
int max_results = -1;
++scm_block_gc;
while (!SCM_NULLP (query_scm))
{
char *symbol;
@ -2051,6 +2056,8 @@ gnc_scm2query_v2 (SCM query_scm)
free (symbol);
}
--scm_block_gc;
if (ok && search_for) {
qof_query_search_for (q, search_for);
qof_query_set_sort_order (q, sp1, sp2, sp3);

View File

@ -33,6 +33,7 @@ static kvp_value* get_random_kvp_value_depth (int type, gint depth);
static gpointer get_random_list_element (GList *list);
static void add_random_splits(QofBook *book, Transaction *trn);
gboolean gnc_engine_debug_random = FALSE;
/***********************************************************************/
@ -1235,7 +1236,9 @@ free_random_guids(GList *guids)
static QofQueryOp
get_random_queryop(void)
{
return get_random_int_in_range (1, QOF_QUERY_XOR);
QofQueryOp op = get_random_int_in_range (1, QOF_QUERY_XOR);
if (gnc_engine_debug_random) printf ("op = %d, ", op);
return op;
}
static GSList *
@ -1354,6 +1357,7 @@ get_random_query(void)
int num_terms;
num_terms = get_random_int_in_range (1, 4);
if (gnc_engine_debug_random) printf("num_terms = %d", num_terms);
q = xaccMallocQuery ();
@ -1369,6 +1373,7 @@ get_random_query(void)
GUID *guid;
pr_type = get_random_int_in_range (1, 20);
if (gnc_engine_debug_random) printf("\n pr_type = %d ", pr_type);
switch (pr_type)
{
@ -1505,11 +1510,13 @@ get_random_query(void)
break;
default:
if (gnc_engine_debug_random) printf("ignored..");
num_terms++;
break;
}
}
if (gnc_engine_debug_random) printf ("\n");
set_query_sort (q, get_random_int_in_range (1, BY_NONE));
xaccQuerySetSortIncreasing (q,