summaryrefslogtreecommitdiff
path: root/tests/modules/process
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-04 00:40:11 +0800
committerruki <[email protected]>2020-02-07 22:45:56 +0800
commit53e371a2b77b91f85275293f451f51b755e3a479 (patch)
tree8455c8a8ae23adb0fb7096ac035627989d3c0e62 /tests/modules/process
parent459ac3d64ed2b78a8b0ba058ca161a38d576dadc (diff)
improve process tests
Diffstat (limited to 'tests/modules/process')
-rw-r--r--tests/modules/process/test.lua41
1 files changed, 22 insertions, 19 deletions
diff --git a/tests/modules/process/test.lua b/tests/modules/process/test.lua
index 8e9e45bd8..15a1ef946 100644
--- a/tests/modules/process/test.lua
+++ b/tests/modules/process/test.lua
@@ -1,30 +1,33 @@
+import("core.base.scheduler")
local inftimeout = 5000
function test_single_process(t)
- -- single process test
local stdout = os.tmpfile()
local stderr = os.tmpfile()
- for i = 1, 2 do
- local proc = process.open("echo -n awd", {stdout = stdout, stderr = stderr})
- proc:wait(inftimeout)
- proc:close()
- t:are_equal(io.readfile(stdout), "awd")
- end
+ local proc = process.openv("xmake", {"lua", "print", "xmake"}, {stdout = stdout, stderr = stderr})
+ proc:wait(inftimeout)
+ proc:close()
+ t:are_equal(io.readfile(stdout):trim(), "xmake")
end
-function test_hack(t)
-
- t:will_raise(function ()
- process.waitlist("awd", inftimeout)
- end)
-
- t:will_raise(function ()
- process.waitlist({}, inftimeout)
- end)
+function test_sched_process(t)
- t:will_raise(function ()
- process.waitlist({"awd"}, inftimeout)
- end)
+ local count = 0
+ local _session = function ()
+ local stdout = io.open(os.tmpfile(), 'w')
+ local stderr = io.open(os.tmpfile(), 'w')
+ local proc = process.openv("xmake", {"lua", "print", "xmake"}, {stdout = stdout, stderr = stderr})
+ local ok, status = proc:wait(inftimeout)
+ proc:close()
+ stdout:close()
+ stderr:close()
+ count = count + 1
+ end
+ for i = 1, 3 do
+ scheduler.co_start(_session)
+ end
+ scheduler.runloop()
+ t:are_equal(count, 3)
end