summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Kendrick (humdrum) <rjek@rjek.com>2013-10-01 12:53:28 +0100
committerRob Kendrick (humdrum) <rjek@rjek.com>2013-10-01 12:53:28 +0100
commit3f5ac6036aab342dcfe3719d8c6740b01179a94d (patch)
treefa6fc5515ca2154197289d77e48e6729da945fc5
parentfe662d784a3b8d72c161b886cad4619744034396 (diff)
parent1c2f121ab33fe85d89846dd7bb30f786e6db619d (diff)
downloadluxio-6.tar.bz2
Test for syslog from Richardluxio-6
-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