diff --git a/check/check.rb b/check/check.rb index c2609b41..5e9e1450 100755 --- a/check/check.rb +++ b/check/check.rb @@ -347,7 +347,7 @@ def do_test(&block) nfiles.times do |i| ENV["FORM"] = FormTest.cfg.form_cmd @filename = "#{i + 1}.frm" - execute("#{FormTest.cfg.form_cmd} #{@filename}") + execute("#{ulimits}#{FormTest.cfg.form_cmd} #{@filename}") if !finished? info.status = "TIMEOUT" assert(false, "timeout (= #{timeout} sec) in #{@filename} of #{info.desc}") @@ -533,6 +533,11 @@ def prepare # Can be overridden in child classes. end + # The sequence of ulimit commands to set the resource usage limits. + def ulimits + "" + end + # Test-result functions. # The exit status as a number @@ -804,6 +809,7 @@ def make_ruby_file(filename) requires = nil pendings = nil prepares = nil + ulimits = nil time_dilation = nil infile.each_line do |line| @@ -835,6 +841,7 @@ def make_ruby_file(filename) requires = nil pendings = nil prepares = nil + ulimits = nil time_dilation = nil if skipping line = "" @@ -888,6 +895,11 @@ def make_ruby_file(filename) prepares = prepares.join("; ") line += "def prepare; #{prepares} end; " end + if !ulimits.nil? + ulimits.map! { |s| "ulimit #{s}; " } + ulimits = ulimits.join("") + line += "def ulimits; %(#{ulimits}) end; " + end if !time_dilation.nil? line += "def timeout; super() * #{time_dilation} end;" end @@ -936,6 +948,14 @@ def make_ruby_file(filename) prepares = [] end prepares << $1 + elsif heredoc.nil? && line =~ /^\s*#\s*ulimit\s+(.*)/ + # #ulimit + # Example: #ulimit -v 4_000_000 + line = "" + if ulimits.nil? + ulimits = [] + end + ulimits << $1.gsub(/(?<=\d)_(?=\d)/, "") # remove decimal marks (underscores) elsif heredoc.nil? && line =~ /^\s*#\s*time_dilation\s+(.*)/ # #time_dilation line = "" @@ -947,8 +967,8 @@ def make_ruby_file(filename) fatal("invalid time_dilation", inname, lineno) end info.time_dilation = time_dilation - elsif heredoc.nil? && line =~ /^\*\s*#\s*(require|prepare|pend_if|time_dilation)\s+(.*)/ - # *#require/prepare/pend_if/time_dilation, commented out in the FORM way + elsif heredoc.nil? && line =~ /^\*\s*#\s*(require|prepare|pend_if|ulimit|time_dilation)\s+(.*)/ + # *#, commented out in the FORM way line = "" else if heredoc.nil?