source: branches/numpy_misc/tools/acceptance_tests/test_all.py @ 7017

Last change on this file since 7017 was 7017, checked in by rwilson, 15 years ago

Improved reporting.

  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/bin/env python
2
3'''Run all acceptance tests in order.'''
4
5import os
6import sys
7import time
8import shutil
9import test_utils as util
10
11
12# the test files, in desired order
13Tests = ['test_dump_python_environment.py',
14         'test_python_packages.py',
15         'test_filesystem_accessibility.py',
16         'test_ssh_to_compute_nodes.py',
17         'test_quadrature_parallel_interleaved.py',
18         'test_latency_bandwidth.py',
19         'test_test_pypar.py',
20         'test_test_all.py']
21
22
23if __name__ == '__main__':
24    home_directory = os.getcwd()
25    logfile = os.path.join(home_directory, 'test.log')
26    if len(sys.argv) > 1:
27        logfile = sys.argv[1]
28
29    try:
30        os.remove(logfile)
31    except:
32        pass
33
34    # make sure we are running on a cluster machine
35    (hostname, _) = util.get_hostname()
36    cluster_info = util.get_cluster_info(hostname)
37    if cluster_info is None:
38        util.log_print_nl(logfile,
39                          'Sorry, you must be running on a cluster master node.')
40        util.log_print_nl(logfile, "You are on machine '%s'." % hostname)
41        sys.exit(10)
42
43    # copy machines_<name> files from here to ~
44    home = os.getenv('HOME')
45    if not home:
46        util.log_print_nl(logfile, "Sorry, you don't have the 'HOME' environment variable set.")
47        sys.exit(10)
48    machine_file = 'machines_%s' % hostname
49    shutil.copyfile(machine_file, os.path.join(home, '.'+machine_file))
50
51    # make sure environment variables are set
52    python = os.getenv('PYTHON')
53    pythonpath = os.getenv('PYTHONPATH')
54    if not python or not pythonpath:
55        if not python:
56            util.log_print_nl(logfile, 'Sorry, you must set the PYTHON environment variable.')
57        if not pythonpath:
58            util.log_print_nl(logfile, 'Sorry, you must set the PYTHONPATH environment variable.')
59        sys.exit(10)
60
61    # make sure all OK with user
62    print '*' * 80
63    print '* Acceptance test for %s cluster' % hostname
64    print '*' * 80
65    print ''
66    print 'PYTHON=%s' % python
67    print 'PYTHONPATH=%s' % pythonpath
68    print ''
69    res = raw_input('This test will run with the above environment variables, OK? ')
70    if res[0].upper() != 'Y':
71        sys.exit(10)
72    print ''
73
74    # put header on log
75    util.log_nl(logfile, '#' * 80)
76    util.log_nl(logfile, '# Acceptance test of cluster %s' % hostname)
77    util.log_nl(logfile, '#' * 80)
78    util.log_nl(logfile)
79
80    # run the tests
81    for test_module in Tests:
82        (import_name, _) = test_module.split('.', 1)
83        import_code = 'import %s as test' % import_name
84
85        exec import_code
86
87        start_time = time.time()
88        test_name = test.name
89        util.header(logfile, test_module, '%s on %s.' % (test_name, hostname))
90        #test_code = ("test.test('%s')" % logfile)
91
92        test.test(logfile)
93        #exec test_code
94
95        util.footer(logfile, start_time)
Note: See TracBrowser for help on using the repository browser.