summaryrefslogtreecommitdiff
path: root/tests/modules/process
diff options
context:
space:
mode:
authorTitanSnow <[email protected]>2017-05-21 11:14:42 +0800
committerTitanSnow <[email protected]>2017-05-21 11:14:42 +0800
commit147e73b642ad93e7d42f1ecfaf780bf89637efbd (patch)
tree01cfb3ac17237589bbc4afe137fc091092731194 /tests/modules/process
parentee650cd4514fd73a9d75093f7ba92740060be641 (diff)
add tests for process
Diffstat (limited to 'tests/modules/process')
-rw-r--r--tests/modules/process/test.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/modules/process/test.lua b/tests/modules/process/test.lua
new file mode 100644
index 000000000..69fe0b676
--- /dev/null
+++ b/tests/modules/process/test.lua
@@ -0,0 +1,51 @@
+function main()
+ -- single process test
+ local inftimeout=999
+ local stdout=os.tmpfile()
+ local stderr=os.tmpfile()
+ for i = 1, 2 do
+ local pro=process.open("echo -n awd",stdout,stderr)
+ process.wait(pro,inftimeout)
+ process.close(pro)
+ assert(io.readfile(stdout)=="awd")
+ end
+ -- hack test
+ local hacked = false
+ try{
+ function ()
+ process.wait("awd",inftimeout)
+ hacked = true
+ end
+ }
+ assert(not hacked)
+ hacked = (process.close("awd") ~= nil)
+ assert(not hacked)
+ try{
+ function ()
+ process.waitlist("awd",inftimeout)
+ hacked = true
+ end
+ }
+ assert(not hacked)
+ try{
+ function ()
+ process.waitlist({},inftimeout)
+ hacked = true
+ end
+ }
+ assert(not hacked)
+ try{
+ function ()
+ process.waitlist({"awd"},inftimeout)
+ hacked = true
+ end
+ }
+ assert(not hacked)
+ try{
+ function ()
+ process.open("thismustnotbeaprogramname")
+ hacked = true
+ end
+ }
+ assert(not hacked)
+end