blob: e826066b7ce4a4d440d48b031e4b3f50103d1d66 (
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
|
-- See LICENSE file for copyright and license details.
local l = require "luxio"
math.randomseed(os.time())
local f = io.open("/var/log/syslog", "r")
if f == nil then
print "Need to read syslog, are you root?"
os.exit(1)
end
l.openlog("test-syslog", 0, l.LOG_DAEMON)
local randomstrs = {}
for i=1,10 do
randomstrs[i] = tostring(math.random(1, 1000))
end
local randomstr = table.concat(randomstrs)
l.syslog(l.LOG_DAEMON, randomstr)
l.closelog()
local text = f:read("*all")
s, e = string.find(text, randomstr)
if string.sub(text, s, e) == randomstr then
print("TEST PASSES")
else
print("TEST FAILS")
end
|