diff options
Diffstat (limited to 'tests/modules')
| -rw-r--r-- | tests/modules/process/test.lua | 5 | ||||
| -rw-r--r-- | tests/modules/scheduler/test.lua | 10 | ||||
| -rw-r--r-- | tests/modules/socket/sched_tcp/echo_client.lua | 5 |
3 files changed, 12 insertions, 8 deletions
diff --git a/tests/modules/process/test.lua b/tests/modules/process/test.lua index 15a1ef946..30a42fd99 100644 --- a/tests/modules/process/test.lua +++ b/tests/modules/process/test.lua @@ -25,9 +25,10 @@ function test_sched_process(t) stderr:close() count = count + 1 end + local cotasks = {} for i = 1, 3 do - scheduler.co_start(_session) + table.insert(cotasks, scheduler.co_start(_session)) end - scheduler.runloop() + scheduler.co_waitexit(cotasks) t:are_equal(count, 3) end diff --git a/tests/modules/scheduler/test.lua b/tests/modules/scheduler/test.lua index 07af3dd80..d6e090c6a 100644 --- a/tests/modules/scheduler/test.lua +++ b/tests/modules/scheduler/test.lua @@ -7,10 +7,11 @@ function test_runjobs(t) t:are_equal(a, "xmake!") count = count + 1 end + local cotasks = {} for i = 1, 100 do - scheduler.co_start(task, "xmake!") + table.insert(cotasks, scheduler.co_start(task, "xmake!")) end - scheduler.runloop() + scheduler.co_waitexit(cotasks) t:are_equal(count, 100) end @@ -36,9 +37,10 @@ function test_yield(t) scheduler.co_yield() count = count + 1 end + local cotasks = {} for i = 1, 10 do - scheduler.co_start(task) + table.insert(cotasks, scheduler.co_start(task)) end - scheduler.runloop() + scheduler.co_waitexit(cotasks) t:are_equal(count, 10) end diff --git a/tests/modules/socket/sched_tcp/echo_client.lua b/tests/modules/socket/sched_tcp/echo_client.lua index 6dfd92439..acc681584 100644 --- a/tests/modules/socket/sched_tcp/echo_client.lua +++ b/tests/modules/socket/sched_tcp/echo_client.lua @@ -50,11 +50,12 @@ function _session(addr, port) end function main(count) + local cotasks = {} count = count and tonumber(count) or 1 for i = 1, count do - scheduler.co_start(_session, "127.0.0.1", 9001) + table.insert(cotasks, scheduler.co_start(_session, "127.0.0.1", 9001)) end - scheduler.runloop() + scheduler.co_waitexit(cotasks) for _, sock in ipairs(socks) do sock:close() end |
