mediawiki-extensions-Scribunto/tests/engines/LuaSandbox/LuaSandboxInterpreterTest.php
Thiemo Mättig 55fe0b69d0 Add missing visibility keywords everywhere
Change-Id: I270d1dd9b6545e15398c2f8b8e9ae533844cc998
2014-11-14 10:10:23 +01:00

32 lines
912 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 {
public $stdOpts = array(
'memoryLimit' => 50000000,
'cpuLimit' => 30,
);
protected function newInterpreter( $opts = array() ) {
$opts = $opts + $this->stdOpts;
$engine = new Scribunto_LuaSandboxEngine( $this->stdOpts );
return new Scribunto_LuaSandboxInterpreter( $engine, $opts );
}
public 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' );
}
}