Skip to content

Commit

Permalink
iproved tests for libgap
Browse files Browse the repository at this point in the history
took `-L ...` out of the command line
allow to build and run all the tests with just one makefile rule.
tests in testlibgap to run each time testlibgap target is made
also defined the list of tests and used it throughout.
Added a TODO in wscreate regarding workspace file naming
better formatting, remove -m option in libgap test calls
  • Loading branch information
dimpase committed Oct 31, 2018
1 parent 382f95c commit a6e47a1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
24 changes: 12 additions & 12 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -990,26 +990,26 @@ testbugfix: all
ReadGapRoot( "tst/testbugfix.g" );' | $(TESTGAP) | \
tee `date -u +dev/log/testbugfix2_%Y-%m-%d-%H-%M` )

LIBGAPTESTS := $(addprefix tst/testlibgap/,basic wsload wscreate)

# run a test in tst/testlibgap
tst/testlibgap/%: obj/tst/testlibgap/%.lo obj/tst/testlibgap/common.lo libgap.la
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $^ -o $@

clean: clean-testlibgap
clean-testlibgap:
rm -f tst/testlibgap/basic tst/testlibgap/wsload tst/testlibgap/wscreate
rm -f ${LIBGAPTESTS}

testlibgapws: tst/testlibgap/wscreate tst/testlibgap/wsload
tst/testlibgap/wscreate -A -l $(top_srcdir) -m 32m -q -T --nointeract > createws.out
diff $(top_srcdir)/tst/testlibgap/createws.expect createws.out
tst/testlibgap/wsload -A -l $(top_srcdir) -m 32m -q -T --nointeract -L /tmp/libgap.ws > loadws.out
diff $(top_srcdir)/tst/testlibgap/loadws.expect loadws.out
rm -f /tmp/libgap.ws loadws.out createws.out
# run all the tests in tst/testlibgap
testlibgap: ${LIBGAPTESTS}
$(foreach v,$^, \
$(v) -A -l $(top_srcdir) -q -T --nointeract >$(v).out; \
diff $(top_srcdir)/$(v).expect $(v).out; )

testlibgap: tst/testlibgap/basic
tst/testlibgap/basic -A -l $(top_srcdir) -m 32m -q -T --nointeract > basic.out
diff $(top_srcdir)/tst/testlibgap/basic.expect basic.out
rm -f basic.out
# this is to make sure wscreate is run before wsload : order-only dependence.
tst/testlibgap/wsload: | tst/testlibgap/wscreate

.PHONY: testlibgap testlibgapws
.PHONY: testlibgap

coverage:
gcov -o . $(SOURCES)
Expand Down
4 changes: 3 additions & 1 deletion tst/testlibgap/wscreate.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Small program to test libgap linkability and basic working
* Small program to test libgap ability to save workspaces.
* Ought to be used with wsload.c
*/
#include "common.h"
int main(int argc, char ** argv)
Expand All @@ -11,6 +12,7 @@ int main(int argc, char ** argv)
test_eval("b:=g.2;");
test_eval("lis:=[a^2, a^2, b*a];");
test_eval("h:=g/lis;");
/* TODO: use unique temporary filename to avoid a race */
test_eval("SaveWorkspace(\"/tmp/libgap.ws\");\n");
printf("# done\n");
return 0;
Expand Down
File renamed without changes.
12 changes: 10 additions & 2 deletions tst/testlibgap/wsload.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
/*
* Small program to test libgap ability to save workspaces
* Small program to test libgap ability to load workspaces.
* Also shows how to directly pass command line arguments to libgap.
*/
#include "common.h"
int main(int argc, char ** argv)
{
GAP_Initialize(argc, argv, environ, 0L, 0L);
char *args[50];
char lpar[3] = "-L";
char wsname[16] = "/tmp/libgap.ws"; /* the name must match the one used in wscreate.c */
memcpy(args, argv, argc*sizeof(char*));
args[argc] = lpar;
args[argc+1] = wsname;
args[argc+2] = NULL;
GAP_Initialize(argc+2, args, environ, 0L, 0L);
printf("# looking at saved stuff...\n");
test_eval("g;");
test_eval("a;");
Expand Down
File renamed without changes.

0 comments on commit a6e47a1

Please sign in to comment.