Add simple tool for automatic test discovery

tools/discover.c contains a simple tool which scans for test cases and
generates a test runner.