selftest.run: Factor out read_testlist_file and open_file_or_pipe.