diff options
| author | ruki <[email protected]> | 2020-01-31 23:47:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-01-31 16:45:13 +0800 |
| commit | 01af47d386620ef4f4401505d85a3f36fe8243c6 (patch) | |
| tree | 18ab8862d9f19d6d85cc7dc8d4635d3b0c45d651 /tests/modules/pipe/echo_server.lua | |
| parent | b1d0a3540bac162914f3fd77d2fc82b344125036 (diff) | |
add pipe.connect and named pipe tests
Diffstat (limited to 'tests/modules/pipe/echo_server.lua')
| -rw-r--r-- | tests/modules/pipe/echo_server.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/modules/pipe/echo_server.lua b/tests/modules/pipe/echo_server.lua new file mode 100644 index 000000000..15f15291b --- /dev/null +++ b/tests/modules/pipe/echo_server.lua @@ -0,0 +1,23 @@ +import("core.base.pipe") + +function main(name) + + local pipefile = pipe.open(name or "test", 'r') + if pipefile:connect() > 0 then + print("%s: connected", pipefile) + local count = 0 + local result = nil + while count < 10000 do + local read, data = pipefile:read(13, {block = true}) + if read > 0 then + result = data + count = count + 1 + else + break + end + end + print("%s: read: %d, count: %d", pipefile, result and result:size() or 0, count) + result:dump() + end + pipefile:close() +end |
