aboutsummaryrefslogtreecommitdiff
path: root/tests/basic.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic.lua')
-rw-r--r--tests/basic.lua33
1 files changed, 21 insertions, 12 deletions
diff --git a/tests/basic.lua b/tests/basic.lua
index 068dc25..170e821 100644
--- a/tests/basic.lua
+++ b/tests/basic.lua
@@ -173,29 +173,38 @@ for k, v in pairs(limited:dump()) do
173end 173end
174local wait_send = function() 174local wait_send = function()
175 local a,b 175 local a,b
176 set_finalizer(function() print("wait_send", a, b) end) 176 set_finalizer(function(err, stack_tbl) print("wait_send", a, b, " -> ", tostring(err)) end)
177 print("in wait_send")
177 a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled 178 a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled
178end 179end
179 180
180local wait_send_lane = lanes.gen("*", { name = 'auto' }, wait_send)() 181local wait_send_lane = lanes.gen("*", { name = 'auto' }, wait_send)()
181repeat until wait_send_lane.status == "waiting" 182repeat
182print "wait_send_lane is waiting" 183 io.stderr:write('!')
184 -- currently mingw64 builds can deadlock if we cancel the lane too early (before the linda blocks, at it causes the linda condvar not to be signalled)
185 lanes.sleep(0.1)
186until wait_send_lane.status == "waiting"
187PRINT "wait_send_lane is waiting"
183wait_send_lane:cancel() -- hard cancel, 0 timeout 188wait_send_lane:cancel() -- hard cancel, 0 timeout
184repeat until wait_send_lane.status == "cancelled" 189repeat until wait_send_lane.status == "cancelled"
185print "wait_send_lane is cancelled" 190PRINT "wait_send_lane is cancelled"
186--################################################]] 191--################################################]]
187local wait_receive = function() 192local wait_receive = function()
188 local k, v 193 local k, v
189 set_finalizer(function() print("wait_receive", k, v) end) 194 set_finalizer(function(err, stack_tbl) print("wait_receive", k, v, " -> ", tostring(err)) end)
190 k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled 195 k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled
191end 196end
192 197
193local wait_receive_lane = lanes.gen("*", { name = 'auto' }, wait_receive)() 198local wait_receive_lane = lanes.gen("*", { name = 'auto' }, wait_receive)()
194repeat until wait_receive_lane.status == "waiting" 199repeat
195print "wait_receive_lane is waiting" 200 io.stderr:write('!')
201 -- currently mingw64 builds can deadlock if we cancel the lane too early (before the linda blocks, at it causes the linda condvar not to be signalled)
202 lanes.sleep(0.1)
203until wait_receive_lane.status == "waiting"
204PRINT "wait_receive_lane is waiting"
196wait_receive_lane:cancel() -- hard cancel, 0 timeout 205wait_receive_lane:cancel() -- hard cancel, 0 timeout
197repeat until wait_receive_lane.status == "cancelled" 206repeat until wait_receive_lane.status == "cancelled"
198print "wait_receive_lane is cancelled" 207PRINT "wait_receive_lane is cancelled"
199--################################################]] 208--################################################]]
200local wait_receive_batched = function() 209local wait_receive_batched = function()
201 local k, v1, v2 210 local k, v1, v2
@@ -205,10 +214,10 @@ end
205 214
206local wait_receive_batched_lane = lanes.gen("*", { name = 'auto' }, wait_receive_batched)() 215local wait_receive_batched_lane = lanes.gen("*", { name = 'auto' }, wait_receive_batched)()
207repeat until wait_receive_batched_lane.status == "waiting" 216repeat until wait_receive_batched_lane.status == "waiting"
208print "wait_receive_batched_lane is waiting" 217PRINT "wait_receive_batched_lane is waiting"
209wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout 218wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout
210repeat until wait_receive_batched_lane.status == "cancelled" 219repeat until wait_receive_batched_lane.status == "cancelled"
211print "wait_receive_batched_lane is cancelled" 220PRINT "wait_receive_batched_lane is cancelled"
212--################################################]] 221--################################################]]
213 222
214-- ################################################################################################## 223-- ##################################################################################################
@@ -437,7 +446,7 @@ local function chunk2(linda)
437 assert(config.strip_functions and info.short_src=="?" or string.match(info.short_src, "^.*basic.lua$"), "bad info.short_src") 446 assert(config.strip_functions and info.short_src=="?" or string.match(info.short_src, "^.*basic.lua$"), "bad info.short_src")
438 -- These vary so let's not be picky (they're there..) 447 -- These vary so let's not be picky (they're there..)
439 -- 448 --
440 assert(info.linedefined == 422, "bad linedefined") -- start of 'chunk2' 449 assert(info.linedefined == 431, "bad linedefined") -- start of 'chunk2'
441 assert(config.strip_functions and info.currentline==-1 or info.currentline > info.linedefined, "bad currentline") -- line of 'debug.getinfo' 450 assert(config.strip_functions and info.currentline==-1 or info.currentline > info.linedefined, "bad currentline") -- line of 'debug.getinfo'
442 assert(info.lastlinedefined > info.currentline, "bad lastlinedefined") -- end of 'chunk2' 451 assert(info.lastlinedefined > info.currentline, "bad lastlinedefined") -- end of 'chunk2'
443 local k,func= linda:receive("down") 452 local k,func= linda:receive("down")
@@ -460,7 +469,7 @@ linda:send("down", function(linda) linda:send("up", "ready!") end,
460-- 469--
461local k,s= linda:receive(1, "up") 470local k,s= linda:receive(1, "up")
462if t2.status == "error" then 471if t2.status == "error" then
463 print("t2 error: " , t2:join()) 472 PRINT("t2 error: " , t2:join())
464end 473end
465PRINT(s) 474PRINT(s)
466assert(s=="ready!") 475assert(s=="ready!")