今天当我试图在Yii框架中运行几个测试运行phpunit时,我收到了一个分段错误。这也是一个新的测试。奇怪的是,这对任何其他Yii安装以及使用selenium的功能测试都不满意
运行测试:
root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests# phpunit unit
Segmentation fault
root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests#
GDB:
root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests# gdb --args php /usr/bin/phpunit unit
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/php...(no debugging symbols found)...done.
(gdb) r
Starting program: /usr/bin/php /usr/bin/phpunit unit
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffec9fd700 (LWP 5572)]
[Thread 0x7fffec9fd700 (LWP 5572) exited]
Program received signal SIGSEGV, Segmentation fault.
0x0000000000685768 in zend_get_class_entry ()
(gdb)
ddb backtrace:
(gdb)bt
#0 0x0000000000685768 in zend_get_class_entry ()
#1 0x000000000069a94f in zend_call_method ()
#2 0x00000000005837e6 in ?? ()
#3 0x000000000067982d in zend_call_function ()
#4 0x0000000000679e4c in zend_lookup_class_ex ()
#5 0x000000000067a120 in zend_fetch_class ()
#6 0x00000000006aa871 in ?? ()
#7 0x00000000006abe00 in execute ()
#8 0x00007ffff4602379 in xdebug_execute (op_array=0x160d178) at /tmp/pear/temp/xdebug/xdebug.c:1435
#9 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#10 0x00000000006c02cc in ?? ()
#11 0x00000000006abe00 in execute ()
#12 0x00007ffff4602379 in xdebug_execute (op_array=0x113a7a0) at /tmp/pear/temp/xdebug/xdebug.c:1435
#13 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#14 0x0000000000679784 in zend_call_function ()
#15 0x000000000069a8d7 in zend_call_method ()
#16 0x00000000005837e6 in ?? ()
#17 0x000000000067982d in zend_call_function ()
#18 0x0000000000679e4c in zend_lookup_class_ex ()
#19 0x000000000067a120 in zend_fetch_class ()
#20 0x00000000006aa871 in ?? ()
#21 0x00000000006abe00 in execute ()
#22 0x00007ffff4602379 in xdebug_execute (op_array=0x102c4c0) at /tmp/pear/temp/xdebug/xdebug.c:1435
#23 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#24 0x00000000006b279d in ?? ()
#25 0x00000000006abe00 in execute ()
#26 0x00007ffff4602379 in xdebug_execute (op_array=0x1107e70) at /tmp/pear/temp/xdebug/xdebug.c:1435
#27 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#28 0x00000000006d4876 in ?? ()
#29 0x00000000006abe00 in execute ()
#30 0x00007ffff4602379 in xdebug_execute (op_array=0x11087d0) at /tmp/pear/temp/xdebug/xdebug.c:1435
#31 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#32 0x00000000006d4876 in ?? ()
#33 0x00000000006abe00 in execute ()
#34 0x00007ffff4602379 in xdebug_execute (op_array=0x7fffebe930f8) at /tmp/pear/temp/xdebug/xdebug.c:1435
#35 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#36 0x00000000006d4876 in ?? ()
#37 0x00000000006abe00 in execute ()
#38 0x00007ffff4602379 in xdebug_execute (op_array=0x7fffebea01d8) at /tmp/pear/temp/xdebug/xdebug.c:1435
#39 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#40 0x00000000006d4876 in ?? ()
#41 0x00000000006abe00 in execute ()
#42 0x00007ffff4602379 in xdebug_execute (op_array=0x157be08) at /tmp/pear/temp/xdebug/xdebug.c:1435
#43 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#44 0x00000000006d4876 in ?? ()
#45 0x00000000006abe00 in execute ()
#46 0x00007ffff4602379 in xdebug_execute (op_array=0x10353d8) at /tmp/pear/temp/xdebug/xdebug.c:1435
#47 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
---Type <return> to continue, or q <return> to quit---
#48 0x00000000006d4876 in ?? ()
#49 0x00000000006abe00 in execute ()
#50 0x00007ffff4602379 in xdebug_execute (op_array=0x1040f20) at /tmp/pear/temp/xdebug/xdebug.c:1435
#51 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#52 0x00000000006d4876 in ?? ()
#53 0x00000000006abe00 in execute ()
#54 0x00007ffff4602379 in xdebug_execute (op_array=0x102aa90) at /tmp/pear/temp/xdebug/xdebug.c:1435
#55 0x00007fffed27e116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#56 0x00000000006835cd in zend_execute_scripts ()
#57 0x000000000062eb98 in php_execute_script ()
#58 0x000000000071413a in ?? ()
#59 0x00007ffff5471c8d in __libc_start_main () from /lib/libc.so.6
#60 0x000000000042d6e9 in _start ()
php版本:
root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests# php -v
PHP 5.3.3-7+squeeze19 with Suhosin-Patch (cli) (built: Feb 17 2014 10:10:23)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
phpunit版本:
root@icalab-dev:/home/jasper/test/public_html/beheer/protected/tests# phpunit --version
PHPUnit 3.7.24 by Sebastian Bergmann.
phpunit.ini(被剥离以禁用selenium,clover-coverage,coverage-html和junit):
<phpunit
bootstrap="bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
strict="false"
verbose="true"
stopOnFailure="false">
<selenium>
<browser name="Internet Explorer" browser="*iexplore" />
<browser name="Firefox" browser="*firefox" />
</selenium>
</phpunit>
bootstrap.php中:
<?php
// change the following paths if necessary
$yiit=dirname(__FILE__).'/../../../../framework/yiit.php';
$config=dirname(__FILE__).'/../config/test.php';
require_once($yiit);
require_once(dirname(__FILE__).'/WebTestCase.php');
Yii::createWebApplication($config);
在文件夹单元中进行测试:
<?php
class JasperTest extends CDbTestCase
{
public function testPushAndPop()
{
//$stack = array();
$this->assertEquals(true, true);
/*
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
*/
}
}
另外:禁用了产生回溯的xdebug:
#0 0x0000000000685768 in zend_get_class_entry ()
#1 0x000000000069a94f in zend_call_method ()
#2 0x00000000005837e6 in ?? ()
#3 0x000000000067982d in zend_call_function ()
#4 0x0000000000679e4c in zend_lookup_class_ex ()
#5 0x000000000067a120 in zend_fetch_class ()
#6 0x00000000006aa871 in ?? ()
#7 0x00000000006abe00 in execute ()
#8 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#9 0x00000000006c02cc in ?? ()
#10 0x00000000006abe00 in execute ()
#11 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#12 0x0000000000679784 in zend_call_function ()
#13 0x000000000069a8d7 in zend_call_method ()
#14 0x00000000005837e6 in ?? ()
#15 0x000000000067982d in zend_call_function ()
#16 0x0000000000679e4c in zend_lookup_class_ex ()
#17 0x000000000067a120 in zend_fetch_class ()
#18 0x00000000006aa871 in ?? ()
#19 0x00000000006abe00 in execute ()
#20 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#21 0x00000000006b279d in ?? ()
#22 0x00000000006abe00 in execute ()
#23 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#24 0x00000000006d4876 in ?? ()
#25 0x00000000006abe00 in execute ()
#26 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#27 0x00000000006d4876 in ?? ()
#28 0x00000000006abe00 in execute ()
#29 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#30 0x00000000006d4876 in ?? ()
#31 0x00000000006abe00 in execute ()
#32 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#33 0x00000000006d4876 in ?? ()
#34 0x00000000006abe00 in execute ()
#35 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#36 0x00000000006d4876 in ?? ()
#37 0x00000000006abe00 in execute ()
#38 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#39 0x00000000006d4876 in ?? ()
#40 0x00000000006abe00 in execute ()
#41 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#42 0x00000000006d4876 in ?? ()
#43 0x00000000006abe00 in execute ()
#44 0x00007fffed4b0116 in ?? () from /usr/lib/php5/20090626/suhosin.so
#45 0x00000000006835cd in zend_execute_scripts ()
#46 0x000000000062eb98 in php_execute_script ()
#47 0x000000000071413a in ?? ()
---Type <return> to continue, or q <return> to quit---
#48 0x00007ffff5471c8d in __libc_start_main () from /lib/libc.so.6
#49 0x000000000042d6e9 in _start ()
任何人都知道如何解决这个问题?
答案 0 :(得分:1)
我猜你正在使用Yii 1.1.12或更低版本,因为这个问题已在1.1.13修补。
打开yii/framework/test/CTestCase.php
并进行以下更改:
替换
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');
spl_autoload_unregister('phpunit_autoload');
Yii::registerAutoloader('phpunit_autoload');
使用新的代码格式1.1.13
require_once('PHPUnit/Runner/Version.php');
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
spl_autoload_unregister(array('YiiBase','autoload'));
require_once('PHPUnit/Autoload.php');
spl_autoload_register(array('YiiBase','autoload')); // put yii's autoloader at the end
if (in_array('phpunit_autoload', spl_autoload_functions())) { // PHPUnit >= 3.7 'phpunit_autoload' was obsoleted
spl_autoload_unregister('phpunit_autoload');
Yii::registerAutoloader('phpunit_autoload');
}
我自己遇到了这个问题,如果我没记错的话,这就解决了这个问题。