diff options
author | Yaco <franco@reevo.org> | 2021-10-19 20:30:39 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2021-10-19 20:30:39 -0300 |
commit | 8c201ace3699b4928daf41eb7b4cdcb4565c6f3b (patch) | |
tree | fbd98f026864e9c1919d3ee740b6799ca0c651e2 /www/wiki/extensions/Scribunto/tests/phpunit/engines/LuaSandbox/LuaSandboxInterpreterTest.php | |
parent | e3880a1c86acaa3bbd05786ad2f5c586e6511a58 (diff) |
adds Scribunto
Diffstat (limited to 'www/wiki/extensions/Scribunto/tests/phpunit/engines/LuaSandbox/LuaSandboxInterpreterTest.php')
-rw-r--r-- | www/wiki/extensions/Scribunto/tests/phpunit/engines/LuaSandbox/LuaSandboxInterpreterTest.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/www/wiki/extensions/Scribunto/tests/phpunit/engines/LuaSandbox/LuaSandboxInterpreterTest.php b/www/wiki/extensions/Scribunto/tests/phpunit/engines/LuaSandbox/LuaSandboxInterpreterTest.php new file mode 100644 index 00000000..256e8c6a --- /dev/null +++ b/www/wiki/extensions/Scribunto/tests/phpunit/engines/LuaSandbox/LuaSandboxInterpreterTest.php @@ -0,0 +1,34 @@ +<?php + +if ( !wfIsCLI() ) { + 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' ); + } +} |