aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-11 14:58:04 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-11 14:58:04 +0200
commit5693bdd8353ae6b623fe5b6210daa72983c220d0 (patch)
treecbe473b56a4491ea5f18c6b7ffe2b3cd453b34e2 /tests
parent3589b8e04ecc7e02674547c4738a54954f6758bc (diff)
downloadlanes-5693bdd8353ae6b623fe5b6210daa72983c220d0.tar.gz
lanes-5693bdd8353ae6b623fe5b6210daa72983c220d0.tar.bz2
lanes-5693bdd8353ae6b623fe5b6210daa72983c220d0.zip
Adjust lanes.configure() documentation
Diffstat (limited to 'tests')
-rw-r--r--tests/appendud.lua1
-rw-r--r--tests/atomic.lua1
-rw-r--r--tests/basic.lua5
-rw-r--r--tests/cyclic.lua1
-rw-r--r--tests/deadlock.lua49
-rw-r--r--tests/ehynes.lua1
-rw-r--r--tests/fibonacci.lua2
-rw-r--r--tests/hangtest.lua1
-rw-r--r--tests/irayo_closure.lua1
-rw-r--r--tests/irayo_recursive.lua2
-rw-r--r--tests/launchtest.lua1
-rw-r--r--tests/objects.lua1
-rw-r--r--tests/parallel_os_calls.lua2
-rw-r--r--tests/pingpong.lua2
-rw-r--r--tests/recursive.lua8
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--
9local lanes = require "lanes" 9local lanes = require "lanes"
10lanes.configure()
11 10
12local _tab = { 11local _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
7local lanes = require "lanes" 7local lanes = require "lanes"
8lanes.configure()
9 8
10local linda= lanes.linda() 9local linda= lanes.linda()
11local key= "$" 10local 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--
9local config = { with_timers = false, strip_functions = false, internal_allocator = "libc"} 9local config = { with_timers = false, strip_functions = false, internal_allocator = "libc"}
10local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure(config) 10-- calling configure more than once should work (additional called are ignored)
11local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure(config).configure()
11print("require_lanes_result:", require_lanes_result_1, require_lanes_result_2) 12print("require_lanes_result:", require_lanes_result_1, require_lanes_result_2)
12local lanes = require_lanes_result_1 13local 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
7local lanes = require "lanes" 7local lanes = require "lanes"
8lanes.configure()
9 8
10local table_concat= assert(table.concat) 9local 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
4local lanes = require('lanes').configure{with_timers=false} 4local lanes = require "lanes"
5local linda = lanes.linda "deadlock_linda" 5
6-- Lua 5.1 compatibility
7local table_unpack = table.unpack or unpack
6 8
7local SLEEP = function(...) 9local SLEEP = function(...)
8 local k, v = lanes.sleep(...) 10 local k, v = lanes.sleep(...)
@@ -14,27 +16,28 @@ print "let's begin"
14local do_extra_stuff = true 16local do_extra_stuff = true
15 17
16if do_extra_stuff then 18if 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)
38end 41end
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--
4local lanes = require "lanes" 4local lanes = require "lanes"
5lanes.configure()
6 5
7local SLEEP = function(...) 6local 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--
15local lanes = require "lanes".configure() 15local lanes = require "lanes"
16 16
17local function WR(str) 17local 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
5local lanes = require "lanes" 5local lanes = require "lanes"
6lanes.configure()
7 6
8local function ret(b) 7local 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
13local lanes = require "lanes" 13local lanes = require "lanes"
14lanes.configure()
15 14
16local function testrun() 15local 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 @@
1local lanes = require "lanes".configure() 1local 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
46end 46end
47 47
48local lanes = require "lanes" 48local lanes = require "lanes"
49lanes.configure()
50 49
51local g= lanes.gen( LIBS, function(i) 50local 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
7local lanes = require "lanes" 7local lanes = require "lanes"
8lanes.configure()
9 8
10local linda= lanes.linda() 9local 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 @@
1local lanes = require "lanes".configure() 1local lanes = require "lanes"
2print( os.date()) 2print( os.date())
3local linda = lanes.linda() 3local linda = lanes.linda()
4local l1 = lanes.gen("os,base", function() print "start sleeping" linda:receive(3, "null") print("finished_sleeping " .. os.date()) return true end)() 4local 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 @@
1local lanes = require 'lanes'.configure() 1local lanes = require "lanes"
2local q = lanes.linda() 2local q = lanes.linda()
3 3
4local pingpong = function(name, qr, qs, start) 4local 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]
21end 17end
22 18
23local v= func(0) 19local v= func(0)
24assert(v=="done!") 20assert(v=="done!")
25io.stderr:write("\n") 21io.stderr:write("TEST OK\n")