summaryrefslogtreecommitdiff
path: root/tests/modules/process/test.lua
blob: 69fe0b6769daa21cc95d6716ed3f15252af6de24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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