| 12 | |
| 13 | |
| 14 | class H1TestSetup(HttpdTestSetup): |
| 15 | |
| 16 | def __init__(self, env: 'HttpdTestEnv'): |
| 17 | super().__init__(env=env) |
| 18 | self.add_source_dir(os.path.dirname(inspect.getfile(H1TestSetup))) |
| 19 | self.add_modules(["cgid", "autoindex", "ssl"]) |
| 20 | |
| 21 | def make(self): |
| 22 | super().make() |
| 23 | self._add_h1test() |
| 24 | self._setup_data_1k_1m() |
| 25 | |
| 26 | def _add_h1test(self): |
| 27 | local_dir = os.path.dirname(inspect.getfile(H1TestSetup)) |
| 28 | p = subprocess.run([self.env.apxs, '-c', 'mod_h1test.c'], |
| 29 | capture_output=True, |
| 30 | cwd=os.path.join(local_dir, 'mod_h1test')) |
| 31 | rv = p.returncode |
| 32 | if rv != 0: |
| 33 | log.error(f"compiling md_h1test failed: {p.stderr}") |
| 34 | raise Exception(f"compiling md_h1test failed: {p.stderr}") |
| 35 | |
| 36 | modules_conf = os.path.join(self.env.server_dir, 'conf/modules.conf') |
| 37 | with open(modules_conf, 'a') as fd: |
| 38 | # load our test module which is not installed |
| 39 | fd.write(f"LoadModule h1test_module \"{local_dir}/mod_h1test/.libs/mod_h1test.so\"\n") |
| 40 | |
| 41 | def _setup_data_1k_1m(self): |
| 42 | s90 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\n" |
| 43 | with open(os.path.join(self.env.gen_dir, "data-1k"), 'w') as f: |
| 44 | for i in range(10): |
| 45 | f.write(f"{i:09d}-{s90}") |
| 46 | with open(os.path.join(self.env.gen_dir, "data-10k"), 'w') as f: |
| 47 | for i in range(100): |
| 48 | f.write(f"{i:09d}-{s90}") |
| 49 | with open(os.path.join(self.env.gen_dir, "data-100k"), 'w') as f: |
| 50 | for i in range(1000): |
| 51 | f.write(f"{i:09d}-{s90}") |
| 52 | with open(os.path.join(self.env.gen_dir, "data-1m"), 'w') as f: |
| 53 | for i in range(10000): |
| 54 | f.write(f"{i:09d}-{s90}") |
| 55 | |
| 56 | |
| 57 | class H1TestEnv(HttpdTestEnv): |