printf(" -dg Debug setting: only libgedcom debug messages\n");
printf(" -da Debug setting: libgedcom + yacc debug messages\n");
printf(" -q No output to standard output\n");
+ printf(" -o <outfile> File to generate output to (def. testgedcom.out)\n");
}
void gedcom_message_handler(Gedcom_msg_type type, char *msg)
int compat_enabled = 1;
int debug_level = 0;
int result = 0;
+ char* outfilename = NULL;
char* file_name = NULL;
if (argc > 1) {
else if (!strncmp(argv[i], "-q", 3)) {
output_set_quiet(1);
}
+ else if (!strncmp(argv[i], "-o", 3)) {
+ i++;
+ if (i < argc) {
+ outfilename = argv[i];
+ }
+ else {
+ printf ("Missing output file name\n");
+ show_help();
+ exit(1);
+ }
+ }
else if (strncmp(argv[i], "-", 1)) {
file_name = argv[i];
break;
gedcom_set_error_handling(mech);
gedcom_set_message_handler(gedcom_message_handler);
- output_open();
+ output_open(outfilename);
output(0, "\n=== Parsing file %s\n", file_name);
result = gom_parse_file(file_name);
if (result == 0) {
#include <stdio.h>
#include <stdarg.h>
-#define OUTFILE "testgedcom.out"
+#define OUTFILE "check.out"
FILE* outfile = NULL;
int quiet = 0;
-void output(int to_stdout_too, char* format, ...)
+void output(int to_stdout_too, const char* format, ...)
{
va_list ap;
va_start(ap, format);
quiet = q;
}
-void output_open()
+void output_open(const char *outfilename)
{
- outfile = fopen(OUTFILE, "a");
+ if (!outfilename)
+ outfilename = OUTFILE;
+ outfile = fopen(outfilename, "a");
if (!outfile) {
- printf("Could not open %s for appending\n", OUTFILE);
+ printf("Could not open %s for appending\n", outfilename);
}
}
#include <stdio.h>
#include <stdarg.h>
-void output(int to_stdout_too, char* format, ...);
+void output(int to_stdout_too, const char* format, ...);
void output_set_quiet(int q);
-void output_open();
+void output_open(const char *outfilename);
void output_close();
#endif /* __OUTPUT_H */
printf(" -3 Run the test parse 3 times instead of once\n");
printf(" -b Parse a bogus file before parsing the main file\n");
printf(" -q No output to standard output\n");
+ printf(" -o <outfile> File to generate output to (def. testgedcom.out)\n");
}
Gedcom_ctxt header_start(Gedcom_rec rec, int level, Gedcom_val xref, char *tag,
int run_times = 1;
int bogus = 0;
int result = 0;
+ char* outfilename = NULL;
char* file_name = NULL;
if (argc > 1) {
else if (!strncmp(argv[i], "-q", 3)) {
output_set_quiet(1);
}
+ else if (!strncmp(argv[i], "-o", 3)) {
+ i++;
+ if (i < argc) {
+ outfilename = argv[i];
+ }
+ else {
+ printf ("Missing output file name\n");
+ show_help();
+ exit(1);
+ }
+ }
else if (strncmp(argv[i], "-", 1)) {
file_name = argv[i];
break;
gedcom_set_default_callback(default_cb);
subscribe_callbacks();
- output_open();
+ output_open(outfilename);
if (bogus) {
output(0, "\n=== Parsing bogus file %s\n", BOGUS_FILE_NAME);
gedcom_parse_file(BOGUS_FILE_NAME);
done
file=$1
-expected_result=$2
+test_name=$2
+expected_result=$3
+if [ -z "$test_name" ]
+then
+ test_name=check
+fi
if [ -z "$expected_result" ]
then
expected_result=0
options="$options $extra_options"
fi
+outfile=$test_name.out
+logfile=check.out
+reffile=$srcdir/output/$test_name.ref
+options="$options -o $outfile"
+
builddir=`pwd`
ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la -dlopen $builddir/../gom/libgedcom_gom.la"
GCONV_PATH=.:$GCONV_PATH
ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
ln -s $srcdir/../iconv/glibc/gconv-modules .
rm -f core
+echo "======================================================">> $logfile
+echo "Performing test '$test_name'" >> $logfile
if [ "$GOM_DMALLOC_TEST" = "" ]
then
$ltcmd $GEDCOM_TESTENV $builddir/src/gomtest $options $testfile
rm gedcom.enc
rm ANSI_Z39.47.so
rm gconv-modules
-if [ "$result" -eq "$expected_result" -a ! -r core ]
+
+echo "Result is $result (expected: $expected_result)" >> $logfile
+if [ "$result" -ne "$expected_result" ]
then
- exit 0
-else
exit 1
+else
+ if [ -r core ]
+ then
+ echo "Core file generated!" >> $logfile
+ exit 1
+ else
+ if diff $outfile $reffile >/dev/null 2>>$logfile
+ then
+ echo "Output agrees with reference output" >> $logfile
+ rm $outfile
+ exit 0
+ else
+ echo "Differences with reference output detected!" >> $logfile
+ exit 1
+ fi
+ fi
fi
done
file=$1
-expected_result=$2
+test_name=$2
+expected_result=$3
+if [ -z "$test_name" ]
+then
+ test_name=check
+fi
if [ -z "$expected_result" ]
then
expected_result=0
options="$options $extra_options"
fi
+outfile=$test_name.out
+logfile=check.out
+reffile=$srcdir/output/$test_name.ref
+options="$options -o $outfile"
+
builddir=`pwd`
ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la"
GCONV_PATH=.:$GCONV_PATH
ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
ln -s $srcdir/../iconv/glibc/gconv-modules .
rm -f core
+echo "======================================================">> $logfile
+echo "Performing test '$test_name'" >> $logfile
$ltcmd $GEDCOM_TESTENV $builddir/src/testgedcom $options $testfile
result=$?
rm gedcom.enc
rm ANSI_Z39.47.so
rm gconv-modules
-if [ "$result" -eq "$expected_result" -a ! -r core ]
+
+echo "Result is $result (expected: $expected_result)" >> $logfile
+if [ "$result" -ne "$expected_result" ]
then
- exit 0
-else
exit 1
+else
+ if [ -r core ]
+ then
+ echo "Core file generated!" >> $logfile
+ exit 1
+ else
+ if diff $outfile $reffile >/dev/null 2>>$logfile
+ then
+ echo "Output agrees with reference output" >> $logfile
+ rm $outfile
+ exit 0
+ else
+ echo "Differences with reference output detected!" >> $logfile
+ exit 1
+ fi
+ fi
fi
shift
done
-expected_result=$1
+test_name=$1
+expected_result=$2
+if [ -z "$test_name" ]
+then
+ test_name=check
+fi
if [ -z "$expected_result" ]
then
expected_result=0
options="$options $extra_options"
fi
+outfile=$test_name.out
+logfile=check.out
+reffile=$srcdir/output/$test_name.ref
+options="$options -o $outfile"
+
builddir=`pwd`
ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la"
GCONV_PATH=.:$GCONV_PATH
ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
ln -s $srcdir/../iconv/glibc/gconv-modules .
rm -f core
+echo "======================================================">> $logfile
+echo "Performing test '$test_name'" >> $logfile
$ltcmd $GEDCOM_TESTENV $builddir/src/updatetest $options
result=$?
rm gedcom.enc
rm new.ged
rm ANSI_Z39.47.so
rm gconv-modules
-if [ "$result" -eq "$expected_result" -a ! -r core ]
+
+echo "Result is $result (expected: $expected_result)" >> $logfile
+if [ "$result" -ne "$expected_result" ]
then
- exit 0
-else
exit 1
+else
+ if [ -r core ]
+ then
+ echo "Core file generated!" >> $logfile
+ exit 1
+ else
+ if diff $outfile $reffile >/dev/null 2>>$logfile
+ then
+ echo "Output agrees with reference output" >> $logfile
+ rm $outfile
+ exit 0
+ else
+ echo "Differences with reference output detected!" >> $logfile
+ exit 1
+ fi
+ fi
fi
printf("Options:\n");
printf(" -h Show this help text\n");
printf(" -q No output to standard output\n");
+ printf(" -o <outfile> File to generate output to (def. testgedcom.out)\n");
}
int test_xref_functions()
int main(int argc, char* argv[])
{
int result;
+ char* outfilename = NULL;
if (argc > 1) {
int i;
else if (!strncmp(argv[i], "-q", 3)) {
output_set_quiet(1);
}
+ else if (!strncmp(argv[i], "-o", 3)) {
+ i++;
+ if (i < argc) {
+ outfilename = argv[i];
+ }
+ else {
+ printf ("Missing output file name\n");
+ show_help();
+ exit(1);
+ }
+ }
else {
printf ("Unrecognized option: %s\n", argv[i]);
show_help();
setlocale(LC_ALL, "");
gedcom_set_message_handler(gedcom_message_handler);
- output_open();
+ output_open(outfilename);
result = gedcom_new_model();
if (result == 0)