29
29
[--fs-type=<fs-type>] [--fsfs-packing] [--fsfs-sharding=<n>]
30
30
[--list] [--milestone-filter=<regex>] [--mode-filter=<type>]
31
31
[--server-minor-version=<version>] [--http-proxy=<host>:<port>]
32
[--httpd-version=<version>]
32
33
[--config-file=<file>] [--ssl-cert=<file>]
34
[--exclusive-wc-locks] [--memcached-server=<url:port>]
33
35
<abs_srcdir> <abs_builddir>
45
47
# A few useful constants
48
import os, re, subprocess, sys, imp, threading
50
import os, re, subprocess, sys, imp, threading, traceback, exceptions
49
51
from datetime import datetime
125
127
fsfs_sharding=None, fsfs_packing=None,
126
128
list_tests=None, svn_bin=None, mode_filter=None,
127
129
milestone_filter=None, set_log_level=None, ssl_cert=None,
130
http_proxy=None, http_proxy_username=None,
131
http_proxy_password=None, httpd_version=None,
132
exclusive_wc_locks=None,
133
memcached_server=None, skip_c_tests=None,
134
dump_load_cross_check=None):
129
135
'''Construct a TestHarness instance.
131
137
ABS_SRCDIR and ABS_BUILDDIR are the source and build directories.
143
149
in conjunction with LIST_TESTS, the only tests that are listed are
144
150
those with an associated issue in the tracker which has a target
145
151
milestone that matches the regex.
152
HTTP_PROXY (hostname:port), HTTP_PROXY_USERNAME and HTTP_PROXY_PASSWORD
153
define the params to run the tests over a proxy server.
147
155
self.srcdir = abs_srcdir
148
156
self.builddir = abs_builddir
179
187
self.ssl_cert = ssl_cert
180
188
self.http_proxy = http_proxy
189
self.http_proxy_username = http_proxy_username
190
self.http_proxy_password = http_proxy_password
191
self.httpd_version = httpd_version
192
self.exclusive_wc_locks = exclusive_wc_locks
193
self.memcached_server = memcached_server
181
194
if not sys.stdout.isatty() or sys.platform == 'win32':
182
195
TextColors.disable()
196
self.skip_c_tests = (not not skip_c_tests)
197
self.dump_load_cross_check = (not not dump_load_cross_check)
199
# Parse out the FSFS version number
200
if self.fs_type is not None and self.fs_type.startswith('fsfs-v'):
201
self.fsfs_version = int(self.fs_type[6:])
202
self.fs_type = 'fsfs'
204
self.fsfs_version = None
184
206
def run(self, list):
185
207
'''Run all test programs given in LIST. Print a summary of results, if
186
208
there is a log file. Return zero iff all test programs passed.'''
187
209
self._open_log('w')
212
# If asked to skip C tests, remove non-Python tests from the list
213
if self.skip_c_tests:
214
def is_py_test(prog):
215
progpath, nums = self._split_nums(prog)
216
return progpath.endswith('.py')
217
list = filter(is_py_test, list)
189
219
for cnt, prog in enumerate(list):
190
220
failed = self._run_test(prog, cnt, len(list)) or failed
347
377
if self.list_tests and self.milestone_filter:
348
378
print 'WARNING: --milestone-filter option does not currently work with C tests'
350
if os.access(progbase, os.X_OK):
351
progname = './' + progbase
353
'--srcdir=' + os.path.join(self.srcdir, progdir)]
354
if self.config_file is not None:
355
cmdline.append('--config-file=' + self.config_file)
357
print("Don't know what to do about " + progbase)
380
if not os.access(progbase, os.X_OK):
381
print("\nNot an executable file: " + progbase)
384
progname = './' + progbase
386
'--srcdir=' + os.path.join(self.srcdir, progdir)]
387
if self.config_file is not None:
388
cmdline.append('--config-file=' + self.config_file)
390
if self.base_url is not None:
391
subdir = 'subversion/tests/cmdline/svn-test-work'
393
cmdline.append('--repos-url=%s' % self.base_url +
394
'/svn-test-work/repositories')
395
cmdline.append('--repos-dir=%s'
397
os.path.join(self.builddir, subdir, 'repositories')))
399
# Enable access for http
400
if self.base_url.startswith('http'):
401
authzparent = os.path.join(self.builddir, subdir)
402
if not os.path.exists(authzparent):
403
os.makedirs(authzparent);
404
open(os.path.join(authzparent, 'authz'), 'w').write('[/]\n'
407
# ### Support --repos-template
360
408
if self.verbose is not None:
361
409
cmdline.append('--verbose')
362
410
if self.cleanup is not None:
363
411
cmdline.append('--cleanup')
364
412
if self.fs_type is not None:
365
413
cmdline.append('--fs-type=' + self.fs_type)
414
if self.fsfs_version is not None:
415
cmdline.append('--fsfs-version=%d' % self.fsfs_version)
366
416
if self.server_minor_version is not None:
367
417
cmdline.append('--server-minor-version=' + self.server_minor_version)
368
418
if self.list_tests is not None:
369
419
cmdline.append('--list')
370
420
if self.mode_filter is not None:
371
421
cmdline.append('--mode-filter=' + self.mode_filter)
422
if self.parallel is not None:
423
cmdline.append('--parallel')
374
426
test_nums = test_nums.split(',')
445
498
if self.enable_sasl is not None:
446
499
svntest.main.options.enable_sasl = True
447
500
if self.parallel is not None:
448
svntest.main.options.parallel = svntest.main.default_num_threads
502
num_parallel = int(self.parallel)
503
except exceptions.ValueError:
504
num_parallel = svntest.main.default_num_threads
506
svntest.main.options.parallel = num_parallel
508
svntest.main.options.parallel = svntest.main.default_num_threads
449
509
if self.config_file is not None:
450
510
svntest.main.options.config_file = self.config_file
451
511
if self.verbose is not None:
454
514
svntest.main.options.cleanup = True
455
515
if self.fs_type is not None:
456
516
svntest.main.options.fs_type = self.fs_type
517
if self.fsfs_version is not None:
518
svntest.main.options.fsfs_version = self.fsfs_version
457
519
if self.http_library is not None:
458
520
svntest.main.options.http_library = self.http_library
459
521
if self.server_minor_version is not None:
481
543
svntest.main.options.ssl_cert = self.ssl_cert
482
544
if self.http_proxy is not None:
483
545
svntest.main.options.http_proxy = self.http_proxy
546
if self.http_proxy_username is not None:
547
svntest.main.options.http_proxy_username = self.http_proxy_username
548
if self.http_proxy_password is not None:
549
svntest.main.options.http_proxy_password = self.http_proxy_password
550
if self.httpd_version is not None:
551
svntest.main.options.httpd_version = self.httpd_version
552
if self.exclusive_wc_locks is not None:
553
svntest.main.options.exclusive_wc_locks = self.exclusive_wc_locks
554
if self.memcached_server is not None:
555
svntest.main.options.memcached_server = self.memcached_server
556
if self.dump_load_cross_check is not None:
557
svntest.main.options.dump_load_cross_check = self.dump_load_cross_check
485
559
svntest.main.options.srcdir = self.srcdir
641
718
opts, args = my_getopt(sys.argv[1:], 'u:f:vc',
642
719
['url=', 'fs-type=', 'verbose', 'cleanup',
720
'skip-c-tests', 'skip-C-tests',
721
'dump-load-cross-check',
643
722
'http-library=', 'server-minor-version=',
644
723
'fsfs-packing', 'fsfs-sharding=',
645
'enable-sasl', 'parallel', 'config-file=',
724
'enable-sasl', 'parallel=', 'config-file=',
646
725
'log-to-stdout', 'list', 'milestone-filter=',
647
726
'mode-filter=', 'set-log-level=', 'ssl-cert=',
727
'http-proxy=', 'http-proxy-username=',
728
'http-proxy-password=', 'httpd-version=',
729
'exclusive-wc-locks',
730
'memcached-server='])
649
731
except getopt.GetoptError:
656
base_url, fs_type, verbose, cleanup, enable_sasl, http_library, \
657
server_minor_version, fsfs_sharding, fsfs_packing, parallel, \
658
config_file, log_to_stdout, list_tests, mode_filter, milestone_filter, \
659
set_log_level, ssl_cert, http_proxy = \
660
None, None, None, None, None, None, None, None, None, None, None, \
661
None, None, None, None, None, None, None
738
base_url, fs_type, verbose, cleanup, skip_c_tests, enable_sasl, \
739
http_library, server_minor_version, fsfs_sharding, fsfs_packing, \
740
parallel, config_file, log_to_stdout, list_tests, mode_filter, \
741
milestone_filter, set_log_level, ssl_cert, http_proxy, \
742
http_proxy_username, http_proxy_password, httpd_version, \
743
exclusive_wc_locks, memcached_server, dump_load_cross_check = \
744
None, None, None, None, None, None, None, None, None, None, \
745
None, None, None, None, None, None, None, None, None, None, \
746
None, None, None, None, None
662
747
for opt, val in opts:
663
748
if opt in ['-u', '--url']:
677
762
elif opt in ['-c', '--cleanup']:
764
elif opt in ['--skip-c-tests', '--skip-C-tests']:
766
elif opt in ['--dump-load-cross-check']:
767
dump_load_cross_check = 1
679
768
elif opt in ['--enable-sasl']:
681
770
elif opt in ['--parallel']:
683
772
elif opt in ['--config-file']:
684
773
config_file = val
685
774
elif opt in ['--log-to-stdout']:
697
786
elif opt in ['--http-proxy']:
788
elif opt in ['--http-proxy-username']:
789
http_proxy_username = val
790
elif opt in ['--http-proxy-password']:
791
http_proxy_password = val
792
elif opt in ['--httpd-version']:
794
elif opt in ['--exclusive-wc-locks']:
795
exclusive_wc_locks = 1
796
elif opt in ['--memcached-server']:
797
memcached_server = val
700
799
raise getopt.GetoptError
712
811
fsfs_sharding, fsfs_packing, list_tests,
713
812
mode_filter=mode_filter, milestone_filter=milestone_filter,
714
813
set_log_level=set_log_level, ssl_cert=ssl_cert,
715
http_proxy=http_proxy)
814
http_proxy=http_proxy,
815
http_proxy_username=http_proxy_username,
816
http_proxy_password=http_proxy_password,
817
httpd_version=httpd_version,
818
exclusive_wc_locks=exclusive_wc_locks,
819
memcached_server=memcached_server,
820
skip_c_tests=skip_c_tests,
821
dump_load_cross_check=dump_load_cross_check)
717
823
failed = th.run(args[2:])