source: misc/tools/acceptance_tests/test_all.py @ 7662

Last change on this file since 7662 was 7662, checked in by gray, 14 years ago

remove prompt in acceptance tests

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