2010-11-18 16:33:48 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
-- a heavy duty test.
|
|
|
|
-- makes thousends of random changes to the source tree
|
|
|
|
-- checks every X changes if lsyncd managed to keep target tree in sync.
|
|
|
|
require("posix")
|
|
|
|
dofile("tests/testlib.lua")
|
|
|
|
|
2010-11-18 16:59:50 +00:00
|
|
|
local tdir = mktempd().."/"
|
2010-11-18 16:33:48 +00:00
|
|
|
cwriteln("using ", tdir, " as test root")
|
|
|
|
|
|
|
|
local srcdir = tdir.."src/"
|
|
|
|
local trgdir = tdir.."trg/"
|
|
|
|
|
|
|
|
posix.mkdir(srcdir)
|
|
|
|
posix.mkdir(trgdir)
|
2010-11-24 19:21:43 +00:00
|
|
|
|
2010-11-24 21:26:41 +00:00
|
|
|
-- makes some startup data
|
|
|
|
churn(srcdir, 10)
|
|
|
|
|
2010-11-24 19:21:43 +00:00
|
|
|
local logs = {}
|
|
|
|
--logs = {"-log", "Inotify", "-log", "Exec" }
|
2010-11-24 20:34:56 +00:00
|
|
|
local pid = spawn("./lsyncd", "-nodaemon",
|
|
|
|
"-rsync", srcdir, trgdir, unpack(logs))
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2010-11-18 16:59:50 +00:00
|
|
|
cwriteln("waiting for Lsyncd to startup")
|
2010-11-18 16:33:48 +00:00
|
|
|
posix.sleep(1)
|
|
|
|
|
2010-11-24 19:45:18 +00:00
|
|
|
churn(srcdir, 100)
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2010-11-18 16:59:50 +00:00
|
|
|
cwriteln("waiting for Lsyncd to finish its jobs.")
|
2010-11-24 10:49:29 +00:00
|
|
|
posix.sleep(20)
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2010-11-20 22:51:53 +00:00
|
|
|
cwriteln("killing the Lsyncd daemon")
|
|
|
|
posix.kill(pid)
|
|
|
|
local _, exitmsg, lexitcode = posix.wait(lpid)
|
|
|
|
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode)
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2010-11-18 16:59:50 +00:00
|
|
|
exitcode = os.execute("diff -r "..srcdir.." "..trgdir)
|
2010-11-22 14:54:50 +00:00
|
|
|
cwriteln("Exitcode of diff = '", exitcode, "'")
|
|
|
|
if exitcode ~= 0 then
|
|
|
|
os.exit(1)
|
2010-11-20 22:51:53 +00:00
|
|
|
else
|
2010-11-22 14:54:50 +00:00
|
|
|
os.exit(0)
|
2010-11-20 22:51:53 +00:00
|
|
|
end
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2010-11-22 14:54:50 +00:00
|
|
|
|