mediawiki-extensions-Scribunto/tests/engines/LuaSandbox/LuaSandboxInterpreterTest.php
Brad Jorsch 8872dd3eda Update phpunit @group annotations
Some tests weren't being run as they should have been when phpunit's
--group option was used.

Change-Id: I29ff9a04322b91cc085247e5663dfc7bc67d3439
2013-11-01 11:56:24 -04:00

32 lines
892 B
PHP

<?php
if ( PHP_SAPI !== 'cli' ) exit;
require_once( dirname( __FILE__ ) .'/../LuaCommon/LuaInterpreterTest.php' );
/**
* @group Lua
* @group LuaSandbox
*/
class Scribunto_LuaSandboxInterpreterTest extends Scribunto_LuaInterpreterTest {
var $stdOpts = array(
'memoryLimit' => 50000000,
'cpuLimit' => 30,
);
function newInterpreter( $opts = array() ) {
$opts = $opts + $this->stdOpts;
$engine = new Scribunto_LuaSandboxEngine( $this->stdOpts );
return new Scribunto_LuaSandboxInterpreter( $engine, $opts );
}
function testGetMemoryUsage() {
$interpreter = $this->newInterpreter();
$chunk = $interpreter->loadString( 's = string.rep("x", 1000000)', 'mem' );
$interpreter->callFunction( $chunk );
$mem = $interpreter->getPeakMemoryUsage();
$this->assertGreaterThan( 1000000, $mem, 'memory usage' );
$this->assertLessThan( 10000000, $mem, 'memory usage' );
}
}