source: trunk/misc/tools/acceptance_tests/test_all.py @ 7904

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

comments

  • Property svn:executable set to *
File size: 3.9 KB
Line 
1#!/bin/env python
2
3"""Run all acceptance tests in order.
4
5Currently runing with;
6python test_all.py cyclone_log_short2.asc *> cyclone_log_long2.asc
7
8To capture the output.  EQRM unit test info is going to screen.
9Do not know why.
10
11"""
12
13import os
14import sys
15import time
16import shutil
17import test_utils as util
18
19# 'test_inter_latency.py' - not needed
20# 'test_validation_anuga.py' - This might take days apparently.
21# Not the test for us.
22
23#         'test_ssh_to_compute_nodes.py', this relies on the internal
24# structure of test_utils, which is a complication I don't need right now.
25         
26# the test files, in desired order
27Tests = ['test_test_all.py',
28         'test_eqrm.py',
29         'test_dump_python_environment.py',
30         'test_python_packages.py',
31         'test_filesystem_accessibility.py',
32         'test_quadrature_parallel_interleaved.py',
33         'test_latency_bandwidth.py',
34         #'test_test_pypar.py'
35        ]
36# Note, test_test_pypar.py is not working in this script,
37# but is working as a stand-alone.
38#Tests += ['test_more_python_packages.py']
39if __name__ == '__main__':
40    home_directory = os.getcwd()
41    logfile = os.path.join(home_directory, 'test.log')
42    if len(sys.argv) > 1:
43        logfile = sys.argv[1]
44
45    try:
46        os.remove(logfile)
47    except:
48        pass
49
50    # make sure we are running on a cluster machine
51    (hostname, _) = util.get_hostname()
52    cluster_info = util.get_cluster_info(hostname)
53    if cluster_info is None:
54        util.log_print_nl(logfile,
55                          'Sorry, you must be running on a cluster master node.')
56        util.log_print_nl(logfile, "You are on machine '%s'." % hostname)
57        sys.exit(10)
58
59##    # copy machines_<name> files from here to ~
60##    home = os.getenv('HOME')
61##    if not home:
62##        util.log_print_nl(logfile, "Sorry, you don't have the 'HOME' environment variable set.")
63##        sys.exit(10)
64##    machine_file = 'machines_%s' % hostname
65##    shutil.copyfile(machine_file, os.path.join(home, '.'+machine_file))
66
67    # make sure environment variables are set
68    python = os.getenv('PYTHON')
69    ANUGAPATH = os.getenv('ANUGAPATH')
70    EQRMPATH = os.getenv('EQRMPATH')
71    if EQRMPATH is None:
72        EQRMPATH = ''
73    if not python or not ANUGAPATH:
74        if not python:
75            util.log_print_nl(logfile, 'Sorry, you must set the PYTHON environment variable.')
76        if not ANUGAPATH:
77            util.log_print_nl(logfile, 'Sorry, you must set the ANUGAPATH environment variable.')
78        sys.exit(10)
79
80    # make sure all OK with user
81    print '*' * 80
82    print '* Acceptance test for %s cluster' % hostname
83    print '*' * 80
84    print ''
85    print 'PYTHON=%s' % python
86    print 'ANUGAPATH=%s' % ANUGAPATH
87    print 'EQRMPATH=%s' % EQRMPATH
88    print ''
89#     res = raw_input('This test will run with the above environment variables, OK? ')
90#     if len(res) == 0 or res[0].upper() != 'Y':
91#         sys.exit(10)
92#     print ''
93
94    # put header on log
95    test_start_time = time.time()
96
97    util.log_nl(logfile, '#' * 80)
98    util.log_nl(logfile, '# Acceptance test of cluster %s' % hostname)
99    util.log_nl(logfile, '#' * 80)
100    util.log_nl(logfile)
101
102    # run the tests
103    for test_module in Tests:
104        (import_name, _) = test_module.split('.', 1)
105        import_code = 'import %s as test' % import_name
106
107        exec import_code
108
109        start_time = time.time()
110        test_name = test.name
111        util.header(logfile, test_module, '%s on %s.' % (test_name, hostname))
112        #test_code = ("test.test('%s')" % logfile)
113
114        test.test(logfile)
115        #exec test_code
116
117        util.footer(logfile, start_time)
118
119    test_stop_time = time.time()
120    test_elapsed_time = test_stop_time - test_start_time
121
122    util.log_nl(logfile)
123    util.log_nl(logfile, '#' * 80)
124    util.log_nl(logfile, '# Acceptance test of cluster %s took %.1fs'
125                         % (hostname, test_elapsed_time))
126    util.log_nl(logfile, '#' * 80)
Note: See TracBrowser for help on using the repository browser.