mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-27 01:30:00 +00:00
b2d340bf71
Change-Id: I8ccb645fa11f001fc1ca1c95f4e9476f84870714
29 lines
850 B
PHP
29 lines
850 B
PHP
<?php
|
|
|
|
if ( PHP_SAPI !== 'cli' ) exit;
|
|
require_once( dirname( __FILE__ ) .'/../LuaCommon/LuaInterpreterTest.php' );
|
|
|
|
|
|
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' );
|
|
}
|
|
}
|
|
|