summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2013-10-01 12:34:53 +0100
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2013-10-01 12:34:53 +0100
commit1c2f121ab33fe85d89846dd7bb30f786e6db619d (patch)
treefa6fc5515ca2154197289d77e48e6729da945fc5
parentba34b34ebcbeb2062486bee26bc015bda1d02c7c (diff)
downloadluxio-1c2f121ab33fe85d89846dd7bb30f786e6db619d.tar.bz2
Add a test for syslog
-rw-r--r--tests/test-syslog.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test-syslog.lua b/tests/test-syslog.lua
new file mode 100644
index 0000000..c5d2c98
--- /dev/null
+++ b/tests/test-syslog.lua
@@ -0,0 +1,32 @@
+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