Skip to content

Commit 1c67b06

Browse files
committed
main: Add bailout tests for dir opening on user stream
1 parent 0992265 commit 1c67b06

File tree

7 files changed

+54
-23
lines changed

7 files changed

+54
-23
lines changed

Zend/tests/arginfo_zpp_mismatch.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function skipFunction($function): bool {
99
/* terminates script */
1010
|| $function === 'exit'
1111
|| $function === 'die'
12+
|| $function === 'zend_trigger_bailout'
1213
/* intentionally violate invariants */
1314
|| $function === 'zend_create_unterminated_string'
1415
|| $function === 'zend_test_array_return'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bailout (E_ERROR) during UserStream Dir Open
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
class FailStream {
9+
public $context;
10+
public function dir_opendir(string $url, int $options) {
11+
zend_trigger_bailout();
12+
}
13+
}
14+
stream_wrapper_register('mystream', 'FailStream');
15+
opendir('mystream://foo');
16+
echo 'Done';
17+
?>
18+
--EXPECTF--
19+
Fatal error: Bailout in %s on line %d

ext/standard/tests/streams/user-stream-error.phpt

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bailout (E_ERROR) during UserStream Open
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
class FailStream {
9+
public $context;
10+
public function stream_open($path, $mode, $options, &$opened_path) {
11+
zend_trigger_bailout();
12+
}
13+
}
14+
stream_wrapper_register('mystream', 'FailStream');
15+
fopen('mystream://foo', 'r');
16+
echo 'Done';
17+
?>
18+
--EXPECTF--
19+
Fatal error: Bailout in %s on line %d

ext/zend_test/test.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ static ZEND_FUNCTION(zend_test_func)
8787
EX(func) = NULL;
8888
}
8989

90+
static ZEND_FUNCTION(zend_trigger_bailout)
91+
{
92+
ZEND_PARSE_PARAMETERS_NONE();
93+
94+
zend_error(E_ERROR, "Bailout");
95+
}
96+
9097
static ZEND_FUNCTION(zend_test_array_return)
9198
{
9299
ZEND_PARSE_PARAMETERS_NONE();

ext/zend_test/test.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ enum ZendTestIntEnum: int {
208208
case Baz = -1;
209209
}
210210

211+
function zend_trigger_bailout(): never {}
212+
211213
function zend_test_array_return(): array {}
212214

213215
/** @genstubs-expose-comment-block

ext/zend_test/test_arginfo.h

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)