From 6f3a11d75b38a8e385bf2538dec279e4248d68d2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 00:33:32 +0100 Subject: [PATCH 01/13] Add generated test extension --- ext/test/.gitignore | 35 ++++++++++++++ ext/test/CREDITS | 1 + ext/test/EXPERIMENTAL | 0 ext/test/config.m4 | 63 ++++++++++++++++++++++++ ext/test/config.w32 | 13 +++++ ext/test/php_test.h | 58 ++++++++++++++++++++++ ext/test/test.c | 103 ++++++++++++++++++++++++++++++++++++++++ ext/test/tests/001.phpt | 21 ++++++++ 8 files changed, 294 insertions(+) create mode 100644 ext/test/.gitignore create mode 100644 ext/test/CREDITS create mode 100644 ext/test/EXPERIMENTAL create mode 100644 ext/test/config.m4 create mode 100644 ext/test/config.w32 create mode 100644 ext/test/php_test.h create mode 100644 ext/test/test.c create mode 100644 ext/test/tests/001.phpt diff --git a/ext/test/.gitignore b/ext/test/.gitignore new file mode 100644 index 0000000000000..f195b609ac451 --- /dev/null +++ b/ext/test/.gitignore @@ -0,0 +1,35 @@ +.deps +*.lo +*.la +.libs +acinclude.m4 +aclocal.m4 +autom4te.cache +build +config.guess +config.h +config.h.in +config.log +config.nice +config.status +config.sub +configure +configure.ac +include +install-sh +libtool +ltmain.sh +Makefile +Makefile.fragments +Makefile.global +Makefile.objects +missing +mkinstalldirs +modules +run-tests.php +tests/*/*.diff +tests/*/*.out +tests/*/*.php +tests/*/*.exp +tests/*/*.log +tests/*/*.sh diff --git a/ext/test/CREDITS b/ext/test/CREDITS new file mode 100644 index 0000000000000..30d74d258442c --- /dev/null +++ b/ext/test/CREDITS @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/ext/test/EXPERIMENTAL b/ext/test/EXPERIMENTAL new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/ext/test/config.m4 b/ext/test/config.m4 new file mode 100644 index 0000000000000..2715e642236bc --- /dev/null +++ b/ext/test/config.m4 @@ -0,0 +1,63 @@ +dnl $Id$ +dnl config.m4 for extension test + +dnl Comments in this file start with the string 'dnl'. +dnl Remove where necessary. This file will not work +dnl without editing. + +dnl If your extension references something external, use with: + +dnl PHP_ARG_WITH(test, for test support, +dnl Make sure that the comment is aligned: +dnl [ --with-test Include test support]) + +dnl Otherwise use enable: + +dnl PHP_ARG_ENABLE(test, whether to enable test support, +dnl Make sure that the comment is aligned: +dnl [ --enable-test Enable test support]) + +if test "$PHP_TEST" != "no"; then + dnl Write more examples of tests here... + + dnl # --with-test -> check with-path + dnl SEARCH_PATH="/usr/local /usr" # you might want to change this + dnl SEARCH_FOR="/include/test.h" # you most likely want to change this + dnl if test -r $PHP_TEST/$SEARCH_FOR; then # path given as parameter + dnl TEST_DIR=$PHP_TEST + dnl else # search default path list + dnl AC_MSG_CHECKING([for test files in default path]) + dnl for i in $SEARCH_PATH ; do + dnl if test -r $i/$SEARCH_FOR; then + dnl TEST_DIR=$i + dnl AC_MSG_RESULT(found in $i) + dnl fi + dnl done + dnl fi + dnl + dnl if test -z "$TEST_DIR"; then + dnl AC_MSG_RESULT([not found]) + dnl AC_MSG_ERROR([Please reinstall the test distribution]) + dnl fi + + dnl # --with-test -> add include path + dnl PHP_ADD_INCLUDE($TEST_DIR/include) + + dnl # --with-test -> check for lib and symbol presence + dnl LIBNAME=test # you may want to change this + dnl LIBSYMBOL=test # you most likely want to change this + + dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, + dnl [ + dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $TEST_DIR/$PHP_LIBDIR, TEST_SHARED_LIBADD) + dnl AC_DEFINE(HAVE_TESTLIB,1,[ ]) + dnl ],[ + dnl AC_MSG_ERROR([wrong test lib version or lib not found]) + dnl ],[ + dnl -L$TEST_DIR/$PHP_LIBDIR -lm + dnl ]) + dnl + dnl PHP_SUBST(TEST_SHARED_LIBADD) + + PHP_NEW_EXTENSION(test, test.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) +fi diff --git a/ext/test/config.w32 b/ext/test/config.w32 new file mode 100644 index 0000000000000..8f976338a8f27 --- /dev/null +++ b/ext/test/config.w32 @@ -0,0 +1,13 @@ +// $Id$ +// vim:ft=javascript + +// If your extension references something external, use ARG_WITH +// ARG_WITH("test", "for test support", "no"); + +// Otherwise, use ARG_ENABLE +// ARG_ENABLE("test", "enable test support", "no"); + +if (PHP_TEST != "no") { + EXTENSION("test", "test.c", PHP_EXTNAME_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); +} + diff --git a/ext/test/php_test.h b/ext/test/php_test.h new file mode 100644 index 0000000000000..cbf67cabc34dc --- /dev/null +++ b/ext/test/php_test.h @@ -0,0 +1,58 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2017 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef PHP_TEST_H +#define PHP_TEST_H + +extern zend_module_entry test_module_entry; +#define phpext_test_ptr &test_module_entry + +#define PHP_TEST_VERSION "0.1.0" + +#ifdef PHP_WIN32 +# define PHP_TEST_API __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define PHP_TEST_API __attribute__ ((visibility("default"))) +#else +# define PHP_TEST_API +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + + +#define TEST_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(test, v) + +#if defined(ZTS) && defined(COMPILE_DL_TEST) +ZEND_TSRMLS_CACHE_EXTERN() +#endif + +#endif + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/test/test.c b/ext/test/test.c new file mode 100644 index 0000000000000..9dcb05eec9d9c --- /dev/null +++ b/ext/test/test.c @@ -0,0 +1,103 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2017 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_test.h" + + + +static int le_test; + + + + + + + +PHP_MINIT_FUNCTION(test) +{ + return SUCCESS; +} + + +PHP_MSHUTDOWN_FUNCTION(test) +{ + return SUCCESS; +} + + + +PHP_RINIT_FUNCTION(test) +{ +#if defined(COMPILE_DL_TEST) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE(); +#endif + return SUCCESS; +} + + + +PHP_RSHUTDOWN_FUNCTION(test) +{ + return SUCCESS; +} + + +PHP_MINFO_FUNCTION(test) +{ + php_info_print_table_start(); + php_info_print_table_header(2, "test support", "enabled"); + php_info_print_table_end(); + +} + + +const zend_function_entry test_functions[] = { + PHP_FE_END +}; + + +zend_module_entry test_module_entry = { + STANDARD_MODULE_HEADER, + "test", + test_functions, + PHP_MINIT(test), + PHP_MSHUTDOWN(test), + PHP_RINIT(test), + PHP_RSHUTDOWN(test), + PHP_MINFO(test), + PHP_TEST_VERSION, + STANDARD_MODULE_PROPERTIES +}; + + +#ifdef COMPILE_DL_TEST +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE() +#endif +ZEND_GET_MODULE(test) +#endif + diff --git a/ext/test/tests/001.phpt b/ext/test/tests/001.phpt new file mode 100644 index 0000000000000..ade884f0af130 --- /dev/null +++ b/ext/test/tests/001.phpt @@ -0,0 +1,21 @@ +--TEST-- +Check for test presence +--SKIPIF-- + +--FILE-- + +--EXPECT-- +test extension is available From 521c77b7158145d8e547cfd1c596717dcb633b0f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 00:38:51 +0100 Subject: [PATCH 02/13] Clean out generated code --- ext/test/.gitignore | 35 ------------------------- ext/test/CREDITS | 1 - ext/test/EXPERIMENTAL | 0 ext/test/config.m4 | 61 ++----------------------------------------- ext/test/config.w32 | 7 +---- ext/test/php_test.h | 1 - ext/test/test.c | 23 +--------------- 7 files changed, 4 insertions(+), 124 deletions(-) delete mode 100644 ext/test/.gitignore delete mode 100644 ext/test/CREDITS delete mode 100644 ext/test/EXPERIMENTAL diff --git a/ext/test/.gitignore b/ext/test/.gitignore deleted file mode 100644 index f195b609ac451..0000000000000 --- a/ext/test/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -.deps -*.lo -*.la -.libs -acinclude.m4 -aclocal.m4 -autom4te.cache -build -config.guess -config.h -config.h.in -config.log -config.nice -config.status -config.sub -configure -configure.ac -include -install-sh -libtool -ltmain.sh -Makefile -Makefile.fragments -Makefile.global -Makefile.objects -missing -mkinstalldirs -modules -run-tests.php -tests/*/*.diff -tests/*/*.out -tests/*/*.php -tests/*/*.exp -tests/*/*.log -tests/*/*.sh diff --git a/ext/test/CREDITS b/ext/test/CREDITS deleted file mode 100644 index 30d74d258442c..0000000000000 --- a/ext/test/CREDITS +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/ext/test/EXPERIMENTAL b/ext/test/EXPERIMENTAL deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/ext/test/config.m4 b/ext/test/config.m4 index 2715e642236bc..ce301d6d1e78f 100644 --- a/ext/test/config.m4 +++ b/ext/test/config.m4 @@ -1,63 +1,6 @@ -dnl $Id$ -dnl config.m4 for extension test - -dnl Comments in this file start with the string 'dnl'. -dnl Remove where necessary. This file will not work -dnl without editing. - -dnl If your extension references something external, use with: - -dnl PHP_ARG_WITH(test, for test support, -dnl Make sure that the comment is aligned: -dnl [ --with-test Include test support]) - -dnl Otherwise use enable: - -dnl PHP_ARG_ENABLE(test, whether to enable test support, -dnl Make sure that the comment is aligned: -dnl [ --enable-test Enable test support]) +PHP_ARG_ENABLE(test, whether to enable test extension, +[ --enable-test Enable test extension]) if test "$PHP_TEST" != "no"; then - dnl Write more examples of tests here... - - dnl # --with-test -> check with-path - dnl SEARCH_PATH="/usr/local /usr" # you might want to change this - dnl SEARCH_FOR="/include/test.h" # you most likely want to change this - dnl if test -r $PHP_TEST/$SEARCH_FOR; then # path given as parameter - dnl TEST_DIR=$PHP_TEST - dnl else # search default path list - dnl AC_MSG_CHECKING([for test files in default path]) - dnl for i in $SEARCH_PATH ; do - dnl if test -r $i/$SEARCH_FOR; then - dnl TEST_DIR=$i - dnl AC_MSG_RESULT(found in $i) - dnl fi - dnl done - dnl fi - dnl - dnl if test -z "$TEST_DIR"; then - dnl AC_MSG_RESULT([not found]) - dnl AC_MSG_ERROR([Please reinstall the test distribution]) - dnl fi - - dnl # --with-test -> add include path - dnl PHP_ADD_INCLUDE($TEST_DIR/include) - - dnl # --with-test -> check for lib and symbol presence - dnl LIBNAME=test # you may want to change this - dnl LIBSYMBOL=test # you most likely want to change this - - dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, - dnl [ - dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $TEST_DIR/$PHP_LIBDIR, TEST_SHARED_LIBADD) - dnl AC_DEFINE(HAVE_TESTLIB,1,[ ]) - dnl ],[ - dnl AC_MSG_ERROR([wrong test lib version or lib not found]) - dnl ],[ - dnl -L$TEST_DIR/$PHP_LIBDIR -lm - dnl ]) - dnl - dnl PHP_SUBST(TEST_SHARED_LIBADD) - PHP_NEW_EXTENSION(test, test.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) fi diff --git a/ext/test/config.w32 b/ext/test/config.w32 index 8f976338a8f27..f62833e6a9d73 100644 --- a/ext/test/config.w32 +++ b/ext/test/config.w32 @@ -1,11 +1,6 @@ -// $Id$ // vim:ft=javascript -// If your extension references something external, use ARG_WITH -// ARG_WITH("test", "for test support", "no"); - -// Otherwise, use ARG_ENABLE -// ARG_ENABLE("test", "enable test support", "no"); +ARG_ENABLE("test", "enable test extension", "no"); if (PHP_TEST != "no") { EXTENSION("test", "test.c", PHP_EXTNAME_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); diff --git a/ext/test/php_test.h b/ext/test/php_test.h index cbf67cabc34dc..8ddc52d39e776 100644 --- a/ext/test/php_test.h +++ b/ext/test/php_test.h @@ -38,7 +38,6 @@ extern zend_module_entry test_module_entry; #include "TSRM.h" #endif - #define TEST_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(test, v) #if defined(ZTS) && defined(COMPILE_DL_TEST) diff --git a/ext/test/test.c b/ext/test/test.c index 9dcb05eec9d9c..ee50b742cb56d 100644 --- a/ext/test/test.c +++ b/ext/test/test.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -27,16 +25,6 @@ #include "ext/standard/info.h" #include "php_test.h" - - -static int le_test; - - - - - - - PHP_MINIT_FUNCTION(test) { return SUCCESS; @@ -48,8 +36,6 @@ PHP_MSHUTDOWN_FUNCTION(test) return SUCCESS; } - - PHP_RINIT_FUNCTION(test) { #if defined(COMPILE_DL_TEST) && defined(ZTS) @@ -58,28 +44,22 @@ PHP_RINIT_FUNCTION(test) return SUCCESS; } - - PHP_RSHUTDOWN_FUNCTION(test) { return SUCCESS; } - PHP_MINFO_FUNCTION(test) { php_info_print_table_start(); - php_info_print_table_header(2, "test support", "enabled"); + php_info_print_table_header(2, "test extension", "enabled"); php_info_print_table_end(); - } - const zend_function_entry test_functions[] = { PHP_FE_END }; - zend_module_entry test_module_entry = { STANDARD_MODULE_HEADER, "test", @@ -93,7 +73,6 @@ zend_module_entry test_module_entry = { STANDARD_MODULE_PROPERTIES }; - #ifdef COMPILE_DL_TEST #ifdef ZTS ZEND_TSRMLS_CACHE_DEFINE() From 3943f482460f1c56c84fdf78c52ba1bdb014c395 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 00:46:59 +0100 Subject: [PATCH 03/13] Move test functions into test extension --- Zend/zend_builtin_functions.c | 119 +--------------------------------- ext/test/test.c | 101 ++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 118 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 55d1209ae0e8d..f09dba62521b3 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -31,13 +31,6 @@ #undef ZEND_TEST_EXCEPTIONS -#if ZEND_DEBUG -static zend_class_entry *zend_test_interface; -static zend_class_entry *zend_test_class; -static zend_class_entry *zend_test_trait; -static zend_object_handlers zend_test_class_handlers; -#endif - static ZEND_FUNCTION(zend_version); static ZEND_FUNCTION(func_num_args); static ZEND_FUNCTION(func_get_arg); @@ -93,13 +86,9 @@ static ZEND_FUNCTION(get_extension_funcs); static ZEND_FUNCTION(get_defined_constants); static ZEND_FUNCTION(debug_backtrace); static ZEND_FUNCTION(debug_print_backtrace); -#if ZEND_DEBUG -static ZEND_FUNCTION(zend_test_func); -static ZEND_FUNCTION(zend_test_func2); -#ifdef ZTS +#if ZEND_DEBUG && defined(ZTS) static ZEND_FUNCTION(zend_thread_id); #endif -#endif static ZEND_FUNCTION(gc_mem_caches); static ZEND_FUNCTION(gc_collect_cycles); static ZEND_FUNCTION(gc_enabled); @@ -255,70 +244,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1) ZEND_ARG_INFO(0, extension_name) ZEND_END_ARG_INFO() -#if ZEND_DEBUG -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func, IS_ARRAY, 0) -ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func2, IS_ARRAY, 1) -ZEND_END_ARG_INFO() -#endif - -/* }}} */ - -#if ZEND_DEBUG -static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */ { - zend_object *obj = zend_objects_new(class_type); - obj->handlers = &zend_test_class_handlers; - return obj; -} -/* }}} */ - -static zend_function *zend_test_class_method_get(zend_object **object, zend_string *name, const zval *key) /* {{{ */ { - zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); - fptr->type = ZEND_OVERLOADED_FUNCTION_TEMPORARY; - fptr->num_args = 1; - fptr->arg_info = NULL; - fptr->scope = (*object)->ce; - fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER; - fptr->function_name = zend_string_copy(name); - fptr->handler = ZEND_FN(zend_test_func); - zend_set_function_arg_flags((zend_function*)fptr); - - return (zend_function*)fptr; -} -/* }}} */ - -static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ { - zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); - fptr->type = ZEND_OVERLOADED_FUNCTION; - fptr->num_args = 1; - fptr->arg_info = NULL; - fptr->scope = ce; - fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC; - fptr->function_name = name; - fptr->handler = ZEND_FN(zend_test_func); - zend_set_function_arg_flags((zend_function*)fptr); - - return (zend_function*)fptr; -} -/* }}} */ - -static int zend_test_class_call_method(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ { - RETVAL_STR(zend_string_copy(method)); - return 0; -} -/* }}} */ - -static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ { - RETURN_TRUE; -} /* }}} */ -static zend_function_entry zend_test_trait_methods[] = { - ZEND_ME(_ZendTestTrait, testMethod, arginfo_zend__void, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; -#endif - static const zend_function_entry builtin_functions[] = { /* {{{ */ ZEND_FE(zend_version, arginfo_zend__void) ZEND_FE(func_num_args, arginfo_zend__void) @@ -377,12 +304,8 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */ ZEND_FE(get_defined_constants, arginfo_get_defined_constants) ZEND_FE(debug_backtrace, arginfo_debug_backtrace) ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace) -#if ZEND_DEBUG - ZEND_FE(zend_test_func, arginfo_zend_test_func) - ZEND_FE(zend_test_func2, arginfo_zend_test_func2) -#ifdef ZTS +#if ZEND_DEBUG && defined(ZTS) ZEND_FE(zend_thread_id, NULL) -#endif #endif ZEND_FE(gc_mem_caches, arginfo_zend__void) ZEND_FE(gc_collect_cycles, arginfo_zend__void) @@ -401,26 +324,6 @@ ZEND_MINIT_FUNCTION(core) { /* {{{ */ zend_register_default_classes(); -#if ZEND_DEBUG - INIT_CLASS_ENTRY(class_entry, "_ZendTestInterface", NULL); - zend_test_interface = zend_register_internal_interface(&class_entry); - zend_declare_class_constant_long(zend_test_interface, ZEND_STRL("DUMMY"), 0); - INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", NULL); - zend_test_class = zend_register_internal_class_ex(&class_entry, NULL); - zend_class_implements(zend_test_class, 1, zend_test_interface); - zend_test_class->create_object = zend_test_class_new; - zend_test_class->get_static_method = zend_test_class_static_method_get; - - memcpy(&zend_test_class_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - zend_test_class_handlers.get_method = zend_test_class_method_get; - zend_test_class_handlers.call_method = zend_test_class_call_method; - - INIT_CLASS_ENTRY(class_entry, "_ZendTestTrait", zend_test_trait_methods); - zend_test_trait = zend_register_internal_class(&class_entry); - zend_test_trait->ce_flags |= ZEND_ACC_TRAIT; - zend_declare_property_null(zend_test_trait, "testProp", sizeof("testProp")-1, ZEND_ACC_PUBLIC); -#endif - return SUCCESS; } /* }}} */ @@ -2095,28 +1998,12 @@ ZEND_FUNCTION(create_function) } /* }}} */ -#if ZEND_DEBUG -ZEND_FUNCTION(zend_test_func) -{ - zval *arg1, *arg2; - - zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2); -} - -ZEND_FUNCTION(zend_test_func2) -{ - zval *arg1, *arg2; - - zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2); -} - -#ifdef ZTS +#if ZEND_DEBUG && defined(ZTS) ZEND_FUNCTION(zend_thread_id) { RETURN_LONG((zend_long)tsrm_thread_id()); } #endif -#endif /* {{{ proto string get_resource_type(resource res) Get the resource type name for a given resource */ diff --git a/ext/test/test.c b/ext/test/test.c index ee50b742cb56d..67cabd71dfe4c 100644 --- a/ext/test/test.c +++ b/ext/test/test.c @@ -25,12 +25,107 @@ #include "ext/standard/info.h" #include "php_test.h" +static zend_class_entry *zend_test_interface; +static zend_class_entry *zend_test_class; +static zend_class_entry *zend_test_trait; +static zend_object_handlers zend_test_class_handlers; + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func, IS_ARRAY, 0) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func2, IS_ARRAY, 1) +ZEND_END_ARG_INFO() + +ZEND_FUNCTION(zend_test_func) +{ + zval *arg1, *arg2; + + zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2); +} + +ZEND_FUNCTION(zend_test_func2) +{ + zval *arg1, *arg2; + + zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2); +} + +static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */ { + zend_object *obj = zend_objects_new(class_type); + obj->handlers = &zend_test_class_handlers; + return obj; +} +/* }}} */ + +static zend_function *zend_test_class_method_get(zend_object **object, zend_string *name, const zval *key) /* {{{ */ { + zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); + fptr->type = ZEND_OVERLOADED_FUNCTION_TEMPORARY; + fptr->num_args = 1; + fptr->arg_info = NULL; + fptr->scope = (*object)->ce; + fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER; + fptr->function_name = zend_string_copy(name); + fptr->handler = ZEND_FN(zend_test_func); + zend_set_function_arg_flags((zend_function*)fptr); + + return (zend_function*)fptr; +} +/* }}} */ + +static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ { + zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); + fptr->type = ZEND_OVERLOADED_FUNCTION; + fptr->num_args = 1; + fptr->arg_info = NULL; + fptr->scope = ce; + fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC; + fptr->function_name = name; + fptr->handler = ZEND_FN(zend_test_func); + zend_set_function_arg_flags((zend_function*)fptr); + + return (zend_function*)fptr; +} +/* }}} */ + +static int zend_test_class_call_method(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ { + RETVAL_STR(zend_string_copy(method)); + return 0; +} +/* }}} */ + +static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ { + RETURN_TRUE; +} +/* }}} */ + +static zend_function_entry zend_test_trait_methods[] = { + ZEND_ME(_ZendTestTrait, testMethod, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + PHP_MINIT_FUNCTION(test) { + zend_class_entry class_entry; + + INIT_CLASS_ENTRY(class_entry, "_ZendTestInterface", NULL); + zend_test_interface = zend_register_internal_interface(&class_entry); + zend_declare_class_constant_long(zend_test_interface, ZEND_STRL("DUMMY"), 0); + INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", NULL); + zend_test_class = zend_register_internal_class_ex(&class_entry, NULL); + zend_class_implements(zend_test_class, 1, zend_test_interface); + zend_test_class->create_object = zend_test_class_new; + zend_test_class->get_static_method = zend_test_class_static_method_get; + + memcpy(&zend_test_class_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + zend_test_class_handlers.get_method = zend_test_class_method_get; + zend_test_class_handlers.call_method = zend_test_class_call_method; + + INIT_CLASS_ENTRY(class_entry, "_ZendTestTrait", zend_test_trait_methods); + zend_test_trait = zend_register_internal_class(&class_entry); + zend_test_trait->ce_flags |= ZEND_ACC_TRAIT; + zend_declare_property_null(zend_test_trait, "testProp", sizeof("testProp")-1, ZEND_ACC_PUBLIC); return SUCCESS; } - PHP_MSHUTDOWN_FUNCTION(test) { return SUCCESS; @@ -57,7 +152,9 @@ PHP_MINFO_FUNCTION(test) } const zend_function_entry test_functions[] = { - PHP_FE_END + ZEND_FE(zend_test_func, arginfo_zend_test_func) + ZEND_FE(zend_test_func2, arginfo_zend_test_func2) + ZEND_FE_END }; zend_module_entry test_module_entry = { From 0f6a5fba9d4c798f1e61b1c7acf958c36fcbf116 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 01:02:48 +0100 Subject: [PATCH 04/13] Add zend_create_unterminated_string() And test parse_url() with it. --- .../tests/url/parse_url_unterminated.phpt | 887 ++++++++++++++++++ ext/test/test.c | 41 +- 2 files changed, 926 insertions(+), 2 deletions(-) create mode 100644 ext/standard/tests/url/parse_url_unterminated.phpt diff --git a/ext/standard/tests/url/parse_url_unterminated.phpt b/ext/standard/tests/url/parse_url_unterminated.phpt new file mode 100644 index 0000000000000..292f34febadf0 --- /dev/null +++ b/ext/standard/tests/url/parse_url_unterminated.phpt @@ -0,0 +1,887 @@ +--TEST-- +Test parse_url() function: Parse unterminated string +--SKIPIF-- + +--FILE-- + $url: "; + $str = zend_create_unterminated_string($url); + var_dump(parse_url($str)); + zend_terminate_string($str); +} + +echo "Done"; +?> +--EXPECTF-- + +--> 64.246.30.37: array(1) { + ["path"]=> + string(12) "64.246.30.37" +} + +--> http://64.246.30.37: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(12) "64.246.30.37" +} + +--> http://64.246.30.37/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(12) "64.246.30.37" + ["path"]=> + string(1) "/" +} + +--> 64.246.30.37/: array(1) { + ["path"]=> + string(13) "64.246.30.37/" +} + +--> 64.246.30.37:80/: array(3) { + ["host"]=> + string(12) "64.246.30.37" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> php.net: array(1) { + ["path"]=> + string(7) "php.net" +} + +--> php.net/: array(1) { + ["path"]=> + string(8) "php.net/" +} + +--> http://php.net: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(7) "php.net" +} + +--> http://php.net/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(7) "php.net" + ["path"]=> + string(1) "/" +} + +--> www.php.net: array(1) { + ["path"]=> + string(11) "www.php.net" +} + +--> www.php.net/: array(1) { + ["path"]=> + string(12) "www.php.net/" +} + +--> http://www.php.net: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" +} + +--> http://www.php.net/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(1) "/" +} + +--> www.php.net:80: array(2) { + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) +} + +--> http://www.php.net:80: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) +} + +--> http://www.php.net:80/: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> http://www.php.net/index.php: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(10) "/index.php" +} + +--> www.php.net/?: array(1) { + ["path"]=> + string(12) "www.php.net/" +} + +--> www.php.net:80/?: array(3) { + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> http://www.php.net/?: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(1) "/" +} + +--> http://www.php.net:80/?: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> http://www.php.net:80/index.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" +} + +--> http://www.php.net:80/foo/bar/index.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(18) "/foo/bar/index.php" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(53) "/this/is/a/very/deep/directory/structure/and/file.php" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(53) "/this/is/a/very/deep/directory/structure/and/file.php" + ["query"]=> + string(37) "lots=1&of=2¶meters=3&too=4&here=5" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(45) "/this/is/a/very/deep/directory/structure/and/" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(53) "/this/is/a/very/deep/directory/structure/and/file.php" +} + +--> http://www.php.net:80/this/../a/../deep/directory: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(28) "/this/../a/../deep/directory" +} + +--> http://www.php.net:80/this/../a/../deep/directory/: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(29) "/this/../a/../deep/directory/" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(42) "/this/is/a/very/deep/directory/../file.php" +} + +--> http://www.php.net:80/index.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" +} + +--> http://www.php.net:80/index.php?: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" +} + +--> http://www.php.net:80/#foo: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" + ["fragment"]=> + string(3) "foo" +} + +--> http://www.php.net:80/?#: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> http://www.php.net:80/?test=1: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" + ["query"]=> + string(6) "test=1" +} + +--> http://www.php.net/?test=1&: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(1) "/" + ["query"]=> + string(7) "test=1&" +} + +--> http://www.php.net:80/?&: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" + ["query"]=> + string(1) "&" +} + +--> http://www.php.net:80/index.php?test=1&: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(7) "test=1&" +} + +--> http://www.php.net/index.php?&: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(1) "&" +} + +--> http://www.php.net:80/index.php?foo&: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(4) "foo&" +} + +--> http://www.php.net/index.php?&foo: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(4) "&foo" +} + +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" +} + +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(5) { + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(6) "secret" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["user"]=> + string(6) "secret" + ["pass"]=> + string(0) "" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(0) "" + ["pass"]=> + string(7) "hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["user"]=> + string(6) "secret" + ["pass"]=> + string(7) "hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(14) "secret@hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(6) "secret" + ["pass"]=> + string(7) "hid:out" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> nntp://news.php.net: array(2) { + ["scheme"]=> + string(4) "nntp" + ["host"]=> + string(12) "news.php.net" +} + +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) { + ["scheme"]=> + string(3) "ftp" + ["host"]=> + string(11) "ftp.gnu.org" + ["path"]=> + string(22) "/gnu/glic/glibc.tar.gz" +} + +--> zlib:http://foo@bar: array(2) { + ["scheme"]=> + string(4) "zlib" + ["path"]=> + string(14) "http://foo@bar" +} + +--> zlib:filename.txt: array(2) { + ["scheme"]=> + string(4) "zlib" + ["path"]=> + string(12) "filename.txt" +} + +--> zlib:/path/to/my/file/file.txt: array(2) { + ["scheme"]=> + string(4) "zlib" + ["path"]=> + string(25) "/path/to/my/file/file.txt" +} + +--> foo://foo@bar: array(3) { + ["scheme"]=> + string(3) "foo" + ["host"]=> + string(3) "bar" + ["user"]=> + string(3) "foo" +} + +--> mailto:me@mydomain.com: array(2) { + ["scheme"]=> + string(6) "mailto" + ["path"]=> + string(15) "me@mydomain.com" +} + +--> /foo.php?a=b&c=d: array(2) { + ["path"]=> + string(8) "/foo.php" + ["query"]=> + string(7) "a=b&c=d" +} + +--> foo.php?a=b&c=d: array(2) { + ["path"]=> + string(7) "foo.php" + ["query"]=> + string(7) "a=b&c=d" +} + +--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(15) "www.example.com" + ["port"]=> + int(8080) + ["user"]=> + string(4) "user" + ["pass"]=> + string(6) "passwd" + ["query"]=> + string(12) "bar=1&boom=0" +} + +--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0: array(6) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(15) "www.example.com" + ["port"]=> + int(8080) + ["user"]=> + string(11) "user_me-you" + ["pass"]=> + string(11) "my_pas-word" + ["query"]=> + string(12) "bar=1&boom=0" +} + +--> file:///path/to/file: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(13) "/path/to/file" +} + +--> file://path/to/file: array(3) { + ["scheme"]=> + string(4) "file" + ["host"]=> + string(4) "path" + ["path"]=> + string(8) "/to/file" +} + +--> file:/path/to/file: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(13) "/path/to/file" +} + +--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(7) "1.2.3.4" + ["path"]=> + string(8) "/abc.asp" + ["query"]=> + string(7) "a=1&b=2" +} + +--> http://foo.com#bar: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(7) "foo.com" + ["fragment"]=> + string(3) "bar" +} + +--> scheme:: array(1) { + ["scheme"]=> + string(6) "scheme" +} + +--> foo+bar://baz@bang/bla: array(4) { + ["scheme"]=> + string(7) "foo+bar" + ["host"]=> + string(4) "bang" + ["user"]=> + string(3) "baz" + ["path"]=> + string(4) "/bla" +} + +--> gg:9130731: array(2) { + ["scheme"]=> + string(2) "gg" + ["path"]=> + string(7) "9130731" +} + +--> http://user:@pass@host/path?argument?value#etc: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(4) "host" + ["user"]=> + string(4) "user" + ["pass"]=> + string(5) "@pass" + ["path"]=> + string(5) "/path" + ["query"]=> + string(14) "argument?value" + ["fragment"]=> + string(3) "etc" +} + +--> http://10.10.10.10/:80: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "10.10.10.10" + ["path"]=> + string(4) "/:80" +} + +--> http://x:?: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(1) "x" +} + +--> x:blah.com: array(2) { + ["scheme"]=> + string(1) "x" + ["path"]=> + string(8) "blah.com" +} + +--> x:/blah.com: array(2) { + ["scheme"]=> + string(1) "x" + ["path"]=> + string(9) "/blah.com" +} + +--> x://::abc/?: bool(false) + +--> http://::?: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(1) ":" +} + +--> http://::#: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(1) ":" +} + +--> x://::6.5: array(3) { + ["scheme"]=> + string(1) "x" + ["host"]=> + string(1) ":" + ["port"]=> + int(6) +} + +--> http://?:/: bool(false) + +--> http://@?:/: bool(false) + +--> file:///:: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(2) "/:" +} + +--> file:///a:/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(3) "a:/" +} + +--> file:///ab:/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(5) "/ab:/" +} + +--> file:///a:/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(3) "a:/" +} + +--> file:///@:/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(3) "@:/" +} + +--> file:///:80/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(5) "/:80/" +} + +--> []: array(1) { + ["path"]=> + string(2) "[]" +} + +--> http://[x:80]/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(6) "[x:80]" + ["path"]=> + string(1) "/" +} + +--> : array(1) { + ["path"]=> + string(0) "" +} + +--> /: array(1) { + ["path"]=> + string(1) "/" +} + +--> /rest/Users?filter={"id":"123"}: array(2) { + ["path"]=> + string(11) "/rest/Users" + ["query"]=> + string(19) "filter={"id":"123"}" +} + +--> http:///blah.com: bool(false) + +--> http://:80: bool(false) + +--> http://user@:80: bool(false) + +--> http://user:pass@:80: bool(false) + +--> http://:: bool(false) + +--> http://@/: bool(false) + +--> http://@:/: bool(false) + +--> http://:/: bool(false) + +--> http://?: bool(false) + +--> http://#: bool(false) + +--> http://?:: bool(false) + +--> http://:?: bool(false) + +--> http://blah.com:123456: bool(false) + +--> http://blah.com:abcdef: bool(false) +Done diff --git a/ext/test/test.c b/ext/test/test.c index 67cabd71dfe4c..5e4f323327b71 100644 --- a/ext/test/test.c +++ b/ext/test/test.c @@ -32,9 +32,14 @@ static zend_object_handlers zend_test_class_handlers; ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func, IS_ARRAY, 0) ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func2, IS_ARRAY, 1) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_terminate_string, 0, 0, 1) + ZEND_ARG_INFO(1, str) +ZEND_END_ARG_INFO() + ZEND_FUNCTION(zend_test_func) { zval *arg1, *arg2; @@ -49,6 +54,36 @@ ZEND_FUNCTION(zend_test_func2) zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2); } +/* Create a string without terminating null byte. Must be termined with + * zend_terminate_string() before destruction, otherwise a warning is issued + * in debug builds. */ +ZEND_FUNCTION(zend_create_unterminated_string) +{ + zend_string *str, *res; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &str) == FAILURE) { + return; + } + + res = zend_string_alloc(ZSTR_LEN(str), 0); + memcpy(ZSTR_VAL(res), ZSTR_VAL(str), ZSTR_LEN(str)); + /* No trailing null byte */ + + RETURN_STR(res); +} + +/* Enforce terminate null byte on string. This avoids a warning in debug builds. */ +ZEND_FUNCTION(zend_terminate_string) +{ + zend_string *str; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &str) == FAILURE) { + return; + } + + ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0'; +} + static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */ { zend_object *obj = zend_objects_new(class_type); obj->handlers = &zend_test_class_handlers; @@ -152,8 +187,10 @@ PHP_MINFO_FUNCTION(test) } const zend_function_entry test_functions[] = { - ZEND_FE(zend_test_func, arginfo_zend_test_func) - ZEND_FE(zend_test_func2, arginfo_zend_test_func2) + ZEND_FE(zend_test_func, arginfo_zend_test_func) + ZEND_FE(zend_test_func2, arginfo_zend_test_func2) + ZEND_FE(zend_create_unterminated_string, NULL) + ZEND_FE(zend_terminate_string, arginfo_zend_terminate_string) ZEND_FE_END }; From 8e670a6fc2b47f0b5b5c80d465d356240f552d77 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 01:03:29 +0100 Subject: [PATCH 05/13] Remove dummy test --- ext/test/tests/001.phpt | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 ext/test/tests/001.phpt diff --git a/ext/test/tests/001.phpt b/ext/test/tests/001.phpt deleted file mode 100644 index ade884f0af130..0000000000000 --- a/ext/test/tests/001.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Check for test presence ---SKIPIF-- - ---FILE-- - ---EXPECT-- -test extension is available From b8261794149f0d440f1080774e74a9da89c5f0c0 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 01:07:36 +0100 Subject: [PATCH 06/13] Move leak(), leak_variable() into ext/test --- Zend/zend_builtin_functions.c | 49 ------------------- .../tests/url/parse_url_unterminated.phpt | 2 +- ext/test/test.c | 44 +++++++++++++++++ 3 files changed, 45 insertions(+), 50 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index f09dba62521b3..41e529755f9a9 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -55,8 +55,6 @@ static ZEND_FUNCTION(trait_exists); static ZEND_FUNCTION(function_exists); static ZEND_FUNCTION(class_alias); #if ZEND_DEBUG -static ZEND_FUNCTION(leak); -static ZEND_FUNCTION(leak_variable); #ifdef ZEND_TEST_EXCEPTIONS static ZEND_FUNCTION(crash); #endif @@ -188,13 +186,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2) ZEND_ARG_INFO(0, autoload) ZEND_END_ARG_INFO() -#if ZEND_DEBUG -ZEND_BEGIN_ARG_INFO_EX(arginfo_leak_variable, 0, 0, 1) - ZEND_ARG_INFO(0, variable) - ZEND_ARG_INFO(0, leak_data) -ZEND_END_ARG_INFO() -#endif - ZEND_BEGIN_ARG_INFO_EX(arginfo_trigger_error, 0, 0, 1) ZEND_ARG_INFO(0, message) ZEND_ARG_INFO(0, error_type) @@ -271,8 +262,6 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */ ZEND_FE(function_exists, arginfo_function_exists) ZEND_FE(class_alias, arginfo_class_alias) #if ZEND_DEBUG - ZEND_FE(leak, NULL) - ZEND_FE(leak_variable, arginfo_leak_variable) #ifdef ZEND_TEST_EXCEPTIONS ZEND_FE(crash, NULL) #endif @@ -1557,44 +1546,6 @@ ZEND_FUNCTION(class_alias) /* }}} */ #if ZEND_DEBUG -/* {{{ proto void leak([int num_bytes]) - Cause an intentional memory leak, for testing/debugging purposes */ -ZEND_FUNCTION(leak) -{ - zend_long leakbytes = 3; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &leakbytes) == FAILURE) { - return; - } - - emalloc(leakbytes); -} -/* }}} */ - -/* {{{ proto void leak_variable(mixed variable [, bool leak_data]) - Leak a variable that is a resource or an object */ -ZEND_FUNCTION(leak_variable) -{ - zval *zv; - zend_bool leak_data = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &zv, &leak_data) == FAILURE) { - return; - } - - if (!leak_data) { - Z_ADDREF_P(zv); - } else if (Z_TYPE_P(zv) == IS_RESOURCE) { - Z_ADDREF_P(zv); - } else if (Z_TYPE_P(zv) == IS_OBJECT) { - Z_ADDREF_P(zv); - } else { - zend_error(E_WARNING, "Leaking non-zval data is only applicable to resources and objects"); - } -} -/* }}} */ - - #ifdef ZEND_TEST_EXCEPTIONS /* {{{ proto void crash(void) Crash the script */ diff --git a/ext/standard/tests/url/parse_url_unterminated.phpt b/ext/standard/tests/url/parse_url_unterminated.phpt index 292f34febadf0..bb0e0968560ae 100644 --- a/ext/standard/tests/url/parse_url_unterminated.phpt +++ b/ext/standard/tests/url/parse_url_unterminated.phpt @@ -2,7 +2,7 @@ Test parse_url() function: Parse unterminated string --SKIPIF-- --FILE-- handlers = &zend_test_class_handlers; @@ -191,6 +233,8 @@ const zend_function_entry test_functions[] = { ZEND_FE(zend_test_func2, arginfo_zend_test_func2) ZEND_FE(zend_create_unterminated_string, NULL) ZEND_FE(zend_terminate_string, arginfo_zend_terminate_string) + ZEND_FE(leak, NULL) + ZEND_FE(leak_variable, arginfo_leak_variable) ZEND_FE_END }; From bc6607bc67ae1aed658264cbedfb44ab6ca13726 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 01:13:19 +0100 Subject: [PATCH 07/13] Cleanup leak_variable() --- ext/sockets/tests/socket_export_stream-5.phpt | 6 ++-- ext/sockets/tests/socket_import_stream-5.phpt | 6 ++-- ext/standard/tests/file/bug52820.phpt | 6 ++-- ext/standard/tests/file/stream_enclosed.phpt | 6 ++-- ext/test/test.c | 33 ++++++++----------- 5 files changed, 26 insertions(+), 31 deletions(-) diff --git a/ext/sockets/tests/socket_export_stream-5.phpt b/ext/sockets/tests/socket_export_stream-5.phpt index 732b2072d0b32..db2d018d474d5 100644 --- a/ext/sockets/tests/socket_export_stream-5.phpt +++ b/ext/sockets/tests/socket_export_stream-5.phpt @@ -5,7 +5,7 @@ socket_export_stream: effects of leaked handles if (!extension_loaded('sockets')) { die('SKIP sockets extension not available.'); } -if (!function_exists('leak_variable')) +if (!function_exists('zend_leak_variable')) die('SKIP only for debug builds'); --FILE-- Date: Sat, 11 Mar 2017 01:15:24 +0100 Subject: [PATCH 08/13] Drop the crash() function --- Zend/zend_builtin_functions.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 41e529755f9a9..7f6e46b73675b 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -29,8 +29,6 @@ #include "zend_closures.h" #include "zend_generators.h" -#undef ZEND_TEST_EXCEPTIONS - static ZEND_FUNCTION(zend_version); static ZEND_FUNCTION(func_num_args); static ZEND_FUNCTION(func_get_arg); @@ -54,11 +52,6 @@ static ZEND_FUNCTION(interface_exists); static ZEND_FUNCTION(trait_exists); static ZEND_FUNCTION(function_exists); static ZEND_FUNCTION(class_alias); -#if ZEND_DEBUG -#ifdef ZEND_TEST_EXCEPTIONS -static ZEND_FUNCTION(crash); -#endif -#endif static ZEND_FUNCTION(get_included_files); static ZEND_FUNCTION(is_subclass_of); static ZEND_FUNCTION(is_a); @@ -261,11 +254,6 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */ ZEND_FE(trait_exists, arginfo_trait_exists) ZEND_FE(function_exists, arginfo_function_exists) ZEND_FE(class_alias, arginfo_class_alias) -#if ZEND_DEBUG -#ifdef ZEND_TEST_EXCEPTIONS - ZEND_FE(crash, NULL) -#endif -#endif ZEND_FE(get_included_files, arginfo_zend__void) ZEND_FALIAS(get_required_files, get_included_files, arginfo_zend__void) ZEND_FE(is_subclass_of, arginfo_is_subclass_of) @@ -1545,25 +1533,6 @@ ZEND_FUNCTION(class_alias) } /* }}} */ -#if ZEND_DEBUG -#ifdef ZEND_TEST_EXCEPTIONS -/* {{{ proto void crash(void) - Crash the script */ -ZEND_FUNCTION(crash) -{ - char *nowhere = NULL; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - memcpy(nowhere, "something", sizeof("something")); -} -/* }}} */ -#endif - -#endif /* ZEND_DEBUG */ - /* {{{ proto array get_included_files(void) Returns an array with the file names that were include_once()'d */ ZEND_FUNCTION(get_included_files) From 1f454d300f1bb88cfb4a6a7bdbcc7600212b7c54 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 01:27:09 +0100 Subject: [PATCH 09/13] Enable test ext on travis / appveyor --- appveyor/build_task.bat | 1 + travis/compile.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor/build_task.bat b/appveyor/build_task.bat index ad47854e0b1ce..7b868fccfda0c 100644 --- a/appveyor/build_task.bat +++ b/appveyor/build_task.bat @@ -39,6 +39,7 @@ call configure.bat ^ --enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^ --with-php-build=%DEPS_DIR% ^ %ADD_CONF% ^ + --enable-test ^ --with-test-ini-ext-exclude=%EXT_EXCLUDE_FROM_TEST% if %errorlevel% neq 0 exit /b 3 diff --git a/travis/compile.sh b/travis/compile.sh index 090cedae693f8..9ed4ed98000af 100755 --- a/travis/compile.sh +++ b/travis/compile.sh @@ -58,6 +58,7 @@ $TS \ --with-freetype-dir=/usr \ --with-xpm-dir=/usr \ --with-kerberos \ ---enable-sysvmsg +--enable-sysvmsg \ +--enable-test make -j2 --quiet make install From 37db2b345fa5a1718a33b8b186b23148c9d54f53 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 13:21:23 +0100 Subject: [PATCH 10/13] Fix config.w32 --- ext/test/config.w32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/test/config.w32 b/ext/test/config.w32 index f62833e6a9d73..5576201f6827a 100644 --- a/ext/test/config.w32 +++ b/ext/test/config.w32 @@ -3,6 +3,6 @@ ARG_ENABLE("test", "enable test extension", "no"); if (PHP_TEST != "no") { - EXTENSION("test", "test.c", PHP_EXTNAME_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); + EXTENSION("test", "test.c", PHP_TEST_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); } From 6c9080d4ce3e2fd3fd7011dc19995d7e079774ac Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 13:25:56 +0100 Subject: [PATCH 11/13] Rename zend_test_func, fix release build --- .../tests/return_types/internal_functions001.phpt | 13 ++++++------- .../tests/return_types/internal_functions002.phpt | 12 ++++-------- ext/test/test.c | 15 ++++++++++----- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Zend/tests/return_types/internal_functions001.phpt b/Zend/tests/return_types/internal_functions001.phpt index fffaf54574535..5dfd2784da023 100644 --- a/Zend/tests/return_types/internal_functions001.phpt +++ b/Zend/tests/return_types/internal_functions001.phpt @@ -1,15 +1,14 @@ --TEST-- Return type for internal functions - --SKIPIF-- --FILE-- --EXPECTF-- -Fatal error: Return value of zend_test_func() must be of the type array, null returned in %s on line %d +Fatal error: Return value of zend_test_array_return() must be of the type array, null returned in %s on line %d diff --git a/Zend/tests/return_types/internal_functions002.phpt b/Zend/tests/return_types/internal_functions002.phpt index 7cdb2b884a5d4..0daf3481c8e66 100644 --- a/Zend/tests/return_types/internal_functions002.phpt +++ b/Zend/tests/return_types/internal_functions002.phpt @@ -1,16 +1,12 @@ --TEST-- Return type for internal functions 2 - --SKIPIF-- ---EXPECTF-- +==DONE== +--EXPECT-- ==DONE== diff --git a/ext/test/test.c b/ext/test/test.c index 2366b341e51e3..e2dc43bc03cfe 100644 --- a/ext/test/test.c +++ b/ext/test/test.c @@ -30,10 +30,10 @@ static zend_class_entry *zend_test_class; static zend_class_entry *zend_test_trait; static zend_object_handlers zend_test_class_handlers; -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func, IS_ARRAY, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_array_return, IS_ARRAY, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func2, IS_ARRAY, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_nullable_array_return, IS_ARRAY, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_terminate_string, 0, 0, 1) @@ -45,13 +45,18 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_leak_variable, 0, 0, 1) ZEND_END_ARG_INFO() ZEND_FUNCTION(zend_test_func) +{ + /* dummy */ +} + +ZEND_FUNCTION(zend_test_array_return) { zval *arg1, *arg2; zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2); } -ZEND_FUNCTION(zend_test_func2) +ZEND_FUNCTION(zend_test_nullable_array_return) { zval *arg1, *arg2; @@ -224,8 +229,8 @@ PHP_MINFO_FUNCTION(test) } const zend_function_entry test_functions[] = { - ZEND_FE(zend_test_func, arginfo_zend_test_func) - ZEND_FE(zend_test_func2, arginfo_zend_test_func2) + ZEND_FE(zend_test_array_return, arginfo_zend_test_array_return) + ZEND_FE(zend_test_nullable_array_return, arginfo_zend_test_nullable_array_return) ZEND_FE(zend_create_unterminated_string, NULL) ZEND_FE(zend_terminate_string, arginfo_zend_terminate_string) ZEND_FE(zend_leak_bytes, NULL) From a9fd5f6cbf346990cb7b8f3aea84a72e8c46ac57 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 13:32:29 +0100 Subject: [PATCH 12/13] Rename ext/test to ext/zend_test --- appveyor/build_task.bat | 2 +- ext/test/config.m4 | 6 ------ ext/test/config.w32 | 8 ------- ext/zend_test/config.m4 | 6 ++++++ ext/zend_test/config.w32 | 8 +++++++ ext/{test => zend_test}/php_test.h | 18 ++++------------ ext/{test => zend_test}/test.c | 34 +++++++++++++++--------------- travis/compile.sh | 2 +- 8 files changed, 37 insertions(+), 47 deletions(-) delete mode 100644 ext/test/config.m4 delete mode 100644 ext/test/config.w32 create mode 100644 ext/zend_test/config.m4 create mode 100644 ext/zend_test/config.w32 rename ext/{test => zend_test}/php_test.h (76%) rename ext/{test => zend_test}/test.c (92%) diff --git a/appveyor/build_task.bat b/appveyor/build_task.bat index 7b868fccfda0c..85a64e4fbd700 100644 --- a/appveyor/build_task.bat +++ b/appveyor/build_task.bat @@ -39,7 +39,7 @@ call configure.bat ^ --enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^ --with-php-build=%DEPS_DIR% ^ %ADD_CONF% ^ - --enable-test ^ + --enable-zend-test ^ --with-test-ini-ext-exclude=%EXT_EXCLUDE_FROM_TEST% if %errorlevel% neq 0 exit /b 3 diff --git a/ext/test/config.m4 b/ext/test/config.m4 deleted file mode 100644 index ce301d6d1e78f..0000000000000 --- a/ext/test/config.m4 +++ /dev/null @@ -1,6 +0,0 @@ -PHP_ARG_ENABLE(test, whether to enable test extension, -[ --enable-test Enable test extension]) - -if test "$PHP_TEST" != "no"; then - PHP_NEW_EXTENSION(test, test.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) -fi diff --git a/ext/test/config.w32 b/ext/test/config.w32 deleted file mode 100644 index 5576201f6827a..0000000000000 --- a/ext/test/config.w32 +++ /dev/null @@ -1,8 +0,0 @@ -// vim:ft=javascript - -ARG_ENABLE("test", "enable test extension", "no"); - -if (PHP_TEST != "no") { - EXTENSION("test", "test.c", PHP_TEST_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); -} - diff --git a/ext/zend_test/config.m4 b/ext/zend_test/config.m4 new file mode 100644 index 0000000000000..becefcdd7e972 --- /dev/null +++ b/ext/zend_test/config.m4 @@ -0,0 +1,6 @@ +PHP_ARG_ENABLE(zend-test, whether to enable zend-test extension, +[ --enable-zend-test Enable zend-test extension]) + +if test "$PHP_ZEND_TEST" != "no"; then + PHP_NEW_EXTENSION(zend_test, test.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) +fi diff --git a/ext/zend_test/config.w32 b/ext/zend_test/config.w32 new file mode 100644 index 0000000000000..77bbe67fb6931 --- /dev/null +++ b/ext/zend_test/config.w32 @@ -0,0 +1,8 @@ +// vim:ft=javascript + +ARG_ENABLE("zend-test", "enable zend-test extension", "no"); + +if (PHP_TEST != "no") { + EXTENSION("zend_test", "test.c", PHP_ZEND_TEST_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); +} + diff --git a/ext/test/php_test.h b/ext/zend_test/php_test.h similarity index 76% rename from ext/test/php_test.h rename to ext/zend_test/php_test.h index 8ddc52d39e776..fe8c5e47e44ac 100644 --- a/ext/test/php_test.h +++ b/ext/zend_test/php_test.h @@ -21,26 +21,16 @@ #ifndef PHP_TEST_H #define PHP_TEST_H -extern zend_module_entry test_module_entry; -#define phpext_test_ptr &test_module_entry +extern zend_module_entry zend_test_module_entry; +#define phpext_zend_test_ptr &zend_test_module_entry -#define PHP_TEST_VERSION "0.1.0" - -#ifdef PHP_WIN32 -# define PHP_TEST_API __declspec(dllexport) -#elif defined(__GNUC__) && __GNUC__ >= 4 -# define PHP_TEST_API __attribute__ ((visibility("default"))) -#else -# define PHP_TEST_API -#endif +#define PHP_ZEND_TEST_VERSION "0.1.0" #ifdef ZTS #include "TSRM.h" #endif -#define TEST_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(test, v) - -#if defined(ZTS) && defined(COMPILE_DL_TEST) +#if defined(ZTS) && defined(COMPILE_DL_ZEND_TEST) ZEND_TSRMLS_CACHE_EXTERN() #endif diff --git a/ext/test/test.c b/ext/zend_test/test.c similarity index 92% rename from ext/test/test.c rename to ext/zend_test/test.c index e2dc43bc03cfe..f203af803fd74 100644 --- a/ext/test/test.c +++ b/ext/zend_test/test.c @@ -179,7 +179,7 @@ static zend_function_entry zend_test_trait_methods[] = { ZEND_FE_END }; -PHP_MINIT_FUNCTION(test) +PHP_MINIT_FUNCTION(zend_test) { zend_class_entry class_entry; @@ -203,32 +203,32 @@ PHP_MINIT_FUNCTION(test) return SUCCESS; } -PHP_MSHUTDOWN_FUNCTION(test) +PHP_MSHUTDOWN_FUNCTION(zend_test) { return SUCCESS; } -PHP_RINIT_FUNCTION(test) +PHP_RINIT_FUNCTION(zend_test) { -#if defined(COMPILE_DL_TEST) && defined(ZTS) +#if defined(COMPILE_DL_ZEND_TEST) && defined(ZTS) ZEND_TSRMLS_CACHE_UPDATE(); #endif return SUCCESS; } -PHP_RSHUTDOWN_FUNCTION(test) +PHP_RSHUTDOWN_FUNCTION(zend_test) { return SUCCESS; } -PHP_MINFO_FUNCTION(test) +PHP_MINFO_FUNCTION(zend_test) { php_info_print_table_start(); - php_info_print_table_header(2, "test extension", "enabled"); + php_info_print_table_header(2, "zend-test extension", "enabled"); php_info_print_table_end(); } -const zend_function_entry test_functions[] = { +const zend_function_entry zend_test_functions[] = { ZEND_FE(zend_test_array_return, arginfo_zend_test_array_return) ZEND_FE(zend_test_nullable_array_return, arginfo_zend_test_nullable_array_return) ZEND_FE(zend_create_unterminated_string, NULL) @@ -238,20 +238,20 @@ const zend_function_entry test_functions[] = { ZEND_FE_END }; -zend_module_entry test_module_entry = { +zend_module_entry zend_test_module_entry = { STANDARD_MODULE_HEADER, "test", - test_functions, - PHP_MINIT(test), - PHP_MSHUTDOWN(test), - PHP_RINIT(test), - PHP_RSHUTDOWN(test), - PHP_MINFO(test), - PHP_TEST_VERSION, + zend_test_functions, + PHP_MINIT(zend_test), + PHP_MSHUTDOWN(zend_test), + PHP_RINIT(zend_test), + PHP_RSHUTDOWN(zend_test), + PHP_MINFO(zend_test), + PHP_ZEND_TEST_VERSION, STANDARD_MODULE_PROPERTIES }; -#ifdef COMPILE_DL_TEST +#ifdef COMPILE_DL_ZEND_TEST #ifdef ZTS ZEND_TSRMLS_CACHE_DEFINE() #endif diff --git a/travis/compile.sh b/travis/compile.sh index 9ed4ed98000af..bd127e716d8f6 100755 --- a/travis/compile.sh +++ b/travis/compile.sh @@ -59,6 +59,6 @@ $TS \ --with-xpm-dir=/usr \ --with-kerberos \ --enable-sysvmsg \ ---enable-test +--enable-zend-test make -j2 --quiet make install From e81452b5c39a950272d3606a07c3591f70414960 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 11 Mar 2017 15:22:17 +0100 Subject: [PATCH 13/13] Fix AppVeyor build --- ext/zend_test/config.w32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/zend_test/config.w32 b/ext/zend_test/config.w32 index 77bbe67fb6931..9b1574ef4e40a 100644 --- a/ext/zend_test/config.w32 +++ b/ext/zend_test/config.w32 @@ -2,7 +2,7 @@ ARG_ENABLE("zend-test", "enable zend-test extension", "no"); -if (PHP_TEST != "no") { +if (PHP_ZEND_TEST != "no") { EXTENSION("zend_test", "test.c", PHP_ZEND_TEST_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); }