| 209 | |
| 210 | |
| 211 | class HttpdTestEnv: |
| 212 | |
| 213 | LIBEXEC_DIR = None |
| 214 | |
| 215 | @classmethod |
| 216 | def has_python_package(cls, name: str) -> bool: |
| 217 | if name in sys.modules: |
| 218 | # already loaded |
| 219 | return True |
| 220 | elif (spec := importlib.util.find_spec(name)) is not None: |
| 221 | module = importlib.util.module_from_spec(spec) |
| 222 | sys.modules[name] = module |
| 223 | spec.loader.exec_module(module) |
| 224 | return True |
| 225 | else: |
| 226 | return False |
| 227 | |
| 228 | @classmethod |
| 229 | def get_ssl_module(cls): |
| 230 | return os.environ['SSL'] if 'SSL' in os.environ else 'mod_ssl' |
| 231 | |
| 232 | @classmethod |
| 233 | def has_shared_module(cls, name): |
| 234 | if cls.LIBEXEC_DIR is None: |
| 235 | env = HttpdTestEnv() # will initialized it |
| 236 | path = os.path.join(cls.LIBEXEC_DIR, f"mod_{name}.so") |
| 237 | return os.path.isfile(path) |
| 238 | |
| 239 | def __init__(self, pytestconfig=None): |
| 240 | self._our_dir = os.path.dirname(inspect.getfile(Dummy)) |
| 241 | self.config = ConfigParser(interpolation=ExtendedInterpolation()) |
| 242 | self.config.read(os.path.join(self._our_dir, 'config.ini')) |
| 243 | |
| 244 | self._bin_dir = self.config.get('global', 'bindir') |
| 245 | self._apxs = self.config.get('global', 'apxs') |
| 246 | self._prefix = self.config.get('global', 'prefix') |
| 247 | self._apachectl = self.config.get('global', 'apachectl') |
| 248 | if HttpdTestEnv.LIBEXEC_DIR is None: |
| 249 | HttpdTestEnv.LIBEXEC_DIR = self._libexec_dir = self.get_apxs_var('LIBEXECDIR') |
| 250 | self._curl = self.config.get('global', 'curl_bin') |
| 251 | if 'CURL' in os.environ: |
| 252 | self._curl = os.environ['CURL'] |
| 253 | self._nghttp = self.config.get('global', 'nghttp') |
| 254 | if self._nghttp is None: |
| 255 | self._nghttp = 'nghttp' |
| 256 | self._h2load = self.config.get('global', 'h2load') |
| 257 | if self._h2load is None: |
| 258 | self._h2load = 'h2load' |
| 259 | |
| 260 | self._http_port = int(self.config.get('test', 'http_port')) |
| 261 | self._http_port2 = int(self.config.get('test', 'http_port2')) |
| 262 | self._https_port = int(self.config.get('test', 'https_port')) |
| 263 | self._proxy_port = int(self.config.get('test', 'proxy_port')) |
| 264 | self._ws_port = int(self.config.get('test', 'ws_port')) |
| 265 | self._http_tld = self.config.get('test', 'http_tld') |
| 266 | self._test_dir = self.config.get('test', 'test_dir') |
| 267 | self._clients_dir = os.path.join(os.path.dirname(self._test_dir), 'clients') |
| 268 | self._gen_dir = self.config.get('test', 'gen_dir') |
no outgoing calls