1let
2 testString = "can-use-subgroups";
3in
4{
5 pkgs,
6 lib,
7 php,
8 ...
9}:
10{
11 name = "php-${php.version}-httpd-pcre-jit-test";
12 meta.maintainers = lib.teams.php.members;
13
14 nodes.machine =
15 { pkgs, ... }:
16 {
17 time.timeZone = "UTC";
18 services.httpd = {
19 enable = true;
20 adminAddr = "please@dont.contact";
21 phpPackage = php;
22 enablePHP = true;
23 phpOptions = "pcre.jit = true";
24 extraConfig =
25 let
26 testRoot = pkgs.writeText "index.php" ''
27 <?php
28 preg_match('/(${testString})/', '${testString}', $result);
29 var_dump($result);
30 '';
31 in
32 ''
33 Alias / ${testRoot}/
34
35 <Directory ${testRoot}>
36 Require all granted
37 </Directory>
38 '';
39 };
40 };
41 testScript =
42 let
43 # PCRE JIT SEAlloc feature does not play well with fork()
44 # The feature needs to either be disabled or PHP configured correctly
45 # More information in https://bugs.php.net/bug.php?id=78927 and https://bugs.php.net/bug.php?id=78630
46 pcreJitSeallocForkIssue = pkgs.writeText "pcre-jit-sealloc-issue.php" ''
47 <?php
48 preg_match('/nixos/', 'nixos');
49 $pid = pcntl_fork();
50 pcntl_wait($pid);
51 '';
52 in
53 ''
54 machine.wait_for_unit("httpd.service")
55 # Ensure php evaluation by matching on the var_dump syntax
56 response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/index.php")
57 expected = 'string(${toString (builtins.stringLength testString)}) "${testString}"'
58 assert expected in response, "Does not appear to be able to use subgroups."
59 machine.succeed("${php}/bin/php -f ${pcreJitSeallocForkIssue}")
60 '';
61}