#!/bin/env python '''Testlet to run the EQRM 'test_all.py' script.''' import os import time import test_utils as util name = 'Running EQRM test_all.py' def test(logfile): result = True (cluster, domain) = util.get_hostname() # get python to run python_env_var = os.getenv('PYTHON') # remember the directory we are in and go to EQRM test directory home_directory = os.getcwd() eqrm_path = os.getenv('EQRMPATH') if not eqrm_path: util.log_print_nl(logfile, "The EQRMPATH environment variable not set, " "can't test EQRM.") return False os.chdir(os.path.join(eqrm_path)) print 'in %s' % os.getcwd() # run clean_all.py util.log_print_nl(logfile, '%s clean_all.py' % python_env_var) (fd_in, fd_out) = os.popen4('%s clean_all.py' % python_env_var) fd_in.write('y\n') fd_in.close() clean_result = fd_out.read() fd_out.close() util.log_print(logfile, clean_result) # run test_all.py util.log_print_nl(logfile, '%s test_all.py' % python_env_var) (_, fd_out) = os.popen4('%s test_all.py' % python_env_var) test_result = fd_out.read() status = fd_out.close() util.log_print(logfile, test_result) # return to original directory os.chdir(home_directory) return result if __name__ == '__main__': import sys home_directory = os.getcwd() logfile = os.path.join(home_directory, 'test.log') if len(sys.argv) > 1: logfile = sys.argv[1] try: os.remove(logfile) except: pass if not test(logfile): sys.exit(10) sys.exit(0)