run test executable through gdb always, on travis

We keep getting segfaults that don't reproduce the second time it
is run, so maybe this will catch them.

It also moves the test execution code out into a script.