Source: lua-bitop
Version: 1.0.2-3
Severity: important
Tags: patch
User: debian-h...@lists.debian.org
Usertags: hurd

Hello,

Currently lua-bitop FTBFS for GNU/Hurd due to a test that runs forever,
creating a timeout after a very long time. From the build log: Build
killed with signal TERM after 180 minutes of inactivity.

The reason is that the bitbench.lua test assumes a clock resolution of
1us. On Hurd, it is 10ms, making a difference of 10 000 times. The
attached patch fixes this by scaling the times by that amount, while
other systems are not affected. Maybe some smarter way of detecting the
OS name is possible, I'm not fluent in lua programming.

Thanks!

--- a/bitbench.lua	2012-05-08 21:15:00.000000000 +0200
+++ b/bitbench.lua	2014-10-14 00:12:33.000000000 +0200
@@ -19,10 +19,19 @@
 
 local function bench(name, t)
   local n = 2000000
+  local s = io.popen("uname -s"):read("*l")
   repeat
-    local tm = os.clock()
-    t(n)
-    tm = os.clock() - tm
+    local tm
+--  Clock resolution is 10 ms on GNU/Hurd not 1us
+    if s == "GNU" then
+      tm = 10000*os.clock()
+      t(n)
+      tm = 10000*os.clock() - tm
+    else
+      tm = os.clock()
+      t(n)
+      tm = os.clock() - tm
+    end
     if tm > 1 then
       local ns = tm*1000/(n/1000000)
       io.write(string.format("%-15s %6.1f ns\n", name, ns-base))

Reply via email to