effil/tests/lua/thread-stress.lua
mihacooper ef93c6a2a8
Rework thread cancellation, using regular exception (#177)
BREAKS BACK COMPATIBILITY:
  - cancellation error can be caught by `pcall`
  - `canceled` thread status was renamed to `cancelled`
2022-12-05 22:09:39 +01:00

16 lines
456 B
Lua

require "bootstrap-tests"
test.thread_stress.tear_down = default_tear_down
test.thread_stress.time = function ()
local function check_time(real_time, use_time, metric)
local start_time = os.time()
effil.sleep(use_time, metric)
test.almost_equal(os.time(), start_time + real_time, 2)
end
check_time(4, 4, nil) -- seconds by default
check_time(4, 4, 's')
check_time(4, 4000, 'ms')
check_time(60, 1, 'm')
end