~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to build/run_tests.py

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
34
36
            <prog ...>
35
37
 
43
45
'''
44
46
 
45
47
# A few useful constants
46
 
SVN_VER_MINOR = 8
 
48
SVN_VER_MINOR = 9
47
49
 
48
 
import os, re, subprocess, sys, imp, threading
 
50
import os, re, subprocess, sys, imp, threading, traceback, exceptions
49
51
from datetime import datetime
50
52
 
51
53
import getopt
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,
128
 
               http_proxy=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.
130
136
 
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.
146
154
    '''
147
155
    self.srcdir = abs_srcdir
148
156
    self.builddir = abs_builddir
178
186
    self.log = None
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)
 
198
 
 
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'
 
203
    else:
 
204
      self.fsfs_version = None
183
205
 
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')
188
210
    failed = 0
 
211
 
 
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)
 
218
 
189
219
    for cnt, prog in enumerate(list):
190
220
      failed = self._run_test(prog, cnt, len(list)) or failed
191
221
 
347
377
    if self.list_tests and self.milestone_filter:
348
378
      print 'WARNING: --milestone-filter option does not currently work with C tests'
349
379
 
350
 
    if os.access(progbase, os.X_OK):
351
 
      progname = './' + progbase
352
 
      cmdline = [progname,
353
 
                 '--srcdir=' + os.path.join(self.srcdir, progdir)]
354
 
      if self.config_file is not None:
355
 
        cmdline.append('--config-file=' + self.config_file)
356
 
    else:
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)
358
382
      sys.exit(1)
359
383
 
 
384
    progname = './' + progbase
 
385
    cmdline = [progname,
 
386
               '--srcdir=' + os.path.join(self.srcdir, progdir)]
 
387
    if self.config_file is not None:
 
388
      cmdline.append('--config-file=' + self.config_file)
 
389
 
 
390
    if self.base_url is not None:
 
391
      subdir = 'subversion/tests/cmdline/svn-test-work'
 
392
 
 
393
      cmdline.append('--repos-url=%s' % self.base_url +
 
394
                        '/svn-test-work/repositories')
 
395
      cmdline.append('--repos-dir=%s'
 
396
                     % os.path.abspath(
 
397
                         os.path.join(self.builddir, subdir, 'repositories')))
 
398
 
 
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'
 
405
                                                            '* = rw\n')
 
406
 
 
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')
372
424
 
373
425
    if test_nums:
374
426
      test_nums = test_nums.split(',')
433
485
      prog_mod = imp.load_module(progbase[:-3], open(prog, 'r'), prog,
434
486
                                 ('.py', 'U', imp.PY_SOURCE))
435
487
    except:
436
 
      print("Don't know what to do about " + progbase)
 
488
      print("\nError loading test (details in following traceback): " + progbase)
 
489
      traceback.print_exc()
437
490
      sys.exit(1)
438
491
 
439
492
    import svntest.main
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
 
501
      try:
 
502
        num_parallel = int(self.parallel)
 
503
      except exceptions.ValueError:
 
504
        num_parallel = svntest.main.default_num_threads
 
505
      if num_parallel > 1:
 
506
        svntest.main.options.parallel = num_parallel
 
507
      else:
 
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
484
558
 
485
559
    svntest.main.options.srcdir = self.srcdir
486
560
 
550
624
 
551
625
    return failed
552
626
 
 
627
  def _split_nums(self, prog):
 
628
    test_nums = None
 
629
    if '#' in prog:
 
630
      prog, test_nums = prog.split('#')
 
631
    return prog, test_nums
 
632
 
553
633
  def _run_test(self, prog, test_nr, total_tests):
554
634
    "Run a single test. Return the test's exit code."
555
635
 
558
638
    else:
559
639
      log = sys.stdout
560
640
 
561
 
    test_nums = None
562
 
    if '#' in prog:
563
 
      prog, test_nums = prog.split('#')
564
 
 
 
641
    prog, test_nums = self._split_nums(prog)
565
642
    progdir, progbase = os.path.split(prog)
566
643
    if self.log:
567
644
      # Using write here because we don't want even a trailing space
640
717
  try:
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=',
648
 
                            'http-proxy='])
 
727
                            'http-proxy=', 'http-proxy-username=',
 
728
                            'http-proxy-password=', 'httpd-version=',
 
729
                            'exclusive-wc-locks',
 
730
                            'memcached-server='])
649
731
  except getopt.GetoptError:
650
732
    args = []
651
733
 
653
735
    print(__doc__)
654
736
    sys.exit(2)
655
737
 
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']:
664
749
      base_url = val
676
761
      verbose = 1
677
762
    elif opt in ['-c', '--cleanup']:
678
763
      cleanup = 1
 
764
    elif opt in ['--skip-c-tests', '--skip-C-tests']:
 
765
      skip_c_tests = 1
 
766
    elif opt in ['--dump-load-cross-check']:
 
767
      dump_load_cross_check = 1
679
768
    elif opt in ['--enable-sasl']:
680
769
      enable_sasl = 1
681
770
    elif opt in ['--parallel']:
682
 
      parallel = 1
 
771
      parallel = val
683
772
    elif opt in ['--config-file']:
684
773
      config_file = val
685
774
    elif opt in ['--log-to-stdout']:
696
785
      ssl_cert = val
697
786
    elif opt in ['--http-proxy']:
698
787
      http_proxy = val
 
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']:
 
793
      httpd_version = val
 
794
    elif opt in ['--exclusive-wc-locks']:
 
795
      exclusive_wc_locks = 1
 
796
    elif opt in ['--memcached-server']:
 
797
      memcached_server = val
699
798
    else:
700
799
      raise getopt.GetoptError
701
800
 
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)
716
822
 
717
823
  failed = th.run(args[2:])
718
824
  if failed: