Extract the generic generation test template to test/test_gen.c