]> granicus.if.org Git - php/commitdiff
More arginfo/zpp verification
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 21 Jul 2020 14:21:14 +0000 (16:21 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 14 Oct 2020 14:26:09 +0000 (16:26 +0200)
Run all functions with a varying number of null arguments, which
helps us flush out all kinds of bugs.

Closes GH-5881.

Zend/tests/arginfo_zpp_mismatch.phpt

index 39a174274396a10ba1f5888f4acc56629c47ba30..cd37fbf33a2284de69f95a2424892636134e21b8 100644 (file)
@@ -4,10 +4,83 @@ Test that there is no arginfo/zpp mismatch
 <?php
 
 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 */
+        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) {
@@ -29,20 +102,6 @@ foreach (get_declared_classes() as $class) {
 
 // var_dump() and debug_zval_dump() print all arguments
 ?>
+===DONE===
 --EXPECT--
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
+===DONE===