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

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

acceptance test update - for current acceptance testing.

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