Skip to content

Commit

Permalink
Unit Tests for GH-16551
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacarpet committed Dec 3, 2024
1 parent 1cdf3fa commit 97eff1b
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 0 deletions.
42 changes: 42 additions & 0 deletions ext/opcache/tests/gt16551_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--TEST--
GH-16551: opcache file cache read only: generate file cache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=disable
opcache.jit_buffer_size=0
opcache.file_cache="{TMP}"
--EXTENSIONS--
opcache
--CONFLICTS--
opcache_file_cache
--FILE--
<?php

$file = __DIR__ . '/gt16551_998.inc';
$uncached_file = __DIR__ . '/gt16551_999.inc';

opcache_compile_file($file);

var_dump(
opcache_is_script_cached($file)
);

var_dump(
opcache_is_script_cached_in_file_cache($file)
);

var_dump(
opcache_is_script_cached($uncached_file)
);

var_dump(
opcache_is_script_cached_in_file_cache($uncached_file)
);

?>
--EXPECT--
bool(true)
bool(true)
bool(false)
bool(false)
37 changes: 37 additions & 0 deletions ext/opcache/tests/gt16551_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--TEST--
GH-16551: opcache file cache read only: read file cache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=disable
opcache.jit_buffer_size=0
opcache.file_cache="{TMP}"
opcache.file_cache_read_only=1
--EXTENSIONS--
opcache
--CONFLICTS--
opcache_file_cache
--FILE--
<?php

$file = __DIR__ . '/gt16551_998.inc';
$uncached_file = __DIR__ . '/gt16551_999.inc';

var_dump(
opcache_is_script_cached_in_file_cache($file)
);

require $file;

var_dump(
opcache_is_script_cached_in_file_cache($uncached_file)
);

require $uncached_file;

?>
--EXPECT--
bool(true)
9
bool(false)
8
41 changes: 41 additions & 0 deletions ext/opcache/tests/gt16551_003.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--TEST--
GH-16551: opcache file cache read only: read file cache with limited checks
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=disable
opcache.jit_buffer_size=0
opcache.file_cache="{TMP}"
opcache.file_cache_read_only=1
opcache.revalidate_freq=0
opcache.enable_file_override=true
opcache.validate_timestamps=false
opcache.file_cache_consistency_checks=false
--EXTENSIONS--
opcache
--CONFLICTS--
opcache_file_cache
--FILE--
<?php

$file = __DIR__ . '/gt16551_998.inc';
$uncached_file = __DIR__ . '/gt16551_999.inc';

var_dump(
opcache_is_script_cached_in_file_cache($file)
);

require $file;

var_dump(
opcache_is_script_cached_in_file_cache($uncached_file)
);

require $uncached_file;

?>
--EXPECT--
bool(true)
9
bool(false)
8
36 changes: 36 additions & 0 deletions ext/opcache/tests/gt16551_004.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
GH-16551: opcache file cache read only: ensure we can't invalidate
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=disable
opcache.jit_buffer_size=0
opcache.file_cache="{TMP}"
opcache.file_cache_read_only=1
--EXTENSIONS--
opcache
--CONFLICTS--
opcache_file_cache
--FILE--
<?php

$file = __DIR__ . '/gt16551_998.inc';

var_dump(
opcache_is_script_cached_in_file_cache($file)
);

// invalidate SHM, but silently ignore file cache.
opcache_invalidate($file, true);

var_dump(
opcache_is_script_cached_in_file_cache($file)
);

require $file;

?>
--EXPECT--
bool(true)
bool(true)
8
42 changes: 42 additions & 0 deletions ext/opcache/tests/gt16551_005.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--TEST--
GH-16551: opcache file cache read only: ensure cache files aren't created
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=disable
opcache.jit_buffer_size=0
opcache.file_cache="{TMP}"
opcache.file_cache_read_only=1
--EXTENSIONS--
opcache
--CONFLICTS--
opcache_file_cache
--FILE--
<?php

$uncached_file = __DIR__ . '/gt16551_999.inc';

var_dump(
opcache_is_script_cached($uncached_file)
);

var_dump(
opcache_is_script_cached_in_file_cache($uncached_file)
);

opcache_compile_file($uncached_file);

var_dump(
opcache_is_script_cached($uncached_file)
);

var_dump(
opcache_is_script_cached_in_file_cache($uncached_file)
);

?>
--EXPECT--
bool(false)
bool(false)
bool(true)
bool(false)
5 changes: 5 additions & 0 deletions ext/opcache/tests/gt16551_998.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

$a = 4+5;

echo $a . "\n";
5 changes: 5 additions & 0 deletions ext/opcache/tests/gt16551_999.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

$a = 3+5;

echo $a . "\n";

0 comments on commit 97eff1b

Please sign in to comment.