Changeset 5f0e94b in mod_gnutls
- Timestamp:
- Nov 29, 2020, 5:08:41 AM (18 months ago)
- Branches:
- master
- Children:
- 663f975
- Parents:
- 9231a4d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/runtest.py
r9231a4d r5f0e94b 20 20 import itertools 21 21 import os 22 import os.path23 22 import subprocess 24 23 import sys 25 24 import tempfile 26 25 import yaml 26 from pathlib import Path 27 27 from unittest import SkipTest 28 28 … … 41 41 42 42 """ 43 with os.scandir(dir) as it: 44 found = None 45 for entry in it: 46 if entry.is_dir(): 47 num = int(entry.name.split('_', maxsplit=1)[0]) 48 if number == num: 49 if found: 50 # duplicate numbers are an error 51 raise LookupError('Multiple directories found for ' 52 f'test number {number}: ' 53 f'{found.name} and {entry.name}') 54 else: 55 found = entry 56 if found is None: 57 raise LookupError('No test directory found for test number ' 58 f'{number}!') 59 else: 60 return (found.path, found.name) 43 found = None 44 for entry in dir.iterdir(): 45 if entry.is_dir(): 46 num = int(entry.name.split('_', maxsplit=1)[0]) 47 if number == num: 48 if found: 49 # duplicate numbers are an error 50 raise LookupError('Multiple directories found for ' 51 f'test number {number}: ' 52 f'{found.name} and {entry.name}') 53 else: 54 found = entry 55 if found is None: 56 raise LookupError('No test directory found for test number ' 57 f'{number}!') 58 return found, found.name 61 59 62 60 … … 92 90 # The Automake environment always provides srcdir, the default is 93 91 # for manual use. 94 srcdir = os.path.realpath(os.environ.get('srcdir', '.'))92 srcdir = Path(os.environ.get('srcdir', '.')).resolve() 95 93 # ensure environment srcdir is absolute 96 os.environ['srcdir'] = s rcdir94 os.environ['srcdir'] = str(srcdir) 97 95 98 96 # Find the configuration directory for the test in 99 97 # ${srcdir}/tests/, based on the test number. 100 testdir, testname = find_testdir(args.test_number, 101 os.path.join(srcdir, 'tests')) 98 testdir, testname = find_testdir(args.test_number, srcdir / 'tests') 102 99 print(f'Found test {testname}, test dir is {testdir}') 103 100 os.environ['TEST_NAME'] = testname … … 105 102 # Load test config 106 103 try: 107 with open( os.path.join(testdir, 'test.yaml'), 'r') as conf_file:104 with open(testdir / 'test.yaml', 'r') as conf_file: 108 105 test_conf = yaml.load(conf_file, Loader=yaml.Loader) 109 106 except FileNotFoundError: … … 111 108 112 109 # Load test case hooks (if any) 113 plugin_path = os.path.join(testdir, 'hooks.py') 114 plugin = mgstest.hooks.load_hooks_plugin(plugin_path) 110 plugin = mgstest.hooks.load_hooks_plugin(testdir / 'hooks.py') 115 111 116 112 # PID file name varies depending on whether we're using … … 124 120 valgrind_log = None 125 121 if args.valgrind: 126 valgrind_log = os.path.join('logs', f'valgrind-{testname}.log')122 valgrind_log = Path('logs', f'valgrind-{testname}.log') 127 123 128 124 # Define the available services 129 apache = ApacheService(config= os.path.join(testdir, 'apache.conf'),125 apache = ApacheService(config=testdir / 'apache.conf', 130 126 pidfile=f'apache2{pidaffix}.pid', 131 127 valgrind_log=valgrind_log, 132 128 valgrind_suppress=args.valgrind_suppressions) 133 backend = ApacheService(config= os.path.join(testdir, 'backend.conf'),129 backend = ApacheService(config=testdir / 'backend.conf', 134 130 pidfile=f'backend{pidaffix}.pid') 135 ocsp = ApacheService(config= os.path.join(testdir, 'ocsp.conf'),131 ocsp = ApacheService(config=testdir / 'ocsp.conf', 136 132 pidfile=f'ocsp{pidaffix}.pid', 137 133 check=check_ocsp_responder) … … 183 179 await service_stack.enter_async_context(apache.run()) 184 180 failed = await apache.wait_ready() 185 if os.path.exists(os.path.join(testdir, 'fail.server')):181 if (testdir / 'fail.server').is_file(): 186 182 if failed: 187 183 print('Apache server failed to start as expected',
Note: See TracChangeset
for help on using the changeset viewer.