Skip to content

Commit

Permalink
test(check.rb): add #ulimit instruction
Browse files Browse the repository at this point in the history
For example, "#ulimit -v 4_000_000" invokes "ulimit -v 4000000" before
starting FORM, which sets the maximum amount of virtual memory available
to the shell to 4*1000*1000*1024 bytes on Linux.
  • Loading branch information
tueda committed May 3, 2024
1 parent 8923c77 commit b820933
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions check/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -835,6 +841,7 @@ def make_ruby_file(filename)
requires = nil
pendings = nil
prepares = nil
ulimits = nil
time_dilation = nil
if skipping
line = ""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -936,6 +948,14 @@ def make_ruby_file(filename)
prepares = []
end
prepares << $1
elsif heredoc.nil? && line =~ /^\s*#\s*ulimit\s+(.*)/
# #ulimit <limits>
# 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 <dilation>
line = ""
Expand All @@ -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+(.*)/
# *#<special instruction>, commented out in the FORM way
line = ""
else
if heredoc.nil?
Expand Down

0 comments on commit b820933

Please sign in to comment.