Skip to content

Commit 6e819bb

Browse files
committed
Unit Tests for GH-16551
1 parent 1cdf3fa commit 6e819bb

File tree

7 files changed

+208
-0
lines changed

7 files changed

+208
-0
lines changed

ext/opcache/tests/gt16551_001.phpt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
GH-16551: opcache file cache read only: generate file cache
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit=disable
7+
opcache.jit_buffer_size=0
8+
opcache.file_cache="{TMP}"
9+
--EXTENSIONS--
10+
opcache
11+
--CONFLICTS--
12+
opcache_file_cache
13+
--FILE--
14+
<?php
15+
16+
$file = __DIR__ . '/gt16551_998.inc';
17+
$uncached_file = __DIR__ . '/gt16551_999.inc';
18+
19+
opcache_compile_file($file);
20+
21+
var_dump(
22+
opcache_is_script_cached($file)
23+
);
24+
25+
var_dump(
26+
opcache_is_script_cached_in_file_cache($file)
27+
);
28+
29+
var_dump(
30+
opcache_is_script_cached($uncached_file)
31+
);
32+
33+
var_dump(
34+
opcache_is_script_cached_in_file_cache($uncached_file)
35+
);
36+
37+
?>
38+
--EXPECT--
39+
bool(true)
40+
bool(true)
41+
bool(false)
42+
bool(false)

ext/opcache/tests/gt16551_002.phpt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
GH-16551: opcache file cache read only: read file cache
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit=disable
7+
opcache.jit_buffer_size=0
8+
opcache.file_cache="{TMP}"
9+
opcache.file_cache_read_only=1
10+
--EXTENSIONS--
11+
opcache
12+
--CONFLICTS--
13+
opcache_file_cache
14+
--FILE--
15+
<?php
16+
17+
$file = __DIR__ . '/gt16551_998.inc';
18+
$uncached_file = __DIR__ . '/gt16551_999.inc';
19+
20+
var_dump(
21+
opcache_is_script_cached_in_file_cache($file)
22+
);
23+
24+
require $file;
25+
26+
var_dump(
27+
opcache_is_script_cached_in_file_cache($uncached_file)
28+
);
29+
30+
require $uncached_file;
31+
32+
?>
33+
--EXPECT--
34+
bool(true)
35+
9
36+
bool(false)
37+
8

ext/opcache/tests/gt16551_003.phpt

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
GH-16551: opcache file cache read only: read file cache with limited checks
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit=disable
7+
opcache.jit_buffer_size=0
8+
opcache.file_cache="{TMP}"
9+
opcache.file_cache_read_only=1
10+
opcache.revalidate_freq=0
11+
opcache.enable_file_override=true
12+
opcache.validate_timestamps=false
13+
opcache.file_cache_consistency_checks=false
14+
--EXTENSIONS--
15+
opcache
16+
--CONFLICTS--
17+
opcache_file_cache
18+
--FILE--
19+
<?php
20+
21+
$file = __DIR__ . '/gt16551_998.inc';
22+
$uncached_file = __DIR__ . '/gt16551_999.inc';
23+
24+
var_dump(
25+
opcache_is_script_cached_in_file_cache($file)
26+
);
27+
28+
require $file;
29+
30+
var_dump(
31+
opcache_is_script_cached_in_file_cache($uncached_file)
32+
);
33+
34+
require $uncached_file;
35+
36+
?>
37+
--EXPECT--
38+
bool(true)
39+
9
40+
bool(false)
41+
8

ext/opcache/tests/gt16551_004.phpt

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
GH-16551: opcache file cache read only: ensure we can't invalidate
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit=disable
7+
opcache.jit_buffer_size=0
8+
opcache.file_cache="{TMP}"
9+
opcache.file_cache_read_only=1
10+
--EXTENSIONS--
11+
opcache
12+
--CONFLICTS--
13+
opcache_file_cache
14+
--FILE--
15+
<?php
16+
17+
$file = __DIR__ . '/gt16551_998.inc';
18+
19+
var_dump(
20+
opcache_is_script_cached_in_file_cache($file)
21+
);
22+
23+
// invalidate SHM, but silently ignore file cache.
24+
opcache_invalidate($file, true);
25+
26+
var_dump(
27+
opcache_is_script_cached_in_file_cache($file)
28+
);
29+
30+
require $file;
31+
32+
?>
33+
--EXPECT--
34+
bool(true)
35+
bool(true)
36+
9

ext/opcache/tests/gt16551_005.phpt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
GH-16551: opcache file cache read only: ensure cache files aren't created
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit=disable
7+
opcache.jit_buffer_size=0
8+
opcache.file_cache="{TMP}"
9+
opcache.file_cache_read_only=1
10+
--EXTENSIONS--
11+
opcache
12+
--CONFLICTS--
13+
opcache_file_cache
14+
--FILE--
15+
<?php
16+
17+
$uncached_file = __DIR__ . '/gt16551_999.inc';
18+
19+
var_dump(
20+
opcache_is_script_cached($uncached_file)
21+
);
22+
23+
var_dump(
24+
opcache_is_script_cached_in_file_cache($uncached_file)
25+
);
26+
27+
opcache_compile_file($uncached_file);
28+
29+
var_dump(
30+
opcache_is_script_cached($uncached_file)
31+
);
32+
33+
var_dump(
34+
opcache_is_script_cached_in_file_cache($uncached_file)
35+
);
36+
37+
?>
38+
--EXPECT--
39+
bool(false)
40+
bool(false)
41+
bool(true)
42+
bool(false)

ext/opcache/tests/gt16551_998.inc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
$a = 4+5;
4+
5+
echo $a . "\n";

ext/opcache/tests/gt16551_999.inc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
$a = 3+5;
4+
5+
echo $a . "\n";

0 commit comments

Comments
 (0)