From 512f4c0b46ea5cc359e673b7379cd81925863121 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 14 Mar 2025 14:53:09 +0100 Subject: Give a name to all lanes in the tests --- unit_tests/embedded_tests.cpp | 2 +- unit_tests/init_and_shutdown.cpp | 1 + unit_tests/lane_tests.cpp | 2 +- unit_tests/scripts/coro/basics.lua | 2 +- unit_tests/scripts/lane/cooperative_shutdown.lua | 6 +++--- unit_tests/scripts/lane/stdlib_naming.lua | 2 +- unit_tests/scripts/lane/tasking_basic.lua | 2 +- unit_tests/scripts/lane/tasking_cancelling.lua | 8 ++++---- unit_tests/scripts/lane/tasking_comms_criss_cross.lua | 2 +- unit_tests/scripts/lane/tasking_communications.lua | 2 +- unit_tests/scripts/lane/tasking_error.lua | 2 +- unit_tests/scripts/lane/tasking_join_test.lua | 2 +- unit_tests/scripts/lane/tasking_send_receive_code.lua | 2 +- unit_tests/scripts/lane/uncooperative_shutdown.lua | 2 +- 14 files changed, 19 insertions(+), 18 deletions(-) (limited to 'unit_tests') 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") // lua_setfield(L, -2, "allocator"); // configure {on_state_create = on_state_create_, allocater = "protected"} lua_pcall(L, 1, 0, 0); sprintf_s(script, - "g = lanes.gen('*', {globals = {ID = %d}}, function(id_) lane_threadname('Lane %d.'..id_) logPrint('This is L%d.'..id_) end)" // lane generator + "g = lanes.gen('*', { name = 'auto', globals = {ID = %d} }, function(id_) lane_threadname('Lane %d.'..id_) logPrint('This is L%d.'..id_) end)" // lane generator "for i = 1,%d do _G['a'..i] = g(i) end" // launch a few lanes, handle stored in global a , 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") // launch a Lane that requires the module. It should succeed because _on_state_create was called and made it possible std::string_view const _script{ " f = lanes.gen('*'," + " { name = 'auto' }," " function()" " local Stuff = require ('Stuff')" " 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") " local l = lanes.linda()" " lanes.timer(l, 'gluh', 0.1, 0.1)" // launch a lane that is supposed to sleep forever - " local g = lanes.gen('*', lanes.sleep)" + " local g = lanes.gen('*', { name = 'auto' }, lanes.sleep)" " local h = g('indefinitely')" // sleep 1 second (this uses the timer linda) " 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 if true then -- if we start a non-coroutine lane with a yielding function, we should get an error, right? - local fun_g = lanes.gen("*", {name = "auto"}, yielder) + local fun_g = lanes.gen("*", { name = 'auto' }, yielder) local h = fun_g("hello", "world", "!") local err, status, stack = h:join() 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 -- the generators -local g1 = lanes.gen("*", lane1) -local g2 = lanes.gen("*", lane2) -local g3 = lanes.gen("*", lane3) +local g1 = lanes.gen("*", { name = 'auto' }, lane1) +local g2 = lanes.gen("*", { name = 'auto' }, lane2) +local g3 = lanes.gen("*", { name = 'auto' }, lane3) -- launch lanes 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) return true end -assert.fails(function() lanes_gen("xxx", {gc_cb = gc_cb}, io_os_f) end) +assert.fails(function() lanes_gen("xxx", { name = 'auto', gc_cb = gc_cb }, io_os_f) end) local stdlib_naming_tests = { 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 PRINT("\n\n", "---=== Tasking (basic) ===---", "\n\n") -local task_launch = lanes_gen("", { globals={hey=true}, gc_cb = gc_cb}, task) +local task_launch = lanes_gen("", { name = 'auto', globals={hey=true}, gc_cb = gc_cb }, task) -- base stdlibs, normal priority -- '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 PRINT("\n\n", "---=== Tasking (cancelling) ===---", "\n\n") -local task_launch2 = lanes_gen("", { globals={hey=true}, gc_cb = gc_cb}, task) +local task_launch2 = lanes_gen("", { name = 'auto', globals={hey=true}, gc_cb = gc_cb }, task) local N=999999999 local lane9= task_launch2(1,N,1) -- huuuuuuge... @@ -87,7 +87,7 @@ local wait_send = function() a,b = limited:send("key", "bybye") -- infinite timeout, returns only when lane is cancelled end -local wait_send_lane = lanes.gen("*", wait_send)() +local wait_send_lane = lanes_gen("*", { name = 'auto' }, wait_send)() repeat until wait_send_lane.status == "waiting" print "wait_send_lane is waiting" wait_send_lane:cancel() -- hard cancel, 0 timeout @@ -100,7 +100,7 @@ local wait_receive = function() k, v = limited:receive("dummy") -- infinite timeout, returns only when lane is cancelled end -local wait_receive_lane = lanes.gen("*", wait_receive)() +local wait_receive_lane = lanes_gen("*", { name = 'auto' }, wait_receive)() repeat until wait_receive_lane.status == "waiting" print "wait_receive_lane is waiting" wait_receive_lane:cancel() -- hard cancel, 0 timeout @@ -113,7 +113,7 @@ local wait_receive_batched = function() k, v1, v2 = limited:receive(limited.batched, "dummy", 2) -- infinite timeout, returns only when lane is cancelled end -local wait_receive_batched_lane = lanes.gen("*", wait_receive_batched)() +local wait_receive_batched_lane = lanes_gen("*", { name = 'auto' }, wait_receive_batched)() repeat until wait_receive_batched_lane.status == "waiting" print "wait_receive_batched_lane is waiting" 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") -- We make two identical lanes, which are using the same Linda channel. -- -local tc = lanes_gen("io", {gc_cb = gc_cb}, +local tc = lanes_gen("io", { name = 'auto', gc_cb = gc_cb }, function(linda, ch_in, ch_out) lane_threadname("criss cross " .. ch_in .. " -> " .. ch_out) 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 local function SEND(...) local _res, _err = linda:send("->", ...) assert(_res == true and _err == nil) end local function RECEIVE() local k,v = linda:receive(1, "<-") return v end -local comms_lane = lanes_gen("io", {gc_cb = gc_cb, name = "auto"}, chunk)(linda) -- prepare & launch +local comms_lane = lanes_gen("io", { name = 'auto', gc_cb = gc_cb }, chunk)(linda) -- prepare & launch SEND(1); WR("main ", "1 sent\n") 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 PRINT("---=== Tasking (error) ===---", "\n\n") -- a lane that throws immediately the error value it received -local g = lanes_gen("", {gc_cb = gc_cb}, error) +local g = lanes_gen("", { name = 'auto', gc_cb = gc_cb }, error) local errmsg = "ERROR!" 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") -- (unless [1..n] has been read earlier, in which case it would seemingly -- work). -local S= lanes_gen("table", {gc_cb = gc_cb}, +local S= lanes_gen("table", { name = 'auto', gc_cb = gc_cb }, function(arg) lane_threadname "join test lane" 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) end local linda = lanes_linda("auto") -local t2= lanes_gen("debug,package,string,io", {gc_cb = gc_cb}, chunk2)(linda) -- prepare & launch +local t2= lanes_gen("debug,package,string,io", { name = 'auto', gc_cb = gc_cb }, chunk2)(linda) -- prepare & launch linda:send("down", function(linda) linda:send("up", "ready!") end, "ok") -- 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() end -- the generator -local g1 = lanes.gen("*", {name = "auto"}, lane) +local g1 = lanes.gen("*", { name = 'auto' }, lane) -- launch lane local h1 = g1() -- cgit v1.2.3-55-g6feb