diff options
Diffstat (limited to 'tests/basic.lua')
| -rw-r--r-- | tests/basic.lua | 33 |
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 | |||
| 173 | end | 173 | end |
| 174 | local wait_send = function() | 174 | local 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 |
| 178 | end | 179 | end |
| 179 | 180 | ||
| 180 | local wait_send_lane = lanes.gen("*", { name = 'auto' }, wait_send)() | 181 | local wait_send_lane = lanes.gen("*", { name = 'auto' }, wait_send)() |
| 181 | repeat until wait_send_lane.status == "waiting" | 182 | repeat |
| 182 | print "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) | ||
| 186 | until wait_send_lane.status == "waiting" | ||
| 187 | PRINT "wait_send_lane is waiting" | ||
| 183 | wait_send_lane:cancel() -- hard cancel, 0 timeout | 188 | wait_send_lane:cancel() -- hard cancel, 0 timeout |
| 184 | repeat until wait_send_lane.status == "cancelled" | 189 | repeat until wait_send_lane.status == "cancelled" |
| 185 | print "wait_send_lane is cancelled" | 190 | PRINT "wait_send_lane is cancelled" |
| 186 | --################################################]] | 191 | --################################################]] |
| 187 | local wait_receive = function() | 192 | local 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 |
| 191 | end | 196 | end |
| 192 | 197 | ||
| 193 | local wait_receive_lane = lanes.gen("*", { name = 'auto' }, wait_receive)() | 198 | local wait_receive_lane = lanes.gen("*", { name = 'auto' }, wait_receive)() |
| 194 | repeat until wait_receive_lane.status == "waiting" | 199 | repeat |
| 195 | print "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) | ||
| 203 | until wait_receive_lane.status == "waiting" | ||
| 204 | PRINT "wait_receive_lane is waiting" | ||
| 196 | wait_receive_lane:cancel() -- hard cancel, 0 timeout | 205 | wait_receive_lane:cancel() -- hard cancel, 0 timeout |
| 197 | repeat until wait_receive_lane.status == "cancelled" | 206 | repeat until wait_receive_lane.status == "cancelled" |
| 198 | print "wait_receive_lane is cancelled" | 207 | PRINT "wait_receive_lane is cancelled" |
| 199 | --################################################]] | 208 | --################################################]] |
| 200 | local wait_receive_batched = function() | 209 | local wait_receive_batched = function() |
| 201 | local k, v1, v2 | 210 | local k, v1, v2 |
| @@ -205,10 +214,10 @@ end | |||
| 205 | 214 | ||
| 206 | local wait_receive_batched_lane = lanes.gen("*", { name = 'auto' }, wait_receive_batched)() | 215 | local wait_receive_batched_lane = lanes.gen("*", { name = 'auto' }, wait_receive_batched)() |
| 207 | repeat until wait_receive_batched_lane.status == "waiting" | 216 | repeat until wait_receive_batched_lane.status == "waiting" |
| 208 | print "wait_receive_batched_lane is waiting" | 217 | PRINT "wait_receive_batched_lane is waiting" |
| 209 | wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout | 218 | wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout |
| 210 | repeat until wait_receive_batched_lane.status == "cancelled" | 219 | repeat until wait_receive_batched_lane.status == "cancelled" |
| 211 | print "wait_receive_batched_lane is cancelled" | 220 | PRINT "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 | -- |
| 461 | local k,s= linda:receive(1, "up") | 470 | local k,s= linda:receive(1, "up") |
| 462 | if t2.status == "error" then | 471 | if t2.status == "error" then |
| 463 | print("t2 error: " , t2:join()) | 472 | PRINT("t2 error: " , t2:join()) |
| 464 | end | 473 | end |
| 465 | PRINT(s) | 474 | PRINT(s) |
| 466 | assert(s=="ready!") | 475 | assert(s=="ready!") |
