Improve tests.

This commit is contained in:
Nodir Temirkhodjaev 2015-01-16 16:11:59 +05:00
parent 05b1d7852c
commit bf3080fc4f
2 changed files with 15 additions and 2 deletions

View File

@ -5,6 +5,11 @@ local sock = require"sys.sock"
local wipf = require"wipflua"
function get_procpath(id)
local pid = sys.pid(id, true)
return (pid and pid:path()) or ""
end
function print_logs(buf)
local size = buf:seek()
local ptr = buf:getptr()
@ -13,8 +18,14 @@ function print_logs(buf)
while off < size do
local len, ip, pid, path = wipf.log_read(ptr, off)
local ip_str = sock.inet_ntop(ip)
off = off + len
if not path then
path = get_procpath(pid)
end
print(ip_str, pid, path)
off = off + len
end
buf:seek(0)

View File

@ -6,9 +6,11 @@ local wipf = require"wipflua"
local mem, win32 = sys.mem, sys.win32
print"-- Log Write"
print"-- Log Read/Write"
do
local path = "/test"
assert(#path == 5)
local outlen = 12 + #path + 3
local bufsize = outlen + 4
local buf = assert(mem.pointer(bufsize))