From 6adc95a975a4b5dc6337515328ad438652abc5c8 Mon Sep 17 00:00:00 2001 From: Herman Venter Date: Fri, 28 Jun 2013 14:52:19 -0700 Subject: [PATCH] Replicate debugger eval tests in test/quick/debugger. Take 2. Ongoing migration of tests to the new infrastructure. The old tests stay in place until we have another way to test the client API. --- hphp/runtime/debugger/break_point.cpp | 1 + hphp/test/quick/debugger/eval1.php | 18 +++++ hphp/test/quick/debugger/eval1.php.expectf | 94 ++++++++++++++++++++++ hphp/test/quick/debugger/eval1.php.in | 44 ++++++++++ 4 files changed, 157 insertions(+) create mode 100644 hphp/test/quick/debugger/eval1.php create mode 100644 hphp/test/quick/debugger/eval1.php.expectf create mode 100644 hphp/test/quick/debugger/eval1.php.in diff --git a/hphp/runtime/debugger/break_point.cpp b/hphp/runtime/debugger/break_point.cpp index 6a901b5a4..de4ad87be 100644 --- a/hphp/runtime/debugger/break_point.cpp +++ b/hphp/runtime/debugger/break_point.cpp @@ -13,6 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ +//force unit test run #include "hphp/runtime/debugger/break_point.h" #include "hphp/runtime/debugger/debugger.h" diff --git a/hphp/test/quick/debugger/eval1.php b/hphp/test/quick/debugger/eval1.php new file mode 100644 index 000000000..510e00d12 --- /dev/null +++ b/hphp/test/quick/debugger/eval1.php @@ -0,0 +1,18 @@ +pub = 11; + $this->pri = 12; + } + public function meth($x) { + $a = $this->pub.':'.$this->pri; + $b = $this->pub.':'.$this->pri; + $c = $this->pub.':'.$this->pri; + return $a.'-'.$b.'-'.$c; + } +} + +error_log('eval1.php loaded'); diff --git a/hphp/test/quick/debugger/eval1.php.expectf b/hphp/test/quick/debugger/eval1.php.expectf new file mode 100644 index 000000000..750f76f33 --- /dev/null +++ b/hphp/test/quick/debugger/eval1.php.expectf @@ -0,0 +1,94 @@ +Program %s/eval1.php loaded. Type '[r]un' or '[c]ontinue' to go. +%Srun +eval1.php loaded +Program %s/eval1.php exited normally. +print function_exists('test1') +false +@ function test1($x){error_log($x);return $x+1;} + +print function_exists('test1') +true +@ $eval1=test1(4) +4 + +print $eval1 +5 +print class_exists('test2') +false +a . ":" . $this->b; + } + public function callCls() { + $obj = new cls(); + return $obj->meth($this); + } + private function seven() { + return 7; + } +} +?> + +print class_exists('test2') +true +set bac off +BypassAccessCheck(bac) set to off +@ $eval2 = new test2() + +@ $eval2->a = 3 + +@ $eval2->b = 4 +Hit fatal : Cannot access protected property + #0 at [:1] + #1 include(), called at [:1] + +print $eval2->ab() +"3:" +set bac on +BypassAccessCheck(bac) set to on. +All code executed from debugger is bypassing access check! +@ $eval2->b = 4 + +print $eval2->ab() +"3:4" +break eval1.php:12 +Breakpoint 1 set on line 12 of eval1.php +print $eval2->callCls() +Breakpoint 1 reached at cls::meth() on line 12 of %s/eval1.php + 11 $a = $this->pub.':'.$this->pri; + 12 $b = $this->pub.':'.$this->pri; + 13 $c = $this->pub.':'.$this->pri; + +break clear all +All breakpoints are cleared. +set bac off +BypassAccessCheck(bac) set to off +@ $this->pub = 21 + +@ $this->pri = 22 + +next +Break at cls::meth() on line 13 of %s/eval1.php + 12 $b = $this->pub.':'.$this->pri; + 13 $c = $this->pub.':'.$this->pri; + 14 return $a.'-'.$b.'-'.$c; + +@ $this->pub = $x->seven() +Hit fatal : Call to private method test2::seven from context cls + #0 at [:1] + #1 include(), called at %s/eval1.php:13] + #2 cls->meth(), called at [:%d] + #3 test2->callCls(), called at [:%d] + #4 include(), called at [:%d] + +set bac on +BypassAccessCheck(bac) set to on. +All code executed from debugger is bypassing access check! +@ $this->pub = $x->seven() + +continue +"11:12-21:22-7:22" +quit diff --git a/hphp/test/quick/debugger/eval1.php.in b/hphp/test/quick/debugger/eval1.php.in new file mode 100644 index 000000000..4e9275e08 --- /dev/null +++ b/hphp/test/quick/debugger/eval1.php.in @@ -0,0 +1,44 @@ +run +print function_exists('test1') +@ function test1($x){error_log($x);return $x+1;} +print function_exists('test1') +@ $eval1=test1(4) +print $eval1 +print class_exists('test2') +a . ":" . $this->b; + } + public function callCls() { + $obj = new cls(); + return $obj->meth($this); + } + private function seven() { + return 7; + } +} +?> +print class_exists('test2') +set bac off +@ $eval2 = new test2() +@ $eval2->a = 3 +@ $eval2->b = 4 +print $eval2->ab() +set bac on +@ $eval2->b = 4 +print $eval2->ab() +break eval1.php:12 +print $eval2->callCls() +break clear all +set bac off +@ $this->pub = 21 +@ $this->pri = 22 +next +@ $this->pub = $x->seven() +set bac on +@ $this->pub = $x->seven() +continue +quit