diff --git a/src/backend/file/test/Makefile.am b/src/backend/file/test/Makefile.am index fd7e0853b1..e9c967224f 100644 --- a/src/backend/file/test/Makefile.am +++ b/src/backend/file/test/Makefile.am @@ -17,31 +17,31 @@ noinst_PROGRAMS = test-dom-converters1 test-kvp-frames \ LDADD = -L../../../engine -L../../../engine/.libs \ -L../../../gnc-module -L../../../gnc-module/.libs \ -L.. -L../.libs \ - -lgncmod-engine \ -lgncmodule \ + ${top_srcdir}/src/test-core/libgncmod-test.la \ + -lgncmod-engine \ -lgncmod-backend-file -CFLAGS=${GLIB_CFLAGS} -INCLUDES=-I ../../../engine -I ../ +CFLAGS = ${GLIB_CFLAGS} +INCLUDES = -I${top_srcdir}/src/test-core -I../../../engine -I ../ -test_kvp_frames_SOURCES = test-kvp-frames.c test-stuff.c gnc-test-stuff.c +test_kvp_frames_SOURCES = test-kvp-frames.c gnc-test-stuff.c -test_load_example_account_SOURCES = test-load-example-account.c test-stuff.c gnc-test-stuff.c +test_load_example_account_SOURCES = test-load-example-account.c gnc-test-stuff.c -test_dom_converters1_SOURCES = test-dom-converters1.c test-stuff.c gnc-test-stuff.c +test_dom_converters1_SOURCES = test-dom-converters1.c gnc-test-stuff.c -test_string_converters_SOURCES = test-string-converters.c test-stuff.c gnc-test-stuff.c +test_string_converters_SOURCES = test-string-converters.c gnc-test-stuff.c -test_xml_account_SOURCES = test-xml-account.c test-stuff.c gnc-test-stuff.c +test_xml_account_SOURCES = test-xml-account.c gnc-test-stuff.c -test_xml_commodity_SOURCES = test-xml-commodity.c test-stuff.c gnc-test-stuff.c +test_xml_commodity_SOURCES = test-xml-commodity.c gnc-test-stuff.c -test_xml_transaction_SOURCES = test-xml-transaction.c test-stuff.c gnc-test-stuff.c +test_xml_transaction_SOURCES = test-xml-transaction.c gnc-test-stuff.c -test_xml2_is_file_SOURCES = test-xml2-is-file.c test-stuff.c gnc-test-stuff.c +test_xml2_is_file_SOURCES = test-xml2-is-file.c gnc-test-stuff.c -test_load_xml2_SOURCES = test-load-xml2.c test-stuff.c gnc-test-stuff.c - -test_save_in_lang_SOURCES = test-save-in-lang.c test-stuff.c gnc-test-stuff.c +test_load_xml2_SOURCES = test-load-xml2.c gnc-test-stuff.c +test_save_in_lang_SOURCES = test-save-in-lang.c gnc-test-stuff.c diff --git a/src/backend/file/test/test-stuff.c b/src/backend/file/test/test-stuff.c deleted file mode 100644 index a31c1f9d61..0000000000 --- a/src/backend/file/test/test-stuff.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Created 20010320 by bstanley to hold only those - * testing functions which are independent of the rest of - * the GNUCash system. - * - * This allows me to compile simple test programs standalone... - * - */ - - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "test-stuff.h" - -void vsuccess_args( - const char *test_title, - const char *file, - int line, - const char *format, - va_list ap); - -void vfailure_args( - const char *test_title, - const char *file, - int line, - const char *format, - va_list ap); - -static guint successes; -static guint failures; -static gboolean success_should_print = FALSE; - -void -success_call( - const char *test_title, - const char* file, - int line ) -{ - success_args( test_title, file, line, "" ); -} - -void -success_args( - const char *test_title, - const char *file, - int line, - const char *format, - ... ) -{ - va_list ap; - va_start(ap,format); - vsuccess_args( test_title, file, line, format, ap ); - va_end(ap); -} - -void -vsuccess_args( - const char *test_title, - const char *file, - int line, - const char *format, - va_list ap) -{ - if( success_should_print ) { - printf("SUCCESS: %s, %s:%d ", test_title, file, line ); - vprintf(format, ap); - printf("\n"); - fflush(stdout); - } - ++successes; -} - -void -failure_call( - const char *test_title, - const char *file, - int line) -{ - failure_args( test_title, file, line, "" ); -} - - -void -failure_args( - const char *test_title, - const char *file, - int line, - const char *format, - ... ) -{ - va_list ap; - va_start(ap,format); - vfailure_args( test_title, file, line, format, ap ); - va_end(ap); -} -void -vfailure_args( - const char *test_title, - const char* file, - int line, - const char *format, - va_list ap) -{ - printf("FAILURE %s %s:%d ", test_title, file, line ); - vprintf(format, ap); - printf("\n"); - fflush(stdout); - - ++failures; -} - -int -get_rv(void) -{ - if( failures ) { - return 1; - } - return 0; -} - -void -do_test_call( - gboolean result, - const char* test_title, - const char* filename, - int line ) -{ - if( result ) { - success_args( test_title, filename, line, "" ); - } else { - failure_args( test_title, filename, line, "" ); - } -} - -void -do_test_args( - gboolean result, - const char* test_title, - const char* filename, - int line, - const char* format, - ... ) -{ - va_list ap; - va_start(ap, format); - - if( result ) { - vsuccess_args( test_title, filename, line, format, ap ); - } else { - vfailure_args( test_title, filename, line, format, ap ); - } - va_end(ap); -} - -void -print_test_results(void) -{ - guint total = successes+failures; - if( total == 1 ) { - printf( "Executed 1 test." ); - } else { - printf("Executed %d tests.", successes+failures ); - } - if( failures ) { - if( failures == 1 ) { - printf(" There was 1 failure." ); - } else { - printf(" There were %d failures.", failures ); - } - } else { - printf(" All tests passed."); - } - printf("\n"); - fflush(stdout); -} - -void -set_success_print( gboolean in_should_print ) -{ - success_should_print = in_should_print; -} - diff --git a/src/backend/file/test/test-stuff.h b/src/backend/file/test/test-stuff.h deleted file mode 100644 index ac5dc1946c..0000000000 --- a/src/backend/file/test/test-stuff.h +++ /dev/null @@ -1,121 +0,0 @@ -/* Modified by bstanley 20010320 - * Added do_test macro, do_test_call and do_test_call_args, - * print_test_results, set_success_print. - * - * Modified by bstanley 20010323 - * removed testing functionality which depends on the rest of gnucash - - * sepearated into gnc-test-stuff.h - * - */ - -/* Outline of a test program using the new testing functions: -#include "test-stuff.h" -int main( int argc, char* argv[] ) -{ - int a, b; - g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING ); - a = b = 1; - do_test( a == b, 'integer equality" ); - do_test( a != b, 'integer inequality? (should fail)" ); - - do_test_args( a == b, "fancy info", __FILE__, __LINE__, "a = %d, b = %b", a, b ); - - print_test_results(); - return get_rv(); -} -*/ -/* If you want to see test passes, use -set_success_print(TRUE); -before you execute the tests. -Otherwise, only failures are printed out. -*/ - - -#ifndef TEST_STUFF_H -#define TEST_STUFF_H - -#include "config.h" - -#include -#include - -/** - * Use this to indicate the result of a test. - * The result is TRUE for success, FALSE for failure. - * title describes the test - * Tests are automatically identified by their source file and line. - */ -#define do_test( result, title ) do_test_call( result, title, __FILE__, __LINE__ ); -#define success( title ) success_call( title, __FILE__, __LINE__ ); -#define failure( title ) failure_call( title, __FILE__, __LINE__ ); - -/** This one doesn't work because macros can't take a variable number of arguments. - * well, apparently gcc can, but it's non-standard. - * Apparently C99 can, too, but it's not exactly standard either. -#define do_test_args( result, title, format ) do_test_call( result, title, __FILE__, __LINE__, format, ... ); -*/ - -/* Privately used to indicate a test result. You may use these if you - * wish, but it's easier to use the do_test macro above. - */ -void do_test_call( - gboolean result, - const char* test_title, - const char* filename, - int line ); -void do_test_args( - gboolean result, - const char* test_title, - const char* filename, - int line, - const char* format, ... ); - - -/** - * Prints out the number of tests passed and failed. - */ -void print_test_results(void); - -/** - * Use this to set whether successful tests - * should print a message. - * Default is false. - * Successful test messages are useful while initally constructing the - * test suite, but when it's completed, no news is good news. - * A successful test run will be indicated by the message - * from print_test_results(). - */ -void set_success_print( gboolean in_should_print ); - -/* Value to return from main. Set to 1 if there were any fails, 0 otherwise. */ -int get_rv(void); - -/** Testing primitives. - * Sometimes you just have to put the results of - * a test into different forks of the code. - */ -void success_call( - const char *test_title, - const char *file, - int line ); - -void success_args( - const char *test_title, - const char *file, - int line, - const char *format, - ... ); - -void failure_call( - const char *test_title, - const char *file, - int line); - -void failure_args( - const char *test_title, - const char *file, - int line, - const char *format, - ... ); - -#endif /* TEST_STUFF_H */ diff --git a/src/backend/postgres/test/Makefile.am b/src/backend/postgres/test/Makefile.am index c702296397..304a884e65 100644 --- a/src/backend/postgres/test/Makefile.am +++ b/src/backend/postgres/test/Makefile.am @@ -4,4 +4,4 @@ TESTS_ENVIRONMENT=\ GNC_MODULE_PATH=${top_srcdir}/src/engine:${top_srcdir}/src/backend/postgres \ GUILE_LOAD_PATH=${G_WRAP_MODULE_DIR}:..:${top_srcdir}/src/gnc-module \ LTDL_LIBRARY_PATH=${top_srcdir}/src/gnc-module \ - LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module\.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs + LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module/.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs diff --git a/src/engine/test/Makefile.am b/src/engine/test/Makefile.am index a3bdd6ff56..9ab67d64b5 100644 --- a/src/engine/test/Makefile.am +++ b/src/engine/test/Makefile.am @@ -6,7 +6,8 @@ TESTS = test-load-engine test-create-account TESTS_ENVIRONMENT = \ GNC_MODULE_PATH="${top_srcdir}/src/engine" \ GUILE_LOAD_PATH="${G_WRAP_MODULE_DIR}:..:../../gnc-module" \ - LTDL_LIBRARY_PATH=../../gnc-module + LTDL_LIBRARY_PATH=../../gnc-module \ + LD_LIBRARY_PATH=../../gnc-module:../../gnc-module/.libs bin_PROGRAMS = test-load-engine test_load_engine_SOURCES=test-load-engine.c diff --git a/src/gnc-module/test/Makefile.am b/src/gnc-module/test/Makefile.am index 6c2f8a5708..48699a5aeb 100644 --- a/src/gnc-module/test/Makefile.am +++ b/src/gnc-module/test/Makefile.am @@ -11,7 +11,7 @@ TESTS_ENVIRONMENT = \ GNC_MODULE_PATH=${PWD}/mod-foo:${PWD}/mod-bar:${PWD}/mod-baz:${PWD}/misc-mods \ GUILE_LOAD_PATH=..:${G_WRAP_MODULE_DIR} \ LTDL_LIBRARY_PATH=../ \ - LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:mod-foo:mod-foo/.libs:mod-bar:mod-bar/.libs:mod-baz:mod-baz/.libs + LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:mod-foo:mod-foo/.libs:mod-bar:mod-bar/.libs:mod-baz:mod-baz/.libs:..:../.libs noinst_PROGRAMS=test-load-c test-modsysver test-incompatdep test-agedver \ test-dynload diff --git a/src/gnc-module/test/mod-bar/bar.c b/src/gnc-module/test/mod-bar/bar.c index 1050fd9785..b2d48a1341 100644 --- a/src/gnc-module/test/mod-bar/bar.c +++ b/src/gnc-module/test/mod-bar/bar.c @@ -4,6 +4,8 @@ #include +#include "bar.h" + int bar_hello(void) { return 1; diff --git a/src/gnc-module/test/mod-foo/foo.c b/src/gnc-module/test/mod-foo/foo.c index 1348ca3142..c6578268c5 100644 --- a/src/gnc-module/test/mod-foo/foo.c +++ b/src/gnc-module/test/mod-foo/foo.c @@ -4,6 +4,8 @@ #include +#include "foo.h" + int foo_hello(void) { return 10;