summaryrefslogtreecommitdiff
path: root/tests/modules/process/test.lua
blob: aec56cfc63959369ad17a6aeeb3ac4d46fa041d2 (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
52
53
54
55
56
57
58
59
60
61
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 ok = try
    {
        function ()
            process.wait("awd", inftimeout)
            return true
        end
    }
    assert(ok == nil)

    assert(process.close("awd") == nil)

    ok = try
    {
        function ()
            process.waitlist("awd", inftimeout)
            return true
        end
    }
    assert(ok == nil)

    ok = try
    {
        function ()
            process.waitlist({}, inftimeout)
            return true
        end
    }
    assert(ok == nil)

    ok = try
    {
        function ()
            process.waitlist({"awd"}, inftimeout)
            return true
        end
    }
    assert(ok == nil)

    ok = try
    {
        function ()
            process.open("thismustnotbeaprogramname")
            return true
        end
    }
    assert(ok == nil)
end