mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-01 03:16:14 +00:00
4abed1d7c7
Done by phpcbf over composer fix Change-Id: I9b7419e025ef499ff68be79789d76ad4b886d256
36 lines
966 B
PHP
36 lines
966 B
PHP
<?php
|
|
|
|
if ( PHP_SAPI !== 'cli' ) {
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/../LuaCommon/LuaInterpreterTest.php';
|
|
|
|
/**
|
|
* @group Lua
|
|
* @group LuaSandbox
|
|
*/
|
|
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
|
|
class Scribunto_LuaSandboxInterpreterTest extends Scribunto_LuaInterpreterTest {
|
|
public $stdOpts = [
|
|
'memoryLimit' => 50000000,
|
|
'cpuLimit' => 30,
|
|
];
|
|
|
|
protected function newInterpreter( $opts = [] ) {
|
|
$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' );
|
|
}
|
|
}
|
|
|