-
Notifications
You must be signed in to change notification settings - Fork 8k
Expand file tree
/
Copy pathgh17770_jit_file_cache_write.phpt
More file actions
83 lines (71 loc) · 1.94 KB
/
gh17770_jit_file_cache_write.phpt
File metadata and controls
83 lines (71 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--TEST--
GH-17770: opcache.file_cache writes with JIT enabled
--SKIPIF--
<?php
@mkdir(__DIR__ . '/gh17770_cache', 0777, true);
if (ini_get('opcache.jit') === false) {
die('skip JIT is not supported');
}
?>
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
opcache.jit_buffer_size=16M
opcache.file_cache="{PWD}/gh17770_cache"
opcache.file_cache_consistency_checks=0
--FILE--
<?php
function removeDirRecursive(string $dir): void {
if (!is_dir($dir)) {
return;
}
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $entry) {
if ($entry->isDir()) {
@rmdir($entry->getRealPath());
} else {
@unlink($entry->getRealPath());
}
}
@rmdir($dir);
}
$cacheDir = ini_get('opcache.file_cache');
removeDirRecursive($cacheDir);
@mkdir($cacheDir, 0777, true);
$tmpPhpFile = __DIR__ . '/gh17770-opcache-target.php';
file_put_contents($tmpPhpFile, "<?php\nfunction gh17770() { return 42; }\ngh17770();\n");
@opcache_reset();
opcache_compile_file($tmpPhpFile);
$hasCacheFile = opcache_is_script_cached_in_file_cache($tmpPhpFile);
echo $hasCacheFile ? "OK\n" : "FAIL: opcache file cache is empty\n";
?>
--CLEAN--
<?php
function removeDirRecursive(string $dir): void {
if (!is_dir($dir)) {
return;
}
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $entry) {
if ($entry->isDir()) {
@rmdir($entry->getRealPath());
} else {
@unlink($entry->getRealPath());
}
}
@rmdir($dir);
}
removeDirRecursive(__DIR__ . '/gh17770_cache');
@unlink(__DIR__ . '/gh17770-opcache-target.php');
?>
--EXPECT--
OK