Skip to content

Commit

Permalink
test: corner cases for moebius_ (#430)
Browse files Browse the repository at this point in the history
* (check.rb) Added #time_dilation instruction to extend the timeout
  limit for each test.

Close #430.
  • Loading branch information
tueda committed Dec 23, 2022
1 parent e7c52d3 commit 6cc038c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 8 deletions.
38 changes: 30 additions & 8 deletions check/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,14 @@ def initialize
@foldname = nil # fold name of the test
@enabled = nil # enabled or not
@sources = [] # FORM sources
@time_dilation = nil
@status = nil # status
@times = nil # elapsed time (array)
end
attr_accessor :classname, :where, :foldname, :enabled, :sources, :status, :times
attr_accessor :classname, :where, :foldname, :enabled, :sources, :time_dilation,
:status, :times
# Return the description of the test.
def desc
Expand Down Expand Up @@ -762,6 +764,7 @@ def make_ruby_file(filename)
requires = nil
pendings = nil
prepares = nil
time_dilation = nil
infile.each_line do |line|
line.chop!
Expand Down Expand Up @@ -792,6 +795,7 @@ def make_ruby_file(filename)
requires = nil
pendings = nil
prepares = nil
time_dilation = nil
if skipping
line = ""
else
Expand Down Expand Up @@ -844,6 +848,9 @@ def make_ruby_file(filename)
prepares = prepares.join("; ")
line += "def prepare; #{prepares} end; "
end
if !time_dilation.nil?
line += "def timeout; super() * #{time_dilation} end;"
end
line += "end"
end
level = 0
Expand Down Expand Up @@ -889,8 +896,19 @@ def make_ruby_file(filename)
prepares = []
end
prepares << $1
elsif heredoc.nil? && line =~ /^\*\s*#\s*(require|prepare|pend_if)\s+(.*)/
# *#require/prepare/pend_if, commented out in the FORM way
elsif heredoc.nil? && line =~ /^\s*#\s*time_dilation\s+(.*)/
# #time_dilation <dilation>
line = ""
if !time_dilation.nil?
fatal("attempted to set time_dilation twice", inname, lineno)
end
time_dilation = $1.to_f
if time_dilation <= 0
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
line = ""
else
if heredoc.nil?
Expand Down Expand Up @@ -1462,28 +1480,32 @@ def finalize
bar_width = 40
end
puts("timeout: #{FormTest.cfg.timeout}s")
puts("default timeout: #{FormTest.cfg.timeout}s")
infos.each do |info|
(0..info.sources.length - 1).each do |i|
t = 0
if !info.times.nil? && i < info.times.length
t = info.times[i]
end
timeout = FormTest.cfg.timeout
if !info.time_dilation.nil?
timeout *= info.time_dilation
end
if i == 0
puts(format("%s %s %s %s%s",
lpad(info.foldname, max_foldname_width),
lpad("(#{info.where})", max_where_width),
lpad(info.status.nil? ? "UNKNOWN" : info.status, status_width),
bar_str(t, FormTest.cfg.timeout, bar_width),
format_time(t, FormTest.cfg.timeout)))
bar_str(t, timeout, bar_width),
format_time(t, timeout)))
else
puts(format("%s %s %s %s%s",
lpad("", max_foldname_width),
lpad("", max_where_width),
lpad("", status_width),
bar_str(t, FormTest.cfg.timeout, bar_width),
format_time(t, FormTest.cfg.timeout)))
bar_str(t, timeout, bar_width),
format_time(t, timeout)))
end
end
end
Expand Down
1 change: 1 addition & 0 deletions check/examples.frm
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,7 @@ Print;
#define LOOPS "6"
Local F = topologies_(`LOOPS',-2,{3,},QQ,PP);
.end
#time_dilation 2.0
assert succeeded?
assert nterms("F") == 2793
*--#] Diagrams_4 :
Expand Down
35 changes: 35 additions & 0 deletions check/features.frm
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,41 @@ assert result("F") =~ expr("
x^203 - x^205 - x^206 + x^207 + x^209 + x^210
")
*--#] moebius_2 :
*--#[ moebius_3 :
* corner cases, see #430
#do i=1,9
L F`i' = moebius_(2^15-`i');
#enddo
#do i=1,9
L G`i' = moebius_(2^31-`i');
#enddo
P;
.end
#time_dilation 4.0
assert succeeded?
if wordsize >= 2
assert result("F1") =~ expr("-1")
assert result("F2") =~ expr("1")
assert result("F3") =~ expr("1")
assert result("F4") =~ expr("0")
assert result("F5") =~ expr("-1")
assert result("F6") =~ expr("1")
assert result("F7") =~ expr("0")
assert result("F8") =~ expr("0")
assert result("F9") =~ expr("-1")
end
if wordsize >= 4
assert result("G1") =~ expr("-1")
assert result("G2") =~ expr("0")
assert result("G3") =~ expr("-1")
assert result("G4") =~ expr("0")
assert result("G5") =~ expr("1")
assert result("G6") =~ expr("-1")
assert result("G7") =~ expr("1")
assert result("G8") =~ expr("0")
assert result("G9") =~ expr("-1")
end
*--#] moebius_3 :
*--#[ partitions_ :
* Test partitions function
#-
Expand Down
1 change: 1 addition & 0 deletions check/fixes.frm
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,7 @@ P;
.end
# Too slow on Travis CI. ParFORM didn't have this bug.
#pend_if travis? && (!linux? || valgrind? || mpi?)
#time_dilation 2.0
assert succeeded?
assert result("F1") =~ expr("2027025")
*--#] Issue154 :
Expand Down

0 comments on commit 6cc038c

Please sign in to comment.