diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-10-22 12:48:12 +0200 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-10-22 19:01:40 +0200 |
commit | a8e92e361f82fdd7485b5f7d2dc1c0ccd8edca62 (patch) | |
tree | acb926bb7a99ab4b52a7eda1c64891b322e0844b /Zend/tests | |
parent | ba27866aecf086cd8311dd8fa7c9f83e09ec1e82 (diff) | |
download | php-git-a8e92e361f82fdd7485b5f7d2dc1c0ccd8edca62.tar.gz |
Run arginfo/ZPP verification tests in strict mode as well
Closes GH-6370
Diffstat (limited to 'Zend/tests')
-rw-r--r-- | Zend/tests/arginfo_zpp_mismatch.inc | 39 | ||||
-rw-r--r-- | Zend/tests/arginfo_zpp_mismatch.phpt | 34 | ||||
-rw-r--r-- | Zend/tests/arginfo_zpp_mismatch_strict.phpt | 85 |
3 files changed, 127 insertions, 31 deletions
diff --git a/Zend/tests/arginfo_zpp_mismatch.inc b/Zend/tests/arginfo_zpp_mismatch.inc new file mode 100644 index 0000000000..2207d76db4 --- /dev/null +++ b/Zend/tests/arginfo_zpp_mismatch.inc @@ -0,0 +1,39 @@ +<?php + +function skipFunction($function): bool { + if (false + /* expect input / hang */ + || $function === 'readline' + || $function === 'readline_read_history' + || $function === 'readline_write_history' + /* intentionally violate invariants */ + || $function === 'zend_create_unterminated_string' + || $function === 'zend_test_array_return' + || $function === 'zend_leak_bytes' + /* mess with output */ + || (is_string($function) && str_starts_with($function, 'ob_')) + || $function === 'output_add_rewrite_var' + || $function === 'error_log' + /* may spend a lot of time waiting for connection timeouts */ + || (is_string($function) && str_contains($function, 'connect')) + || (is_string($function) && str_starts_with($function, 'snmp')) + || (is_array($function) && get_class($function[0]) === mysqli::class + && in_array($function[1], ['__construct', 'connect', 'real_connect'])) + /* misc */ + || $function === 'mail' + || $function === 'mb_send_mail' + || $function === 'pcntl_fork' + || $function === 'posix_kill' + || $function === 'posix_setrlimit' + || $function === 'sapi_windows_generate_ctrl_event' + || $function === 'imagegrabscreen' + ) { + return true; + } + if ($function[0] instanceof SoapServer) { + /* TODO: Uses fatal errors */ + return true; + } + + return false; +} diff --git a/Zend/tests/arginfo_zpp_mismatch.phpt b/Zend/tests/arginfo_zpp_mismatch.phpt index 2a9522a6de..f5df299430 100644 --- a/Zend/tests/arginfo_zpp_mismatch.phpt +++ b/Zend/tests/arginfo_zpp_mismatch.phpt @@ -7,38 +7,10 @@ if (getenv('SKIP_MSAN')) die("skip msan misses interceptors for some functions") --FILE-- <?php +require __DIR__ . "/arginfo_zpp_mismatch.inc"; + function test($function) { - if (false - /* expect input / hang */ - || $function === 'readline' - || $function === 'readline_read_history' - || $function === 'readline_write_history' - /* intentionally violate invariants */ - || $function === 'zend_create_unterminated_string' - || $function === 'zend_test_array_return' - || $function === 'zend_leak_bytes' - /* mess with output */ - || (is_string($function) && str_starts_with($function, 'ob_')) - || $function === 'output_add_rewrite_var' - || $function === 'error_log' - /* may spend a lot of time waiting for connection timeouts */ - || (is_string($function) && str_contains($function, 'connect')) - || (is_string($function) && str_starts_with($function, 'snmp')) - || (is_array($function) && get_class($function[0]) === mysqli::class - && in_array($function[1], ['__construct', 'connect', 'real_connect'])) - /* misc */ - || $function === 'mail' - || $function === 'mb_send_mail' - || $function === 'pcntl_fork' - || $function === 'posix_kill' - || $function === 'posix_setrlimit' - || $function === 'sapi_windows_generate_ctrl_event' - || $function === 'imagegrabscreen' - ) { - return; - } - if ($function[0] instanceof SoapServer) { - /* TODO: Uses fatal errors */ + if (skipFunction($function)) { return; } diff --git a/Zend/tests/arginfo_zpp_mismatch_strict.phpt b/Zend/tests/arginfo_zpp_mismatch_strict.phpt new file mode 100644 index 0000000000..8e77af9fb4 --- /dev/null +++ b/Zend/tests/arginfo_zpp_mismatch_strict.phpt @@ -0,0 +1,85 @@ +--TEST-- +Test that there is no arginfo/zpp mismatch in strict mode +--SKIPIF-- +<?php +if (getenv('SKIP_MSAN')) die("skip msan misses interceptors for some functions"); +?> +--FILE-- +<?php + +declare(strict_types=1); + +require __DIR__ . "/arginfo_zpp_mismatch.inc"; + +function test($function) { + if (skipFunction($function)) { + return; + } + + ob_start(); + if (is_string($function)) { + echo "Testing $function\n"; + } else { + echo "Testing " . get_class($function[0]) . "::$function[1]\n"; + } + try { + @$function(); + } catch (Throwable) { + } + try { + @$function(null); + } catch (Throwable) { + } + try { + @$function(null, null); + } catch (Throwable) { + } + try { + @$function(null, null, null); + } catch (Throwable) { + } + try { + @$function(null, null, null, null); + } catch (Throwable) { + } + try { + @$function(null, null, null, null, null); + } catch (Throwable) { + } + try { + @$function(null, null, null, null, null, null); + } catch (Throwable) { + } + try { + @$function(null, null, null, null, null, null, null); + } catch (Throwable) { + } + try { + @$function(null, null, null, null, null, null, null, null); + } catch (Throwable) { + } + ob_end_clean(); +} + +foreach (get_defined_functions()["internal"] as $function) { + test($function); +} + +foreach (get_declared_classes() as $class) { + try { + $rc = new ReflectionClass($class); + $obj = $rc->newInstanceWithoutConstructor(); + } catch (Throwable) { + continue; + } + + foreach (get_class_methods($class) as $method) { + test([$obj, $method]); + } +} + +// var_dump() and debug_zval_dump() print all arguments +?> +===DONE=== +--EXPECT-- +===DONE=== |