Skip to content

Commit cc7ed39

Browse files
committed
Added tests that generates opcache and that queries phpinfo
1 parent 0f3ddd7 commit cc7ed39

File tree

13 files changed

+79
-0
lines changed

13 files changed

+79
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
*.pyc
22
*.tmp
33
hunt_opcache
4+
tests/opcache/Dockerfile
5+
tests/systemid/Dockerfile

tests/opcache/Dockerfile.template

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:%%PHP_VERSION%%-cli-alpine
2+
3+
# Override with custom opcache settings
4+
RUN docker-php-ext-install opcache
5+
COPY opcache.ini $PHP_INI_DIR/conf.d/
6+
7+
COPY test.php /usr/src/myapp/
8+
WORKDIR /usr/src/myapp
9+
CMD [ "php", "./test.php" ]

tests/opcache/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
VERSIONS = 7.0 7.1 7.2 7.3
2+
prepare:
3+
for version in ${VERSIONS} ; do \
4+
sed -r "s!%%PHP_VERSION%%!$$version!g;" Dockerfile.template > Dockerfile ; \
5+
docker build -t opcache-test-$$version . ; \
6+
done
7+
8+
test:
9+
for version in ${VERSIONS} ; do \
10+
docker run -it --rm --user 1000 -v "${CURDIR}"/opcache/:/tmp/opcache opcache-test-$$version ; \
11+
done

tests/opcache/opcache.ini

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[opcache]
2+
; Determines if Zend OPCache is enabled
3+
opcache.enable=1
4+
5+
; Determines if Zend OPCache is enabled for the CLI version of PHP
6+
;opcache.enable_cli=0
7+
opcache.enable_cli=1
8+
9+
; Enables or disables opcode caching in shared memory.
10+
;opcache.file_cache_only=0
11+
opcache.file_cache_only=1
12+
13+
; Enables and sets the second level cache directory.
14+
; It should improve performance when SHM memory is full, at server restart or
15+
; SHM reset. The default "" disables file based caching.
16+
;opcache.file_cache=
17+
opcache.file_cache = /tmp/opcache
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

tests/opcache/test.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
print("Hello World!\n");
4+
5+
?>

tests/systemid/Dockerfile.template

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:%%PHP_VERSION%%-apache
2+
COPY phpinfo.php /var/www/html

tests/systemid/Makefile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
VERSIONS = 7.0 7.1 7.2 7.3
2+
prepare:
3+
for version in ${VERSIONS} ; do \
4+
sed -r "s!%%PHP_VERSION%%!$$version!g;" Dockerfile.template > Dockerfile ; \
5+
docker build -t systemid-test-$$version . ; \
6+
done
7+
8+
test:
9+
for version in ${VERSIONS} ; do \
10+
docker run -d -p 80:80 --rm --name systemid-test-$$version-run systemid-test-$$version ; \
11+
sleep 2 ; \
12+
../../system_id_scraper.py http://127.0.0.1/phpinfo.php ; \
13+
docker stop systemid-test-$$version-run ; \
14+
sleep 2 ; \
15+
done

tests/systemid/opcache.ini

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[opcache]
2+
; Determines if Zend OPCache is enabled
3+
opcache.enable=1
4+
5+
; Determines if Zend OPCache is enabled for the CLI version of PHP
6+
;opcache.enable_cli=0
7+
opcache.enable_cli=1
8+
9+
; Enables or disables opcode caching in shared memory.
10+
;opcache.file_cache_only=0
11+
opcache.file_cache_only=1
12+
13+
; Enables and sets the second level cache directory.
14+
; It should improve performance when SHM memory is full, at server restart or
15+
; SHM reset. The default "" disables file based caching.
16+
;opcache.file_cache=
17+
opcache.file_cache = /tmp/opcache

tests/systemid/phpinfo.php

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php phpinfo(); ?>

0 commit comments

Comments
 (0)