diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/appendud.lua | 1 | ||||
-rw-r--r-- | tests/atomic.lua | 1 | ||||
-rw-r--r-- | tests/basic.lua | 5 | ||||
-rw-r--r-- | tests/cyclic.lua | 1 | ||||
-rw-r--r-- | tests/deadlock.lua | 49 | ||||
-rw-r--r-- | tests/ehynes.lua | 1 | ||||
-rw-r--r-- | tests/fibonacci.lua | 2 | ||||
-rw-r--r-- | tests/hangtest.lua | 1 | ||||
-rw-r--r-- | tests/irayo_closure.lua | 1 | ||||
-rw-r--r-- | tests/irayo_recursive.lua | 2 | ||||
-rw-r--r-- | tests/launchtest.lua | 1 | ||||
-rw-r--r-- | tests/objects.lua | 1 | ||||
-rw-r--r-- | tests/parallel_os_calls.lua | 2 | ||||
-rw-r--r-- | tests/pingpong.lua | 2 | ||||
-rw-r--r-- | tests/recursive.lua | 8 |
15 files changed, 35 insertions, 43 deletions
diff --git a/tests/appendud.lua b/tests/appendud.lua index d0efb26..f510c8b 100644 --- a/tests/appendud.lua +++ b/tests/appendud.lua | |||
@@ -7,7 +7,6 @@ | |||
7 | -- Needs Lanes >= 2.0.3 | 7 | -- Needs Lanes >= 2.0.3 |
8 | -- | 8 | -- |
9 | local lanes = require "lanes" | 9 | local lanes = require "lanes" |
10 | lanes.configure() | ||
11 | 10 | ||
12 | local _tab = { | 11 | local _tab = { |
13 | beginupdate = function (this) print('tab.beginupdate') end; | 12 | beginupdate = function (this) print('tab.beginupdate') end; |
diff --git a/tests/atomic.lua b/tests/atomic.lua index 12bdf02..2de8f52 100644 --- a/tests/atomic.lua +++ b/tests/atomic.lua | |||
@@ -5,7 +5,6 @@ | |||
5 | -- | 5 | -- |
6 | 6 | ||
7 | local lanes = require "lanes" | 7 | local lanes = require "lanes" |
8 | lanes.configure() | ||
9 | 8 | ||
10 | local linda= lanes.linda() | 9 | local linda= lanes.linda() |
11 | local key= "$" | 10 | local key= "$" |
diff --git a/tests/basic.lua b/tests/basic.lua index cad3764..bdad44c 100644 --- a/tests/basic.lua +++ b/tests/basic.lua | |||
@@ -7,7 +7,8 @@ | |||
7 | -- - ... | 7 | -- - ... |
8 | -- | 8 | -- |
9 | local config = { with_timers = false, strip_functions = false, internal_allocator = "libc"} | 9 | local config = { with_timers = false, strip_functions = false, internal_allocator = "libc"} |
10 | local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure(config) | 10 | -- calling configure more than once should work (additional called are ignored) |
11 | local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure(config).configure() | ||
11 | print("require_lanes_result:", require_lanes_result_1, require_lanes_result_2) | 12 | print("require_lanes_result:", require_lanes_result_1, require_lanes_result_2) |
12 | local lanes = require_lanes_result_1 | 13 | local lanes = require_lanes_result_1 |
13 | 14 | ||
@@ -434,7 +435,7 @@ local function chunk2(linda) | |||
434 | assert(config.strip_functions and info.short_src=="?" or string.match(info.short_src, "^.*basic.lua$"), "bad info.short_src") | 435 | assert(config.strip_functions and info.short_src=="?" or string.match(info.short_src, "^.*basic.lua$"), "bad info.short_src") |
435 | -- These vary so let's not be picky (they're there..) | 436 | -- These vary so let's not be picky (they're there..) |
436 | -- | 437 | -- |
437 | assert(info.linedefined == 419, "bad linedefined") -- start of 'chunk2' | 438 | assert(info.linedefined == 420, "bad linedefined") -- start of 'chunk2' |
438 | assert(config.strip_functions and info.currentline==-1 or info.currentline > info.linedefined, "bad currentline") -- line of 'debug.getinfo' | 439 | assert(config.strip_functions and info.currentline==-1 or info.currentline > info.linedefined, "bad currentline") -- line of 'debug.getinfo' |
439 | assert(info.lastlinedefined > info.currentline, "bad lastlinedefined") -- end of 'chunk2' | 440 | assert(info.lastlinedefined > info.currentline, "bad lastlinedefined") -- end of 'chunk2' |
440 | local k,func= linda:receive("down") | 441 | local k,func= linda:receive("down") |
diff --git a/tests/cyclic.lua b/tests/cyclic.lua index 553d2a9..fd6d4a0 100644 --- a/tests/cyclic.lua +++ b/tests/cyclic.lua | |||
@@ -5,7 +5,6 @@ | |||
5 | -- | 5 | -- |
6 | 6 | ||
7 | local lanes = require "lanes" | 7 | local lanes = require "lanes" |
8 | lanes.configure() | ||
9 | 8 | ||
10 | local table_concat= assert(table.concat) | 9 | local table_concat= assert(table.concat) |
11 | 10 | ||
diff --git a/tests/deadlock.lua b/tests/deadlock.lua index c38ca13..bbbda8d 100644 --- a/tests/deadlock.lua +++ b/tests/deadlock.lua | |||
@@ -1,8 +1,10 @@ | |||
1 | -- this script tests the fix of a bug that could cause the mutex of a keeper state to remain locked | 1 | -- this script tests the fix of a bug that could cause the mutex of a keeper state to remain locked |
2 | -- see https://github.com/LuaLanes/lanes/commit/0cc1c9c9dcea5955f7dab921d9a2fff78c4e1729 | 2 | -- see https://github.com/LuaLanes/lanes/commit/0cc1c9c9dcea5955f7dab921d9a2fff78c4e1729 |
3 | 3 | ||
4 | local lanes = require('lanes').configure{with_timers=false} | 4 | local lanes = require "lanes" |
5 | local linda = lanes.linda "deadlock_linda" | 5 | |
6 | -- Lua 5.1 compatibility | ||
7 | local table_unpack = table.unpack or unpack | ||
6 | 8 | ||
7 | local SLEEP = function(...) | 9 | local SLEEP = function(...) |
8 | local k, v = lanes.sleep(...) | 10 | local k, v = lanes.sleep(...) |
@@ -14,27 +16,28 @@ print "let's begin" | |||
14 | local do_extra_stuff = true | 16 | local do_extra_stuff = true |
15 | 17 | ||
16 | if do_extra_stuff then | 18 | if do_extra_stuff then |
17 | -- just something to make send() succeed and receive() fail (any C function exposed by some module will do) | 19 | local linda = lanes.linda "deadlock_linda" |
18 | local payload = { lanes.require('socket').connect } | 20 | -- just something to make send() succeed and receive() fail |
19 | 21 | local payload = { io.flush } | |
20 | -- lane generator | 22 | |
21 | local g = lanes.gen('*', function() | 23 | -- lane generator. don't initialize "io" base library so that it is not known in the lane |
22 | set_debug_threadname( "deadlock_lane") | 24 | local g = lanes.gen('base,table', function() |
23 | -- wrapping inside pcall makes the Lanes module unaware that something went wrong | 25 | set_debug_threadname( "deadlock_lane") |
24 | print( "In lane 1:", table.unpack{ pcall( linda.receive, linda, 'tmp')}) | 26 | -- wrapping inside pcall makes the Lanes module unaware that something went wrong |
25 | -- with the bug not fixed, and non-recursive mutexes, we can hang here | 27 | print( "In lane 1:", table_unpack{ pcall( linda.receive, linda, 'tmp')}) |
26 | print( "In lane 2:", table.unpack{ pcall( linda.receive, linda, 'tmp')}) | 28 | -- with the bug not fixed, and non-recursive mutexes, we can hang here |
27 | -- return something out of the lane | 29 | print( "In lane 2:", table_unpack{ pcall( linda.receive, linda, 'tmp')}) |
28 | return 33, 55 | 30 | -- return something out of the lane |
29 | end) | 31 | return 33, 55 |
30 | 32 | end) | |
31 | -- send payload twice. succeeds because sending stores a function identification string in the linda's keeper state | 33 | |
32 | linda:send( 'tmp', payload, payload) | 34 | -- send payload twice. succeeds because sending stores a function identification string in the linda's keeper state |
33 | -- start the lane | 35 | linda:send( 'tmp', payload, payload) |
34 | local h = g() | 36 | -- start the lane |
35 | -- wait for lane completion | 37 | local h = g() |
36 | local err, stack = h:join() | 38 | -- wait for lane completion |
37 | print( 'result of lane execution', err, stack) | 39 | local err, stack = h:join() |
40 | print( 'result of lane execution', err, stack) | ||
38 | end | 41 | end |
39 | 42 | ||
40 | -- With the bug not fixed, the linda keeper's mutex is still acquired, | 43 | -- With the bug not fixed, the linda keeper's mutex is still acquired, |
diff --git a/tests/ehynes.lua b/tests/ehynes.lua index 9436c7d..cdcd5a5 100644 --- a/tests/ehynes.lua +++ b/tests/ehynes.lua | |||
@@ -2,7 +2,6 @@ | |||
2 | -- Test from <ehynes at dharmagaia.com> | 2 | -- Test from <ehynes at dharmagaia.com> |
3 | -- | 3 | -- |
4 | local lanes = require "lanes" | 4 | local lanes = require "lanes" |
5 | lanes.configure() | ||
6 | 5 | ||
7 | local SLEEP = function(...) | 6 | local SLEEP = function(...) |
8 | local k, v = lanes.sleep(...) | 7 | local k, v = lanes.sleep(...) |
diff --git a/tests/fibonacci.lua b/tests/fibonacci.lua index 0ff2f37..51e7137 100644 --- a/tests/fibonacci.lua +++ b/tests/fibonacci.lua | |||
@@ -12,7 +12,7 @@ | |||
12 | 12 | ||
13 | -- Need to say it's 'local' so it can be an upvalue | 13 | -- Need to say it's 'local' so it can be an upvalue |
14 | -- | 14 | -- |
15 | local lanes = require "lanes".configure() | 15 | local lanes = require "lanes" |
16 | 16 | ||
17 | local function WR(str) | 17 | local function WR(str) |
18 | io.stderr:write( str.."\n" ) | 18 | io.stderr:write( str.."\n" ) |
diff --git a/tests/hangtest.lua b/tests/hangtest.lua index 6a9f7aa..0e44451 100644 --- a/tests/hangtest.lua +++ b/tests/hangtest.lua | |||
@@ -3,7 +3,6 @@ | |||
3 | -- | 3 | -- |
4 | 4 | ||
5 | local lanes = require "lanes" | 5 | local lanes = require "lanes" |
6 | lanes.configure() | ||
7 | 6 | ||
8 | local function ret(b) | 7 | local function ret(b) |
9 | return b | 8 | return b |
diff --git a/tests/irayo_closure.lua b/tests/irayo_closure.lua index 3278d57..45189ec 100644 --- a/tests/irayo_closure.lua +++ b/tests/irayo_closure.lua | |||
@@ -11,7 +11,6 @@ e.g. { globals = { data = 1, func = function() useclosurehere() end } }" | |||
11 | ]] | 11 | ]] |
12 | 12 | ||
13 | local lanes = require "lanes" | 13 | local lanes = require "lanes" |
14 | lanes.configure() | ||
15 | 14 | ||
16 | local function testrun() | 15 | local function testrun() |
17 | assert( print ) | 16 | assert( print ) |
diff --git a/tests/irayo_recursive.lua b/tests/irayo_recursive.lua index fe722a3..88f4aab 100644 --- a/tests/irayo_recursive.lua +++ b/tests/irayo_recursive.lua | |||
@@ -1,4 +1,4 @@ | |||
1 | local lanes = require "lanes".configure() | 1 | local lanes = require "lanes" |
2 | -- | 2 | -- |
3 | -- Bugs filed by irayo Jul-2008 | 3 | -- Bugs filed by irayo Jul-2008 |
4 | -- | 4 | -- |
diff --git a/tests/launchtest.lua b/tests/launchtest.lua index f3a6740..16db242 100644 --- a/tests/launchtest.lua +++ b/tests/launchtest.lua | |||
@@ -46,7 +46,6 @@ for k,v in pairs( argtable(...) ) do | |||
46 | end | 46 | end |
47 | 47 | ||
48 | local lanes = require "lanes" | 48 | local lanes = require "lanes" |
49 | lanes.configure() | ||
50 | 49 | ||
51 | local g= lanes.gen( LIBS, function(i) | 50 | local g= lanes.gen( LIBS, function(i) |
52 | --io.stderr:write( i.."\t" ) | 51 | --io.stderr:write( i.."\t" ) |
diff --git a/tests/objects.lua b/tests/objects.lua index 7668e45..61c280d 100644 --- a/tests/objects.lua +++ b/tests/objects.lua | |||
@@ -5,7 +5,6 @@ | |||
5 | -- | 5 | -- |
6 | 6 | ||
7 | local lanes = require "lanes" | 7 | local lanes = require "lanes" |
8 | lanes.configure() | ||
9 | 8 | ||
10 | local linda= lanes.linda() | 9 | local linda= lanes.linda() |
11 | 10 | ||
diff --git a/tests/parallel_os_calls.lua b/tests/parallel_os_calls.lua index 7e7de26..8030d4c 100644 --- a/tests/parallel_os_calls.lua +++ b/tests/parallel_os_calls.lua | |||
@@ -1,4 +1,4 @@ | |||
1 | local lanes = require "lanes".configure() | 1 | local lanes = require "lanes" |
2 | print( os.date()) | 2 | print( os.date()) |
3 | local linda = lanes.linda() | 3 | local linda = lanes.linda() |
4 | local l1 = lanes.gen("os,base", function() print "start sleeping" linda:receive(3, "null") print("finished_sleeping " .. os.date()) return true end)() | 4 | local l1 = lanes.gen("os,base", function() print "start sleeping" linda:receive(3, "null") print("finished_sleeping " .. os.date()) return true end)() |
diff --git a/tests/pingpong.lua b/tests/pingpong.lua index fdc60a6..3498f49 100644 --- a/tests/pingpong.lua +++ b/tests/pingpong.lua | |||
@@ -1,4 +1,4 @@ | |||
1 | local lanes = require 'lanes'.configure() | 1 | local lanes = require "lanes" |
2 | local q = lanes.linda() | 2 | local q = lanes.linda() |
3 | 3 | ||
4 | local pingpong = function(name, qr, qs, start) | 4 | local pingpong = function(name, qr, qs, start) |
diff --git a/tests/recursive.lua b/tests/recursive.lua index 139f4c8..97b9c5b 100644 --- a/tests/recursive.lua +++ b/tests/recursive.lua | |||
@@ -12,14 +12,10 @@ local function func( depth ) | |||
12 | end | 12 | end |
13 | 13 | ||
14 | local lanes = require "lanes" | 14 | local lanes = require "lanes" |
15 | -- lanes.configure() is available only at the first require() | 15 | local lane = lanes.gen("*", func)( depth+1 ) |
16 | if lanes.configure then | ||
17 | lanes = lanes.configure{with_timers = false} | ||
18 | end | ||
19 | local lane= lanes.gen("*", func)( depth+1 ) | ||
20 | return lane[1] | 16 | return lane[1] |
21 | end | 17 | end |
22 | 18 | ||
23 | local v= func(0) | 19 | local v= func(0) |
24 | assert(v=="done!") | 20 | assert(v=="done!") |
25 | io.stderr:write("\n") | 21 | io.stderr:write("TEST OK\n") |