com php-src: more tests add phpdbg_exec userland function : Changelog.md phpdbg.c tests/commands/0104 _clean.test tests/commands/0105_clear.test
tests/commands/0106_compile.test
| From: | Bob Weinand | Date: | Fri, 06 Dec 2013 20:56:16 +0000 |
| Subject: | com php-src: more tests add phpdbg_exec userland function : Changelog.md phpdbg.c tests/commands/0104 _clean.test tests/commands/0105_clear.test tests/commands/0106_compile.test |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75297@lists.php.net to get a copy of this message | ||
Commit: faf10136819a48c26ed25519861d948e8044b7e8
Author: krakjoe <joe.watkins@live.co.uk> Fri, 6 Dec 2013 20:56:16 +0000
Parents: ad2ea99c3e13c96fe322ef8cdbbdb7f58c6aeea0
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=faf10136819a48c26ed25519861d948e8044b7e8
Log:
more tests
add phpdbg_exec userland function
Changed paths:
M Changelog.md
M phpdbg.c
A tests/commands/0104_clean.test
A tests/commands/0105_clear.test
A tests/commands/0106_compile.test
Diff:
diff --git a/Changelog.md b/Changelog.md
index 308b68c..b49390f 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -11,6 +11,8 @@ Version 0.3.0 2013-00-00
5. Fix crash when loading .phpdbginit with command line switch
6. Fix crash on startup errors
7. Added init.d for remote console (redhat)
+8. Added phpdbg_exec userland function
+9. Added testing facilities
Version 0.2.0 2013-11-31
------------------------
diff --git a/phpdbg.c b/phpdbg.c
index 2a87265..1bd79bb 100644
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -199,6 +199,51 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
return SUCCESS;
} /* }}} */
+/* {{{ proto mixed phpdbg_exec(string context)
+ Attempt to set the execution context for phpdbg
+ If the execution context was set previously it is returned
+ If the execution context was not set previously boolean true is returned
+ If the request to set the context fails, boolean false is returned, and an E_WARNING raised */
+static PHP_FUNCTION(phpdbg_exec)
+{
+ char *exec = NULL;
+ zend_ulong exec_len = 0L;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &exec, &exec_len) ==
FAILURE) {
+ return;
+ }
+
+ {
+ struct stat sb;
+ zend_bool result = 1;
+
+ if (VCWD_STAT(exec, &sb) != FAILURE) {
+ if (sb.st_mode & (S_IFREG|S_IFLNK)) {
+ if (PHPDBG_G(exec)) {
+ ZVAL_STRINGL(return_value, PHPDBG_G(exec), PHPDBG_G(exec_len), 1);
+ efree(PHPDBG_G(exec));
+ result = 0;
+ }
+
+ PHPDBG_G(exec) = estrndup(exec, exec_len);
+ PHPDBG_G(exec_len) = exec_len;
+
+ if (result)
+ ZVAL_BOOL(return_value, 1);
+ } else {
+ zend_error(
+ E_WARNING, "Failed to set execution context (%s), not a regular file or symlink",
exec);
+ ZVAL_BOOL(return_value, 0);
+ }
+ } else {
+ zend_error(
+ E_WARNING, "Failed to set execution context (%s) the file does not exist", exec);
+
+ ZVAL_BOOL(return_value, 0);
+ }
+ }
+} /* }}} */
+
/* {{{ proto void phpdbg_break([integer type, string expression])
instructs phpdbg to insert a breakpoint at the next opcode */
static PHP_FUNCTION(phpdbg_break)
@@ -307,12 +352,17 @@ ZEND_BEGIN_ARG_INFO_EX(phpdbg_prompt_arginfo, 0, 0, 0)
ZEND_ARG_INFO(0, string)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(phpdbg_exec_arginfo, 0, 0, 0)
+ ZEND_ARG_INFO(0, context)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(phpdbg_clear_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()
zend_function_entry phpdbg_user_functions[] = {
PHP_FE(phpdbg_clear, phpdbg_clear_arginfo)
PHP_FE(phpdbg_break, phpdbg_break_arginfo)
+ PHP_FE(phpdbg_exec, phpdbg_exec_arginfo)
PHP_FE(phpdbg_color, phpdbg_color_arginfo)
PHP_FE(phpdbg_prompt, phpdbg_prompt_arginfo)
#ifdef PHP_FE_END
diff --git a/tests/commands/0104_clean.test b/tests/commands/0104_clean.test
new file mode 100644
index 0000000..c7a579b
--- /dev/null
+++ b/tests/commands/0104_clean.test
@@ -0,0 +1,15 @@
+#################################################
+# name: clean
+# purpose: test cleaning environment
+# expect: TEST::FORMAT
+# options: -rr
+#################################################
+#[Cleaning Execution Environment]
+#Classes %d
+#Functions %d
+#Constants %d
+#Includes %d
+#[Nothing to execute!]
+#################################################
+clean
+quit
diff --git a/tests/commands/0105_clear.test b/tests/commands/0105_clear.test
new file mode 100644
index 0000000..1ac3c3b
--- /dev/null
+++ b/tests/commands/0105_clear.test
@@ -0,0 +1,15 @@
+#################################################
+# name: clear
+# purpose: test clearing breakpoints
+# expect: TEST::FORMAT
+# options: -rr
+#################################################
+#[Clearing Breakpoints]
+#File 0
+#Functions 0
+#Methods 0
+#Oplines 0
+#Conditionals 0
+#################################################
+clear
+quit
diff --git a/tests/commands/0106_compile.test b/tests/commands/0106_compile.test
new file mode 100644
index 0000000..d79211d
--- /dev/null
+++ b/tests/commands/0106_compile.test
@@ -0,0 +1,19 @@
+#################################################
+# name: compile
+# purpose: test compiling code
+# expect: TEST::FORMAT
+# options: -rr
+#################################################
+#[Attempting compilation of %s]
+#[Success]
+#Hello World
+#################################################
+<:
+define('OUT',
+ tempnam(null, "phpdbg"));
+file_put_contents(OUT, "<?php echo \"Hello World\"; ?>");
+phpdbg_exec(OUT);
+:>
+compile
+run
+quit