Skip to content

Commit 2b48e74

Browse files
committed
main: Add bailout tests for dir opening on user stream
1 parent d926c36 commit 2b48e74

File tree

6 files changed

+53
-23
lines changed

6 files changed

+53
-23
lines changed
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
@@ -85,6 +85,13 @@ static ZEND_FUNCTION(zend_test_func)
8585
EX(func) = NULL;
8686
}
8787

88+
static ZEND_FUNCTION(zend_trigger_bailout)
89+
{
90+
ZEND_PARSE_PARAMETERS_NONE();
91+
92+
zend_error(E_ERROR, "Bailout");
93+
}
94+
8895
static ZEND_FUNCTION(zend_test_array_return)
8996
{
9097
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)