2020-03-31 18:06:04 +01:00
|
|
|
let
|
|
|
|
testString = "can-use-subgroups";
|
2021-06-26 08:46:46 +01:00
|
|
|
in
|
2022-11-29 17:36:38 +00:00
|
|
|
import ../make-test-python.nix ({ pkgs, lib, php, ... }: {
|
2021-02-27 18:39:26 +00:00
|
|
|
name = "php-${php.version}-httpd-pcre-jit-test";
|
2020-04-19 19:56:42 +01:00
|
|
|
meta.maintainers = lib.teams.php.members;
|
|
|
|
|
2022-03-20 23:15:30 +00:00
|
|
|
nodes.machine = { lib, pkgs, ... }: {
|
2017-11-12 07:05:27 +00:00
|
|
|
time.timeZone = "UTC";
|
|
|
|
services.httpd = {
|
|
|
|
enable = true;
|
|
|
|
adminAddr = "please@dont.contact";
|
2021-02-27 18:39:26 +00:00
|
|
|
phpPackage = php;
|
2019-08-11 15:03:28 +01:00
|
|
|
enablePHP = true;
|
|
|
|
phpOptions = "pcre.jit = true";
|
2021-06-26 08:46:46 +01:00
|
|
|
extraConfig =
|
|
|
|
let
|
|
|
|
testRoot = pkgs.writeText "index.php"
|
|
|
|
''
|
|
|
|
<?php
|
|
|
|
preg_match('/(${testString})/', '${testString}', $result);
|
|
|
|
var_dump($result);
|
|
|
|
'';
|
|
|
|
in
|
2019-08-11 15:03:28 +01:00
|
|
|
''
|
|
|
|
Alias / ${testRoot}/
|
2017-11-12 07:05:27 +00:00
|
|
|
|
2019-08-11 15:03:28 +01:00
|
|
|
<Directory ${testRoot}>
|
|
|
|
Require all granted
|
|
|
|
</Directory>
|
|
|
|
'';
|
2017-11-12 07:05:27 +00:00
|
|
|
};
|
|
|
|
};
|
2022-11-29 17:36:38 +00:00
|
|
|
testScript = let
|
|
|
|
# PCRE JIT SEAlloc feature does not play well with fork()
|
|
|
|
# The feature needs to either be disabled or PHP configured correctly
|
|
|
|
# More information in https://bugs.php.net/bug.php?id=78927 and https://bugs.php.net/bug.php?id=78630
|
|
|
|
pcreJitSeallocForkIssue = pkgs.writeText "pcre-jit-sealloc-issue.php" ''
|
|
|
|
<?php
|
|
|
|
preg_match('/nixos/', 'nixos');
|
|
|
|
$pid = pcntl_fork();
|
|
|
|
pcntl_wait($pid);
|
|
|
|
'';
|
|
|
|
in ''
|
2020-03-31 18:06:04 +01:00
|
|
|
machine.wait_for_unit("httpd.service")
|
|
|
|
# Ensure php evaluation by matching on the var_dump syntax
|
2020-09-16 16:32:56 +01:00
|
|
|
response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/index.php")
|
2020-04-16 22:19:45 +01:00
|
|
|
expected = 'string(${toString (builtins.stringLength testString)}) "${testString}"'
|
|
|
|
assert expected in response, "Does not appear to be able to use subgroups."
|
2022-11-29 17:36:38 +00:00
|
|
|
machine.succeed("${php}/bin/php -f ${pcreJitSeallocForkIssue}")
|
2020-03-31 18:06:04 +01:00
|
|
|
'';
|
2017-11-12 07:05:27 +00:00
|
|
|
})
|