diff options
author | Eric Wong <e@80x24.org> | 2018-12-26 19:57:16 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-12-28 06:44:57 +0000 |
commit | bd629500a1f4250d7fbeeb027e4aba76bcbc27a5 (patch) | |
tree | c15dbd240a6e0bdc7818a8866c9bbf5a8c86aa97 /test/test_extras_exec_cgi.rb | |
parent | bfffc6cdab85743b5617a06c094b0544086e3cbf (diff) | |
download | yahns-bd629500a1f4250d7fbeeb027e4aba76bcbc27a5.tar.gz |
These options can be useful for limiting CGI process runtime and memory usage.
Diffstat (limited to 'test/test_extras_exec_cgi.rb')
-rw-r--r-- | test/test_extras_exec_cgi.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test_extras_exec_cgi.rb b/test/test_extras_exec_cgi.rb index c6c5ad6..426409d 100644 --- a/test/test_extras_exec_cgi.rb +++ b/test/test_extras_exec_cgi.rb @@ -179,4 +179,27 @@ class TestExtrasExecCGI < Testcase c.close if c quit_wait(pid) end + + def test_rlimit_options + err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1] + tout = 1 + opts = { rlimit_cpu: tout, rlimit_core: 0 } + cmd = [ '/bin/sh', '-c', 'while :; do :;done', opts ] + pid = mkserver(cfg) do + require './extras/exec_cgi' + cfg.instance_eval do + stack = Rack::ContentLength.new(Rack::Chunked.new(ExecCgi.new(*cmd))) + app(:rack, stack) { listen "#{host}:#{port}" } + stderr_path err.path + worker_processes 1 + end + end + c = get_tcp_client(host, port) + c.write "GET / HTTP/1.0\r\n\r\n" + assert_same c, c.wait(tout + 5) + assert_match %r{ 500 Internal Server Error\b}, c.readpartial(4096) + c.close + ensure + quit_wait(pid) + end end |