Skip to content

Commit 3df9917

Browse files
committed
Different GD tests for when fopencooki is available
This requires us adding a function to poll this information in zend_test
1 parent e26b3e9 commit 3df9917

5 files changed

+49
-5
lines changed

ext/gd/tests/gd_create_xbm_non_castable_user_stream.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
--TEST--
2-
imagecreatefromxbm(): uncastable user stream
2+
imagecreatefromxbm(): uncastable user stream has fopencookie
33
--EXTENSIONS--
44
gd
5+
zend_test
56
--SKIPIF--
67
<?php
78
if (!GD_BUNDLED) die("skip requires bundled GD library\n");
9+
if (!zend_test_is_c_fopencookie_available()) die("skip test for when C fopencookie is available");
810
?>
911
--FILE--
1012
<?php
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
imagecreatefromxbm(): uncastable user stream without fopencookie
3+
--EXTENSIONS--
4+
gd
5+
zend_test
6+
--SKIPIF--
7+
<?php
8+
if (!GD_BUNDLED) die("skip requires bundled GD library\n");
9+
if (zend_test_is_c_fopencookie_available()) die("skip test for when C fopencookie is not available");
10+
?>
11+
--FILE--
12+
<?php
13+
14+
require dirname(__DIR__, 3) . '/tests/output/DummyStreamWrapper.inc';
15+
stream_wrapper_register('custom', DummyStreamWrapper::class);
16+
17+
/* This tests the underlying _php_image_create_from() C function */
18+
var_dump(imagecreatefromxbm("custom://myvar"));
19+
20+
echo "Done";
21+
?>
22+
--EXPECTF--
23+
Warning: imagecreatefromxbm(): Cannot represent a stream of type user-space as a STDIO FILE* in %s on line %d
24+
bool(false)
25+
Done

ext/zend_test/test.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,17 @@ static ZEND_FUNCTION(zend_test_zend_call_stack_use_all)
516516
}
517517
#endif /* ZEND_CHECK_STACK_LIMIT */
518518

519+
static ZEND_FUNCTION(zend_test_is_c_fopencookie_available)
520+
{
521+
ZEND_PARSE_PARAMETERS_NONE();
522+
523+
#if HAVE_FOPENCOOKIE
524+
RETURN_TRUE;
525+
#else
526+
RETURN_FALSE;
527+
#endif
528+
}
529+
519530
static zend_object *zend_test_class_new(zend_class_entry *class_type)
520531
{
521532
zend_object *obj = zend_objects_new(class_type);

ext/zend_test/test.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ function zend_test_zend_ini_str(): string {}
178178
function zend_test_zend_call_stack_get(): ?array {}
179179
function zend_test_zend_call_stack_use_all(): int {}
180180
#endif
181+
182+
function zend_test_is_c_fopencookie_available(): bool {}
181183
}
182184

183185
namespace ZendTestNS {

ext/zend_test/test_arginfo.h

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)