summaryrefslogtreecommitdiff
path: root/tests/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-05 00:34:53 +0800
committerruki <[email protected]>2020-02-07 22:45:56 +0800
commit94d3eb649e489a597a2f5d966d2249a9e64d87e3 (patch)
treec5bb5c3286c64a5ca491b2aacc0c09a4c9cc84ba /tests/modules
parenta615d353a701e0d23e322060e5dd8e364d38dfee (diff)
impl private.async.runjobs
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/scheduler/runjobs.lua8
-rw-r--r--tests/modules/scheduler/test.lua15
2 files changed, 21 insertions, 2 deletions
diff --git a/tests/modules/scheduler/runjobs.lua b/tests/modules/scheduler/runjobs.lua
index 505573190..36f72b47f 100644
--- a/tests/modules/scheduler/runjobs.lua
+++ b/tests/modules/scheduler/runjobs.lua
@@ -1,9 +1,15 @@
+import("core.base.scheduler")
import("private.async.runjobs")
function _jobfunc(index)
+ print("%s: run job (%d)", scheduler.co_running(), index)
+ local dt = os.mclock()
+ os.sleep(1000)
+ dt = os.mclock() - dt
+ print("%s: run job (%d) end, dt: %d ms", scheduler.co_running(), index, dt)
end
function main()
- runjobs(_jobfunc, 100, 4)
+ runjobs("test", _jobfunc, 100, 6)
end
diff --git a/tests/modules/scheduler/test.lua b/tests/modules/scheduler/test.lua
index de62e47ed..853957567 100644
--- a/tests/modules/scheduler/test.lua
+++ b/tests/modules/scheduler/test.lua
@@ -1,6 +1,6 @@
import("core.base.scheduler")
-function test_runjobs(t)
+function test_group(t)
local count = 0
local task = function (a)
@@ -46,3 +46,16 @@ function test_yield(t)
scheduler.co_group_wait("test")
t:are_equal(count, 10)
end
+
+function test_runjobs(t)
+ import("private.async.runjobs")
+
+ local total = 100
+ local comax = 6
+ local count = 0
+ runjobs("test", function (index)
+ t:require(index >= 1 and index <= total)
+ count = count + 1
+ end, total, comax)
+ t:are_equal(count, total)
+end