Skip to content

Proc resource test #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
223 changes: 0 additions & 223 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,131 +42,6 @@ env:
CC: ccache gcc
CXX: ccache g++
jobs:
LINUX_X64:
services:
mysql:
image: mysql:8
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: root
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
env:
MYSQL_TEST_HOST: mysql
PDO_MYSQL_TEST_DSN: mysql:host=mysql;dbname=test
PDO_MYSQL_TEST_HOST: mysql
strategy:
fail-fast: false
matrix:
include:
- debug: false
zts: false
asan: false
- debug: true
zts: true
asan: true
name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}"
runs-on: ubuntu-22.04
container:
image: ${{ matrix.asan && 'ubuntu:23.04' || null }}
steps:
- name: git checkout
uses: actions/checkout@v4
- name: apt
uses: ./.github/actions/apt-x64
- name: System info
run: |
echo "::group::Show host CPU info"
lscpu
echo "::endgroup::"
echo "::group::Show installed package versions"
dpkg -l
echo "::endgroup::"
- name: Create MSSQL container
if: ${{ !matrix.asan }}
uses: ./.github/actions/setup-mssql
- name: Create Oracle container
if: ${{ !matrix.asan }}
uses: ./.github/actions/setup-oracle
- name: Setup Caddy server
uses: ./.github/actions/setup-caddy
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
# This duplicates the "job.name" expression above because
# GitHub has no way to query the job name (github.job is the
# job id, not the job name)
key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}"
append-timestamp: false
- name: ./configure
uses: ./.github/actions/configure-x64
with:
configurationParameters: >-
--${{ matrix.debug && 'enable' || 'disable' }}-debug
--${{ matrix.zts && 'enable' || 'disable' }}-zts
${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address" CC=clang CXX=clang++ --disable-opcache-jit' || '' }}
skipSlow: ${{ matrix.asan }}
- name: make
run: make -j$(/usr/bin/nproc) >/dev/null
- name: make install
uses: ./.github/actions/install-linux
- name: Setup
if: ${{ !matrix.asan }}
uses: ./.github/actions/setup-x64
- name: Test
if: matrix.asan == false
uses: ./.github/actions/test-linux
with:
testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}
- name: Test ${{ matrix.asan && 'OpCache' || 'Tracing JIT' }}
uses: ./.github/actions/test-linux
with:
testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}_${{ matrix.asan && 'OpCache' || 'Tracing JIT' }}
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
${{ !matrix.asan && '-d opcache.jit_buffer_size=16M' || '' }}
${{ matrix.asan && '--asan -x' || '' }}
- name: Verify generated files are up to date
if: ${{ !matrix.asan }}
uses: ./.github/actions/verify-generated-files
MACOS_DEBUG_NTS:
runs-on: macos-11
steps:
- name: git checkout
uses: actions/checkout@v4
- name: brew
uses: ./.github/actions/brew
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
append-timestamp: false
- name: ./configure
uses: ./.github/actions/configure-macos
with:
configurationParameters: --enable-debug --disable-zts
- name: make
run: |-
export PATH="/usr/local/opt/bison/bin:$PATH"
make -j$(sysctl -n hw.logicalcpu) >/dev/null
- name: make install
run: sudo make install
- name: Test Tracing JIT
uses: ./.github/actions/test-macos
with:
testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
-d opcache.protect_memory=1
-d opcache.jit_buffer_size=16M
- name: Verify generated files are up to date
uses: ./.github/actions/verify-generated-files
WINDOWS:
name: WINDOWS_X64_ZTS
runs-on: windows-2019
Expand All @@ -186,105 +61,7 @@ jobs:
run: git config --global core.autocrlf false && git config --global core.eol lf
- name: git checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup-windows
- name: Build
run: .github/scripts/windows/build.bat
- name: Test
run: .github/scripts/windows/test.bat
BENCHMARKING:
name: BENCHMARKING
if: github.repository_owner == 'php' || github.event_name == 'pull_request'
runs-on: ubuntu-22.04
steps:
- name: git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: apt
run: |
set -x
sudo apt-get update
sudo apt-get install \
bison \
libgmp-dev \
libonig-dev \
libsqlite3-dev \
openssl \
re2c \
valgrind
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
append-timestamp: false
- name: ./configure
run: |
set -x
./buildconf --force
./configure \
--disable-debug \
--enable-mbstring \
--enable-opcache \
--enable-option-checking=fatal \
--enable-sockets \
--enable-werror \
--prefix=/usr \
--with-config-file-scan-dir=/etc/php.d \
--with-gmp \
--with-mysqli=mysqlnd \
--with-openssl \
--with-pdo-sqlite \
--with-valgrind
- name: make
run: make -j$(/usr/bin/nproc) >/dev/null
- name: make install
run: |
set -x
sudo make install
sudo mkdir -p /etc/php.d
sudo chmod 777 /etc/php.d
echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
echo zend_extension=opcache.so >> /etc/php.d/opcache.ini
echo opcache.enable=1 >> /etc/php.d/opcache.ini
echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
- name: Setup
run: |
git config --global user.name "Benchmark"
git config --global user.email "benchmark@php.net"
sudo service mysql start
mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress"
mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;"
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;"
- name: git checkout benchmarking-data
uses: actions/checkout@v4
with:
repository: php/benchmarking-data
ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }}
path: benchmark/repos/data
- name: Benchmark
run: php benchmark/benchmark.php true
- name: Store result
if: github.event_name == 'push'
run: |
set -x
cd benchmark/repos/data
git pull --autostash
if [ -e ".git/MERGE_HEAD" ]; then
echo "Merging, can't proceed"
exit 1
fi
git add .
if git diff --cached --quiet; then
exit 0
fi
git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}"
git push
- name: Show diff
if: github.event_name == 'pull_request'
run: |-
set -x
php benchmark/generate_diff.php \
${{ github.sha }} \
$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \
> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ static const func_info_t func_infos[] = {
F1("password_get_info", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_NULL),
F1("password_hash", MAY_BE_STRING),
#if defined(PHP_CAN_SUPPORT_PROC_OPEN)
F1("proc_open", MAY_BE_RESOURCE|MAY_BE_FALSE),
F1("proc_open", MAY_BE_OBJECT|MAY_BE_FALSE),
#endif
#if defined(PHP_CAN_SUPPORT_PROC_OPEN)
F1("proc_get_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
Expand Down
6 changes: 2 additions & 4 deletions ext/posix/tests/posix_ttyname_error_wrongparams.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ standard

var_dump(posix_ttyname(0)); // param not a resource

$descriptors = [["pty"], ["pty"], ["pty"], ["pipe", "w"]];
$pipes = [];
$process = proc_open('echo "foo";', $descriptors, $pipes);
$bucket = stream_bucket_new(fopen('php://temp', 'w+'), '');

try {
var_dump(posix_ttyname($process)); // wrong resource type
var_dump(posix_ttyname($bucket->bucket)); // wrong resource type
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
Expand Down
3 changes: 2 additions & 1 deletion ext/readline/tests/bug77812-libedit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ fclose($pipes[0]);
proc_close($proc);
?>
--EXPECTF--
resource(%d) of type (process)
object(Standard\Process)#1 (0) {
}
Interactive shell

bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ $standard = new ReflectionExtension('standard');
var_dump($standard->getClassNames());
?>
--EXPECT--
array(4) {
array(5) {
[0]=>
string(22) "__PHP_Incomplete_Class"
[1]=>
string(14) "AssertionError"
[2]=>
string(15) "php_user_filter"
string(16) "Standard\Process"
[3]=>
string(15) "php_user_filter"
[4]=>
string(9) "Directory"
}
8 changes: 5 additions & 3 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */

assertion_error_ce = register_class_AssertionError(zend_ce_error);

#ifdef PHP_CAN_SUPPORT_PROC_OPEN
process_ce = register_class_Standard_Process();
php_register_process_class_handlers();
#endif

BASIC_MINIT_SUBMODULE(var)
BASIC_MINIT_SUBMODULE(file)
BASIC_MINIT_SUBMODULE(pack)
Expand Down Expand Up @@ -336,9 +341,6 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
BASIC_MINIT_SUBMODULE(array)
BASIC_MINIT_SUBMODULE(assert)
BASIC_MINIT_SUBMODULE(url_scanner_ex)
#ifdef PHP_CAN_SUPPORT_PROC_OPEN
BASIC_MINIT_SUBMODULE(proc_open)
#endif
BASIC_MINIT_SUBMODULE(exec)

BASIC_MINIT_SUBMODULE(user_streams)
Expand Down
5 changes: 5 additions & 0 deletions ext/standard/basic_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
extern zend_module_entry basic_functions_module;
#define basic_functions_module_ptr &basic_functions_module

#ifdef PHP_CAN_SUPPORT_PROC_OPEN
extern zend_class_entry *process_ce;
extern void php_register_process_class_handlers(void);
#endif

PHP_MINIT_FUNCTION(basic);
PHP_MSHUTDOWN_FUNCTION(basic);
PHP_RINIT_FUNCTION(basic);
Expand Down
Loading