# mysql-test-check.py # Python script to gather all tests for a MySQL tree, # execute them, and observe if any tests fail to clean up after themselves. # input: source tree to test # python mysql-test-check.py (symbolic links accepted) # TODO: allow options to be passed such as --skip-ndb, --skip-rpl,etc # output: list of tests that failed check # TODO: allow for varying levels of output such as --check output being included. # imports import sys import os # functions def get_tests(): test_catalog = [] # populate main test_catalog = test_catalog + test_cat('',"./mysql-test/t") # check suites for suite in os.listdir("./mysql-test/suite"): test_path = "./mysql-test/suite/"+suite+"/t" test_catalog = test_catalog + test_cat(suite,test_path) return test_catalog def test_cat(suite,test_path): test_list = [] for test in os.listdir(test_path): if ".test" in test: test_list.append((suite,test)) return test_list def run_test(root_dir, suite, test_name): result = '' start_dir = os.getcwd() os.chdir("mysql-test") cmd = "./mysql-test-run.pl --force --big --check " if suite != '': cmd = cmd + "--suite=" + suite + " " cmd = cmd + test_name test_data = os.popen(cmd) result = check_data(test_data) if result != '' : print suite, test_name, "[ fail ]" else: print suite, test_name, "[ pass ]" os.chdir(start_dir) def check_data(test_data): for line in test_data: if "Check of testcase failed" in line: return line return '' # main args = sys.argv[1:] if len(args) < 1: print "ERROR: requires one argument" print "example: python mysql-test-check.py " sys.exit() root_dir = args[0] # check validity of root_dir if not os.path.isdir(root_dir): print "ERROR: start directory not a directory" else: os.chdir(root_dir) for test_info in get_tests(): run_test(root_dir, test_info[0], test_info[1])