diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-14 14:53:09 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-14 14:53:09 +0100 |
commit | 512f4c0b46ea5cc359e673b7379cd81925863121 (patch) | |
tree | 1e72167d8d63f44109719db9643d4c0445b17d57 /unit_tests | |
parent | 0aa030db022c57947afbae3b97038a403973e3cd (diff) | |
download | lanes-master.tar.gz lanes-master.tar.bz2 lanes-master.zip |
Diffstat (limited to 'unit_tests')
-rw-r--r-- | unit_tests/embedded_tests.cpp | 2 | ||||
-rw-r--r-- | unit_tests/init_and_shutdown.cpp | 1 | ||||
-rw-r--r-- | unit_tests/lane_tests.cpp | 2 | ||||
-rw-r--r-- | unit_tests/scripts/coro/basics.lua | 2 | ||||
-rw-r--r-- | unit_tests/scripts/lane/cooperative_shutdown.lua | 6 | ||||
-rw-r--r-- | unit_tests/scripts/lane/stdlib_naming.lua | 2 | ||||
-rw-r--r-- | unit_tests/scripts/lane/tasking_basic.lua | 2 | ||||
-rw-r--r-- | unit_tests/scripts/lane/tasking_cancelling.lua | 8 | ||||
-rw-r--r-- | unit_tests/scripts/lane/tasking_comms_criss_cross.lua | 2 | ||||
-rw-r--r-- | unit_tests/scripts/lane/tasking_communications.lua | 2 | ||||
-rw-r--r-- | unit_tests/scripts/lane/tasking_error.lua | 2 | ||||
-rw-r--r-- | unit_tests/scripts/lane/tasking_join_test.lua | 2 | ||||
-rw-r--r-- | unit_tests/scripts/lane/tasking_send_receive_code.lua | 2 | ||||
-rw-r--r-- | unit_tests/scripts/lane/uncooperative_shutdown.lua | 2 |
14 files changed, 19 insertions, 18 deletions
diff --git a/unit_tests/embedded_tests.cpp b/unit_tests/embedded_tests.cpp index a63383a..9a262d5 100644 --- a/unit_tests/embedded_tests.cpp +++ b/unit_tests/embedded_tests.cpp | |||
@@ -234,7 +234,7 @@ TEST_CASE("lanes.embedding.with custom allocator") | |||
234 | // lua_setfield(L, -2, "allocator"); // configure {on_state_create = on_state_create_, allocater = "protected"} | 234 | // lua_setfield(L, -2, "allocator"); // configure {on_state_create = on_state_create_, allocater = "protected"} |
235 | lua_pcall(L, 1, 0, 0); | 235 | lua_pcall(L, 1, 0, 0); |
236 | sprintf_s(script, | 236 | sprintf_s(script, |
237 | "g = lanes.gen('*', {globals = {ID = %d}}, function(id_) lane_threadname('Lane %d.'..id_) logPrint('This is L%d.'..id_) end)" // lane generator | 237 | "g = lanes.gen('*', { name = 'auto', globals = {ID = %d} }, function(id_) lane_threadname('Lane %d.'..id_) logPrint('This is L%d.'..id_) end)" // lane generator |
238 | "for i = 1,%d do _G['a'..i] = g(i) end" // launch a few lanes, handle stored in global a<i> | 238 | "for i = 1,%d do _G['a'..i] = g(i) end" // launch a few lanes, handle stored in global a<i> |
239 | , | 239 | , |
240 | id_, | 240 | id_, |
diff --git a/unit_tests/init_and_shutdown.cpp b/unit_tests/init_and_shutdown.cpp index 7e4c215..9652f2d 100644 --- a/unit_tests/init_and_shutdown.cpp +++ b/unit_tests/init_and_shutdown.cpp | |||
@@ -829,6 +829,7 @@ TEST_CASE("lanes.on_state_create setting") | |||
829 | // launch a Lane that requires the module. It should succeed because _on_state_create was called and made it possible | 829 | // launch a Lane that requires the module. It should succeed because _on_state_create was called and made it possible |
830 | std::string_view const _script{ | 830 | std::string_view const _script{ |
831 | " f = lanes.gen('*'," | 831 | " f = lanes.gen('*'," |
832 | " { name = 'auto' }," | ||
832 | " function()" | 833 | " function()" |
833 | " local Stuff = require ('Stuff')" | 834 | " local Stuff = require ('Stuff')" |
834 | " Stuff.DoStuffInC()" | 835 | " Stuff.DoStuffInC()" |
diff --git a/unit_tests/lane_tests.cpp b/unit_tests/lane_tests.cpp index bf239ba..0c4feba 100644 --- a/unit_tests/lane_tests.cpp +++ b/unit_tests/lane_tests.cpp | |||
@@ -80,7 +80,7 @@ TEST_CASE("lanes.sleep.interactions with timers") | |||
80 | " local l = lanes.linda()" | 80 | " local l = lanes.linda()" |
81 | " lanes.timer(l, 'gluh', 0.1, 0.1)" | 81 | " lanes.timer(l, 'gluh', 0.1, 0.1)" |
82 | // launch a lane that is supposed to sleep forever | 82 | // launch a lane that is supposed to sleep forever |
83 | " local g = lanes.gen('*', lanes.sleep)" | 83 | " local g = lanes.gen('*', { name = 'auto' }, lanes.sleep)" |
84 | " local h = g('indefinitely')" | 84 | " local h = g('indefinitely')" |
85 | // sleep 1 second (this uses the timer linda) | 85 | // sleep 1 second (this uses the timer linda) |
86 | " lanes.sleep(1)" | 86 | " lanes.sleep(1)" |
diff --git a/unit_tests/scripts/coro/basics.lua b/unit_tests/scripts/coro/basics.lua index dc74b7c..cd2f410 100644 --- a/unit_tests/scripts/coro/basics.lua +++ b/unit_tests/scripts/coro/basics.lua | |||
@@ -42,7 +42,7 @@ end | |||
42 | 42 | ||
43 | if true then | 43 | if true then |
44 | -- if we start a non-coroutine lane with a yielding function, we should get an error, right? | 44 | -- if we start a non-coroutine lane with a yielding function, we should get an error, right? |
45 | local fun_g = lanes.gen("*", {name = "auto"}, yielder) | 45 | local fun_g = lanes.gen("*", { name = 'auto' }, yielder) |
46 | local h = fun_g("hello", "world", "!") | 46 | local h = fun_g("hello", "world", "!") |
47 | local err, status, stack = h:join() | 47 | local err, status, stack = h:join() |
48 | PRINT(err, status, stack) | 48 | PRINT(err, status, stack) |
diff --git a/unit_tests/scripts/lane/cooperative_shutdown.lua b/unit_tests/scripts/lane/cooperative_shutdown.lua index 1204e35..756e33c 100644 --- a/unit_tests/scripts/lane/cooperative_shutdown.lua +++ b/unit_tests/scripts/lane/cooperative_shutdown.lua | |||
@@ -31,9 +31,9 @@ end | |||
31 | 31 | ||
32 | 32 | ||
33 | -- the generators | 33 | -- the generators |
34 | local g1 = lanes.gen("*", lane1) | 34 | local g1 = lanes.gen("*", { name = 'auto' }, lane1) |
35 | local g2 = lanes.gen("*", lane2) | 35 | local g2 = lanes.gen("*", { name = 'auto' }, lane2) |
36 | local g3 = lanes.gen("*", lane3) | 36 | local g3 = lanes.gen("*", { name = 'auto' }, lane3) |
37 | 37 | ||
38 | -- launch lanes | 38 | -- launch lanes |
39 | local h1 = g1() | 39 | local h1 = g1() |
diff --git a/unit_tests/scripts/lane/stdlib_naming.lua b/unit_tests/scripts/lane/stdlib_naming.lua index 2e045c3..4884cca 100644 --- a/unit_tests/scripts/lane/stdlib_naming.lua +++ b/unit_tests/scripts/lane/stdlib_naming.lua | |||
@@ -63,7 +63,7 @@ local function coro_f(_x) | |||
63 | return true | 63 | return true |
64 | end | 64 | end |
65 | 65 | ||
66 | assert.fails(function() lanes_gen("xxx", {gc_cb = gc_cb}, io_os_f) end) | 66 | assert.fails(function() lanes_gen("xxx", { name = 'auto', gc_cb = gc_cb }, io_os_f) end) |
67 | 67 | ||
68 | local stdlib_naming_tests = | 68 | local stdlib_naming_tests = |
69 | { | 69 | { |
diff --git a/unit_tests/scripts/lane/tasking_basic.lua b/unit_tests/scripts/lane/tasking_basic.lua index 99be321..233accf 100644 --- a/unit_tests/scripts/lane/tasking_basic.lua +++ b/unit_tests/scripts/lane/tasking_basic.lua | |||
@@ -39,7 +39,7 @@ end | |||
39 | 39 | ||
40 | PRINT("\n\n", "---=== Tasking (basic) ===---", "\n\n") | 40 | PRINT("\n\n", "---=== Tasking (basic) ===---", "\n\n") |
41 | 41 | ||
42 | local task_launch = lanes_gen("", { globals={hey=true}, gc_cb = gc_cb}, task) | 42 | local task_launch = lanes_gen("", { name = 'auto', globals={hey=true}, gc_cb = gc_cb }, task) |
43 | -- base stdlibs, normal priority | 43 | -- base stdlibs, normal priority |
44 | 44 | ||
45 | -- 'task_launch' is a factory of multithreaded tasks, we can launch several: | 45 | -- 'task_launch' is a factory of multithreaded tasks, we can launch several: |
diff --git a/unit_tests/scripts/lane/tasking_cancelling.lua b/unit_tests/scripts/lane/tasking_cancelling.lua index a4e0fde..85600ab 100644 --- a/unit_tests/scripts/lane/tasking_cancelling.lua +++ b/unit_tests/scripts/lane/tasking_cancelling.lua | |||
@@ -36,7 +36,7 @@ end | |||
36 | 36 | ||
37 | PRINT("\n\n", "---=== Tasking (cancelling) ===---", "\n\n") | 37 | PRINT("\n\n", "---=== Tasking (cancelling) ===---", "\n\n") |
38 | 38 | ||
39 | local task_launch2 = lanes_gen("", { globals={hey=true}, gc_cb = gc_cb}, task) | 39 | local task_launch2 = lanes_gen("", { name = 'auto', globals={hey=true}, gc_cb = gc_cb }, task) |
40 | 40 | ||
41 | local N=999999999 | 41 | local N=999999999 |
42 | local lane9= task_launch2(1,N,1) -- huuuuuuge... | 42 | local lane9= task_launch2(1,N,1) -- huuuuuuge... |
@@ -87,7 +87,7 @@ local wait_send = function() | |||
87 | a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled | 87 | a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled |
88 | end | 88 | end |
89 | 89 | ||
90 | local wait_send_lane = lanes.gen("*", wait_send)() | 90 | local wait_send_lane = lanes_gen("*", { name = 'auto' }, wait_send)() |
91 | repeat until wait_send_lane.status == "waiting" | 91 | repeat until wait_send_lane.status == "waiting" |
92 | print "wait_send_lane is waiting" | 92 | print "wait_send_lane is waiting" |
93 | wait_send_lane:cancel() -- hard cancel, 0 timeout | 93 | wait_send_lane:cancel() -- hard cancel, 0 timeout |
@@ -100,7 +100,7 @@ local wait_receive = function() | |||
100 | k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled | 100 | k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled |
101 | end | 101 | end |
102 | 102 | ||
103 | local wait_receive_lane = lanes.gen("*", wait_receive)() | 103 | local wait_receive_lane = lanes_gen("*", { name = 'auto' }, wait_receive)() |
104 | repeat until wait_receive_lane.status == "waiting" | 104 | repeat until wait_receive_lane.status == "waiting" |
105 | print "wait_receive_lane is waiting" | 105 | print "wait_receive_lane is waiting" |
106 | wait_receive_lane:cancel() -- hard cancel, 0 timeout | 106 | wait_receive_lane:cancel() -- hard cancel, 0 timeout |
@@ -113,7 +113,7 @@ local wait_receive_batched = function() | |||
113 | k, v1, v2 = limited:receive(limited.batched, "dummy", 2) -- infinite timeout, returns only when lane is cancelled | 113 | k, v1, v2 = limited:receive(limited.batched, "dummy", 2) -- infinite timeout, returns only when lane is cancelled |
114 | end | 114 | end |
115 | 115 | ||
116 | local wait_receive_batched_lane = lanes.gen("*", wait_receive_batched)() | 116 | local wait_receive_batched_lane = lanes_gen("*", { name = 'auto' }, wait_receive_batched)() |
117 | repeat until wait_receive_batched_lane.status == "waiting" | 117 | repeat until wait_receive_batched_lane.status == "waiting" |
118 | print "wait_receive_batched_lane is waiting" | 118 | print "wait_receive_batched_lane is waiting" |
119 | wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout | 119 | wait_receive_batched_lane:cancel() -- hard cancel, 0 timeout |
diff --git a/unit_tests/scripts/lane/tasking_comms_criss_cross.lua b/unit_tests/scripts/lane/tasking_comms_criss_cross.lua index db63b8e..497e81d 100644 --- a/unit_tests/scripts/lane/tasking_comms_criss_cross.lua +++ b/unit_tests/scripts/lane/tasking_comms_criss_cross.lua | |||
@@ -27,7 +27,7 @@ PRINT("\n\n", "---=== Comms criss cross ===---", "\n\n") | |||
27 | 27 | ||
28 | -- We make two identical lanes, which are using the same Linda channel. | 28 | -- We make two identical lanes, which are using the same Linda channel. |
29 | -- | 29 | -- |
30 | local tc = lanes_gen("io", {gc_cb = gc_cb}, | 30 | local tc = lanes_gen("io", { name = 'auto', gc_cb = gc_cb }, |
31 | function(linda, ch_in, ch_out) | 31 | function(linda, ch_in, ch_out) |
32 | lane_threadname("criss cross " .. ch_in .. " -> " .. ch_out) | 32 | lane_threadname("criss cross " .. ch_in .. " -> " .. ch_out) |
33 | local function STAGE(str) | 33 | local function STAGE(str) |
diff --git a/unit_tests/scripts/lane/tasking_communications.lua b/unit_tests/scripts/lane/tasking_communications.lua index b922973..1fd43b0 100644 --- a/unit_tests/scripts/lane/tasking_communications.lua +++ b/unit_tests/scripts/lane/tasking_communications.lua | |||
@@ -101,7 +101,7 @@ local function PEEK(...) return linda:get("<-", ...) end | |||
101 | local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end | 101 | local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end |
102 | local function RECEIVE() local k,v = linda:receive(1, "<-") return v end | 102 | local function RECEIVE() local k,v = linda:receive(1, "<-") return v end |
103 | 103 | ||
104 | local comms_lane = lanes_gen("io", {gc_cb = gc_cb, name = "auto"}, chunk)(linda) -- prepare & launch | 104 | local comms_lane = lanes_gen("io", { name = 'auto', gc_cb = gc_cb }, chunk)(linda) -- prepare & launch |
105 | 105 | ||
106 | SEND(1); WR("main ", "1 sent\n") | 106 | SEND(1); WR("main ", "1 sent\n") |
107 | SEND(2); WR("main ", "2 sent\n") | 107 | SEND(2); WR("main ", "2 sent\n") |
diff --git a/unit_tests/scripts/lane/tasking_error.lua b/unit_tests/scripts/lane/tasking_error.lua index 1e2347f..26f244b 100644 --- a/unit_tests/scripts/lane/tasking_error.lua +++ b/unit_tests/scripts/lane/tasking_error.lua | |||
@@ -22,7 +22,7 @@ end | |||
22 | PRINT("---=== Tasking (error) ===---", "\n\n") | 22 | PRINT("---=== Tasking (error) ===---", "\n\n") |
23 | 23 | ||
24 | -- a lane that throws immediately the error value it received | 24 | -- a lane that throws immediately the error value it received |
25 | local g = lanes_gen("", {gc_cb = gc_cb}, error) | 25 | local g = lanes_gen("", { name = 'auto', gc_cb = gc_cb }, error) |
26 | local errmsg = "ERROR!" | 26 | local errmsg = "ERROR!" |
27 | 27 | ||
28 | if true then | 28 | if true then |
diff --git a/unit_tests/scripts/lane/tasking_join_test.lua b/unit_tests/scripts/lane/tasking_join_test.lua index 8f2d4db..2fbce6c 100644 --- a/unit_tests/scripts/lane/tasking_join_test.lua +++ b/unit_tests/scripts/lane/tasking_join_test.lua | |||
@@ -34,7 +34,7 @@ PRINT("---=== :join test ===---", "\n\n") | |||
34 | -- (unless [1..n] has been read earlier, in which case it would seemingly | 34 | -- (unless [1..n] has been read earlier, in which case it would seemingly |
35 | -- work). | 35 | -- work). |
36 | 36 | ||
37 | local S= lanes_gen("table", {gc_cb = gc_cb}, | 37 | local S= lanes_gen("table", { name = 'auto', gc_cb = gc_cb }, |
38 | function(arg) | 38 | function(arg) |
39 | lane_threadname "join test lane" | 39 | lane_threadname "join test lane" |
40 | set_finalizer(function() end) | 40 | set_finalizer(function() end) |
diff --git a/unit_tests/scripts/lane/tasking_send_receive_code.lua b/unit_tests/scripts/lane/tasking_send_receive_code.lua index 77a4b12..e329a88 100644 --- a/unit_tests/scripts/lane/tasking_send_receive_code.lua +++ b/unit_tests/scripts/lane/tasking_send_receive_code.lua | |||
@@ -66,7 +66,7 @@ local function chunk2(linda) | |||
66 | end | 66 | end |
67 | 67 | ||
68 | local linda = lanes_linda("auto") | 68 | local linda = lanes_linda("auto") |
69 | local t2= lanes_gen("debug,package,string,io", {gc_cb = gc_cb}, chunk2)(linda) -- prepare & launch | 69 | local t2= lanes_gen("debug,package,string,io", { name = 'auto', gc_cb = gc_cb }, chunk2)(linda) -- prepare & launch |
70 | linda:send("down", function(linda) linda:send("up", "ready!") end, | 70 | linda:send("down", function(linda) linda:send("up", "ready!") end, |
71 | "ok") | 71 | "ok") |
72 | -- wait to see if the tiny function gets executed | 72 | -- wait to see if the tiny function gets executed |
diff --git a/unit_tests/scripts/lane/uncooperative_shutdown.lua b/unit_tests/scripts/lane/uncooperative_shutdown.lua index 56c936b..51e5762 100644 --- a/unit_tests/scripts/lane/uncooperative_shutdown.lua +++ b/unit_tests/scripts/lane/uncooperative_shutdown.lua | |||
@@ -12,7 +12,7 @@ local lane = function() | |||
12 | end | 12 | end |
13 | 13 | ||
14 | -- the generator | 14 | -- the generator |
15 | local g1 = lanes.gen("*", {name = "auto"}, lane) | 15 | local g1 = lanes.gen("*", { name = 'auto' }, lane) |
16 | 16 | ||
17 | -- launch lane | 17 | -- launch lane |
18 | local h1 = g1() | 18 | local h1 = g1() |