mirror of
https://github.com/tnodir/fort
synced 2024-11-15 03:26:01 +00:00
Improve tests.
This commit is contained in:
parent
05b1d7852c
commit
bf3080fc4f
@ -5,6 +5,11 @@ local sock = require"sys.sock"
|
|||||||
local wipf = require"wipflua"
|
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)
|
function print_logs(buf)
|
||||||
local size = buf:seek()
|
local size = buf:seek()
|
||||||
local ptr = buf:getptr()
|
local ptr = buf:getptr()
|
||||||
@ -13,8 +18,14 @@ function print_logs(buf)
|
|||||||
while off < size do
|
while off < size do
|
||||||
local len, ip, pid, path = wipf.log_read(ptr, off)
|
local len, ip, pid, path = wipf.log_read(ptr, off)
|
||||||
local ip_str = sock.inet_ntop(ip)
|
local ip_str = sock.inet_ntop(ip)
|
||||||
off = off + len
|
|
||||||
|
if not path then
|
||||||
|
path = get_procpath(pid)
|
||||||
|
end
|
||||||
|
|
||||||
print(ip_str, pid, path)
|
print(ip_str, pid, path)
|
||||||
|
|
||||||
|
off = off + len
|
||||||
end
|
end
|
||||||
|
|
||||||
buf:seek(0)
|
buf:seek(0)
|
||||||
|
@ -6,9 +6,11 @@ local wipf = require"wipflua"
|
|||||||
local mem, win32 = sys.mem, sys.win32
|
local mem, win32 = sys.mem, sys.win32
|
||||||
|
|
||||||
|
|
||||||
print"-- Log Write"
|
print"-- Log Read/Write"
|
||||||
do
|
do
|
||||||
local path = "/test"
|
local path = "/test"
|
||||||
|
assert(#path == 5)
|
||||||
|
|
||||||
local outlen = 12 + #path + 3
|
local outlen = 12 + #path + 3
|
||||||
local bufsize = outlen + 4
|
local bufsize = outlen + 4
|
||||||
local buf = assert(mem.pointer(bufsize))
|
local buf = assert(mem.pointer(bufsize))
|
||||||
|
Loading…
Reference in New Issue
Block a user