Skip to content

Instantly share code, notes, and snippets.

@srhb
Last active November 10, 2017 10:27
Show Gist options
  • Save srhb/2d9f5354cdf16c96ec3356f4c5383303 to your computer and use it in GitHub Desktop.
Save srhb/2d9f5354cdf16c96ec3356f4c5383303 to your computer and use it in GitHub Desktop.
Tests whether mod_php handles groups in pcre regexes
let testString = "can-use-subgroups"; in
import <nixpkgs/nixos/tests/make-test.nix> {
name = "php-httpd-pcre-jit-test";
machine = { config, lib, pkgs, ... }: {
time.timeZone = "Europe/Copenhagen";
services.httpd = {
enable = true;
adminAddr = "please@dont.contact";
extraSubservices = lib.singleton {
function = f: {
enablePHP = true;
phpOptions = "pcre.jit = true";
extraConfig =
let
testRoot = pkgs.writeText "index.php"
''
<?php
preg_match('/(${testString})/', '${testString}', $result);
var_dump($result);
?>
'';
in
''
Alias / ${testRoot}/
<Directory ${testRoot}>
Require all granted
</Directory>
'';
};
};
};
};
testScript = { nodes, ... }:
''
$machine->waitForUnit('httpd.service');
$machine->succeed('curl -s http://127.0.0.1:80/index.php | grep "${testString}"');
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment