php-src/ext/ffi/tests/bug77706.phpt
Max Semenik bd9f4fa676 Migrate skip checks to --EXTENSIONS--, p2
For rationale, see https://github.com/php/php-src/pull/6787

Make extension checks lowercase, add a special case for opcache
that has internal name not matching .so filename.

Extensions migrated in part 2:
* dom
* exif
* fileinfo
* ffi
2021-04-01 12:08:24 +01:00

62 lines
1.5 KiB
PHP

--TEST--
Bug #77632 (FFI Segfaults When Called With Variadics)
--EXTENSIONS--
ffi
--SKIPIF--
<?php
try {
$libc = FFI::cdef("int printf(const char *format, ...);", "libc.so.6");
} catch (Throwable $_) {
die('skip libc.so.6 not available');
}
?>
--INI--
ffi.enable=1
--FILE--
<?php
$header = '
typedef struct _IO_FILE FILE;
extern FILE *stdout;
extern FILE *stdin;
extern FILE *stderr;
typedef uint64_t time_t;
typedef uint32_t pid_t;
time_t time(time_t*);
pid_t getpid(void);
int fprintf(FILE *, const char *, ...);
';
$ffi = FFI::cdef($header, 'libc.so.6');
try {
$ffi->time();
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage() . "\n";
}
try {
$ffi->time(null, null);
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage() . "\n";
}
try {
$ffi->fprintf($ffi->stdout);
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage() . "\n";
}
try {
$ffi->fprintf($ffi->stdout, 123, "Hello %s\n", "World");
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage() . "\n";
}
?>
--EXPECT--
FFI\Exception: Incorrect number of arguments for C function 'time', expecting exactly 1 parameter
FFI\Exception: Incorrect number of arguments for C function 'time', expecting exactly 1 parameter
FFI\Exception: Incorrect number of arguments for C function 'fprintf', expecting at least 2 parameters
FFI\Exception: Passing incompatible argument 2 of C function 'fprintf', expecting 'char*', found PHP 'int'