More work on test infrastructure.

Comment out vacuum analyze command,
it's not designed to be run so frequently.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5440 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas committed 2001-09-29 00:08:44 +00:00
1 parent 40792644bf
commit 66e5b6b991
11 files changed
+116 -56

No files matched your search

+21 -9
View File
@@ -12,6 +12,7 @@
#include "gnc-xml-helper.h"
#include "gnc-xml.h"
#include "gnc-engine-util.h"
#include "gnc-engine.h"
#include "sixtp-parsers.h"
@@ -279,6 +280,7 @@ really_get_rid_of_transaction(Transaction *trn)
struct tran_data_struct
{
Transaction *trn;
gnc_commodity *com;
int value;
};
typedef struct tran_data_struct tran_data;
@@ -286,14 +288,20 @@ typedef struct tran_data_struct tran_data;
static gboolean
test_add_transaction(const char *tag, gpointer globaldata, gpointer data)
{
Transaction *trans = data;
tran_data *gdata = (tran_data*)globaldata;
do_test_args(
xaccTransEqual((Transaction*)data, gdata->trn, TRUE, TRUE),
"gnc_transaction_sixtp_parser_create",
__FILE__, __LINE__,
"%d", gdata->value);
really_get_rid_of_transaction((Transaction*)data);
xaccTransBeginEdit (trans);
xaccTransSetCurrency (trans, gdata->com);
xaccTransCommitEdit (trans);
do_test_args(xaccTransEqual(trans, gdata->trn, TRUE, TRUE),
"gnc_transaction_sixtp_parser_create",
__FILE__, __LINE__,
"%d", gdata->value);
really_get_rid_of_transaction(trans);
return TRUE;
}
@@ -305,13 +313,16 @@ test_transaction(void)
{
Transaction *ran_trn;
xmlNodePtr test_node;
gnc_commodity *com;
gchar *compare_msg;
gchar *filename1;
FILE *cmp_file;
int fd;
gchar *compare_msg;
ran_trn = get_random_transaction();
com = xaccTransGetCurrency (ran_trn);
test_node = gnc_transaction_dom_tree_create(ran_trn);
if(!test_node)
{
@@ -352,6 +363,7 @@ test_transaction(void)
tran_data data;
data.trn = ran_trn;
data.com = com;
data.value = i;
parser = gnc_transaction_sixtp_parser_create();
@@ -390,7 +402,7 @@ test_real_transaction(const char *tag, gpointer global_data, gpointer data)
int
main(int argc, char **argv)
{
xaccGUIDInit();
gnc_engine_init (argc, argv);
xaccLogDisable();
if(argc > 1)
+2 -4
View File
@@ -102,7 +102,5 @@ table-version.c: table-version.sql
cat table-version.sql >> table-version.c
echo \" >> table-version.c
clean:
-rm -f base-autogen.c check-autogen.c kvp-autogen.c
-rm -f table-drop.c table-create.c table-version.c functions.c
CLEANFILES = base-autogen.c check-autogen.c kvp-autogen.c \
table-drop.c table-create.c table-version.c functions.c
+10 -1
View File
@@ -1073,9 +1073,18 @@ pgendSessionEnd (PGBackend *be)
if (!be->sessionGuid) return;
/* vacuuming w/ analyze can improve performance 20% */
#if 0
/* vacuuming w/ analyze can improve performance 20%.
* Should this really be done on every session end?
* The postgres manual recommends once every night! */
p = be->buff; *p=0;
p = stpcpy (p, "VACUUM ANALYZE;\n");
SEND_QUERY (be,be->buff, );
FINISH_QUERY(be->connection);
#endif
p = be->buff; *p=0;
p = stpcpy (p, "UPDATE gncSession SET time_off='NOW' "
"WHERE sessionGuid='");
p = stpcpy (p, be->session_guid_str);
+3
View File
@@ -31,3 +31,6 @@ INCLUDES = \
EXTRA_DIST = \
db-control.sh
CLEANFILES = test-file-*
+10 -1
View File
@@ -5,9 +5,18 @@ exit 0
EXIT_VALUE=0
./db-control.sh create
./db-control.sh start
./test-db || EXIT_VALUE=1
./db-control.sh stop
#./db-control.sh destroy
if test $EXIT_VALUE != 0; then exit $EXIT_VALUE; fi
diff -u test-file-1 test-file-2 || EXIT_VALUE=1
if test $EXIT_VALUE != 0; then exit $EXIT_VALUE; fi
./db-control.sh destroy
rm -f test-file-*
exit $EXIT_VALUE
+43 -8
View File
@@ -13,12 +13,15 @@
#include "test-engine-stuff.h"
static void
test_book (GNCBook *book)
run_test (void)
{
GNCBook *book;
GNCBackendError io_err;
char cwd[1024];
char *filename;
book = get_random_book ();
getcwd (cwd, sizeof (cwd));
filename = g_strconcat ("file:/", cwd, "/test-file-1", NULL);
@@ -42,7 +45,6 @@ test_book (GNCBook *book)
filename = g_strdup ("postgres://localhost:7777/gnc_test?mode=single-file");
gnc_book_begin (book, filename, FALSE, TRUE);
g_free (filename);
io_err = gnc_book_get_error (book);
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Beginning gnc_test"))
@@ -55,6 +57,41 @@ test_book (GNCBook *book)
gnc_book_end (book);
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Ending gnc_test"))
return;
gnc_book_destroy (book);
book = gnc_book_new ();
gnc_book_begin (book, filename, FALSE, FALSE);
g_free (filename);
io_err = gnc_book_get_error (book);
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Beginning gnc_test load"))
return;
gnc_book_load (book);
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Loading gnc_test"))
return;
gnc_book_end (book);
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Ending gnc_test load"))
return;
filename = g_strconcat ("file:/", cwd, "/test-file-2", NULL);
gnc_book_begin (book, filename, FALSE, TRUE);
g_free (filename);
io_err = gnc_book_get_error (book);
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Beginning test-file-2"))
return;
gnc_book_save (book);
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Saving test-file-2"))
return;
gnc_book_end (book);
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Ending test-file-2"))
return;
}
static void
@@ -65,13 +102,11 @@ guile_main (int argc, char **argv)
gnc_module_system_init ();
gnc_module_load ("gnucash/engine", 0);
random_glist_strings_only (TRUE);
xaccLogDisable ();
book = get_random_book ();
test_book (book);
gnc_book_destroy (book);
run_test ();
print_test_results ();
exit (get_rv ());
@@ -80,7 +115,7 @@ guile_main (int argc, char **argv)
int
main (int argc, char ** argv)
{
getchar ();
/* getchar (); */
gh_enter (argc, argv, guile_main);
+18 -29
View File
@@ -17,6 +17,7 @@
#include "test-stuff.h"
static gboolean add_comms_to_engine = TRUE;
static gboolean glist_strings_only = FALSE;
/***********************************************************************/
@@ -26,6 +27,12 @@ add_random_commodities_to_engine (gboolean add)
add_comms_to_engine = add;
}
void
random_glist_strings_only (gboolean strings_only)
{
glist_strings_only = strings_only;
}
Timespec*
get_random_timespec(void)
{
@@ -61,28 +68,6 @@ get_random_commodity_namespace(void)
return get_random_string_in_array(types);
}
gnc_commodity*
get_random_gnc_commodity_ref(void)
{
const gchar *name;
gchar *mnemonic;
gnc_commodity *ret;
name = get_random_commodity_namespace();
mnemonic = get_random_string();
if(!name || !mnemonic)
{
return NULL;
}
ret = gnc_commodity_new("", name, mnemonic, "", 0);
g_free(mnemonic);
return ret;
}
GNCPrice *
get_random_price(void)
{
@@ -93,11 +78,11 @@ get_random_price(void)
p = gnc_price_create ();
c = get_random_gnc_commodity_ref ();
c = get_random_commodity ();
c = gnc_commodity_table_insert (gnc_engine_commodities (), c);
gnc_price_set_commodity (p, c);
c = get_random_gnc_commodity_ref ();
c = get_random_commodity ();
c = gnc_commodity_table_insert (gnc_engine_commodities (), c);
gnc_price_set_currency (p, c);
@@ -166,9 +151,13 @@ get_random_glist(void)
int i;
int count = get_random_int_in_range(1, 5);
for(i = 0; i < count; i++)
for (i = 0; i < count; i++)
{
ret = g_list_prepend(ret, (gpointer)get_random_kvp_value(-2));
kvp_value_t kvpt;
kvpt = glist_strings_only ? KVP_TYPE_STRING : -2;
ret = g_list_prepend(ret, get_random_kvp_value (kvpt));
}
return ret;
@@ -397,7 +386,7 @@ get_random_account(void)
set_account_random_string(ret, xaccAccountSetCode);
set_account_random_string(ret, xaccAccountSetDescription);
xaccAccountSetCommodity(ret, get_random_gnc_commodity_ref());
xaccAccountSetCommodity(ret, get_random_commodity());
xaccAccountSetSlots_nc(ret, get_random_kvp_frame());
@@ -492,7 +481,7 @@ get_random_transaction(void)
xaccTransBeginEdit(ret);
xaccTransSetCurrency(ret, get_random_gnc_commodity_ref());
xaccTransSetCurrency(ret, get_random_commodity ());
set_tran_random_string(ret, xaccTransSetNum);
@@ -511,7 +500,7 @@ get_random_transaction(void)
}
gnc_commodity*
get_random_commodity(void)
get_random_commodity (void)
{
gnc_commodity *ret;
gchar *name;
+2 -1
View File
@@ -28,10 +28,11 @@ bin_data* get_random_binary_data(void);
kvp_frame* get_random_kvp_frame(void);
gnc_numeric get_random_gnc_numeric(void);
gnc_commodity* get_random_gnc_commodity_ref(void);
GUID* get_random_guid(void);
GList* get_random_glist(void);
void random_glist_strings_only (gboolean strings_only);
GNCPrice * get_random_price(void);
void make_random_pricedb (GNCPriceDB *pdb);
GNCPriceDB * get_random_pricedb(void);
+3 -1
View File
@@ -13,6 +13,7 @@
#include "test-stuff.h"
#include "FreqSpec.h"
#include "GNCIdP.h"
#include "gnc-engine.h"
static void
test_once (void)
@@ -524,7 +525,8 @@ main( int argc, char* argv[] )
#if 0
set_success_print(TRUE);
#endif
xaccGUIDInit();
gnc_engine_init (argc, argv);
test_once();
+2 -1
View File
@@ -3,6 +3,7 @@
#include "GNCIdP.h"
#include "gnc-book.h"
#include "gnc-engine.h"
#include "test-engine-stuff.h"
#include "test-stuff.h"
@@ -137,7 +138,7 @@ main (int argc, char **argv)
{
int i;
xaccGUIDInit ();
gnc_engine_init (argc, argv);
for (i = 0; i < 10; i++)
run_test ();
+2 -1
View File
@@ -4,6 +4,7 @@
#include "GNCIdP.h"
#include "Account.h"
#include "gnc-engine.h"
#include "test-engine-stuff.h"
#include "test-stuff.h"
#include "Transaction.h"
@@ -32,7 +33,7 @@ main(int argc, char **argv)
Split *spl;
gnc_numeric num;
xaccGUIDInit();
gnc_engine_init (argc, argv);
act1 = get_random_account();
if(!act1)