Execute tests after scanning, from toplevel directory

As a preparation to running the tests in parallel, change things
around on two points:

* The test scanning is a separate phase, and only gathers the list of
  things to do.

* When we run the tests, we do not use chdir() (outside system()
  anyway) any more.

This is needed because all threads will share the same current
directory, so they cannot use chdir().
Implement threaded regression tests

We just need to make sure we share the main test queue and all the
output data.