mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Use test-core module. Fix some tests & warnings.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5169 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f959452ec4
commit
d2d5478f31
@ -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
|
||||
|
@ -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 <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#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;
|
||||
}
|
||||
|
@ -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 <glib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* 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 */
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bar.h"
|
||||
|
||||
int
|
||||
bar_hello(void) {
|
||||
return 1;
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "foo.h"
|
||||
|
||||
int
|
||||
foo_hello(void) {
|
||||
return 10;
|
||||
|
Loading…
Reference in New Issue
Block a user