You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing some lua code on OpenWrt 22.03 (latest for my device) which has Lua 5.1.5. I downloaded the luaunit.lua (version 3.4) file to my device, but when running I got the error
luaunit.lua:247: bad argument #1 to 'randomseed' (integer expected, got number)
It seems that the line below returns a number that is bigger than a 32 bit signed integer: math.floor(os.clock()*1E11)
The initial value of the os.clock() is several hundred ms e.g. 0.07.
Suggestion - use modulus to force range within 32 bit range (and this worked for me) math.floor((os.clock()*1E11) % 2147483647)
I'm developing some lua code on OpenWrt 22.03 (latest for my device) which has Lua 5.1.5. I downloaded the luaunit.lua (version 3.4) file to my device, but when running I got the error
luaunit.lua:247: bad argument #1 to 'randomseed' (integer expected, got number)
It seems that the line below returns a number that is bigger than a 32 bit signed integer:
math.floor(os.clock()*1E11)
The initial value of the os.clock() is several hundred ms e.g. 0.07.
Suggestion - use modulus to force range within 32 bit range (and this worked for me)
math.floor((os.clock()*1E11) % 2147483647)
I noticed there was a related PR here
OpenWRT details
root@host:~# cat /etc/openwrt_release DISTRIB_ID='OpenWrt' DISTRIB_RELEASE='22.03.4' DISTRIB_REVISION='r20123-38ccc47687' DISTRIB_TARGET='ath79/nand' DISTRIB_ARCH='mips_24kc' DISTRIB_DESCRIPTION='OpenWrt 22.03.4 r20123-38ccc47687' DISTRIB_TAINTS='busybox'
Lua details
root@host:~# lua -v Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio (double int32)
The text was updated successfully, but these errors were encountered: