mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-18 10:53:37 +00:00
8872dd3eda
Some tests weren't being run as they should have been when phpunit's --group option was used. Change-Id: I29ff9a04322b91cc085247e5663dfc7bc67d3439
32 lines
892 B
PHP
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' );
|
|
}
|
|
}
|
|
|