lsyncd/tests/churn-direct.lua

43 lines
1.1 KiB
Lua
Raw Normal View History

2011-02-08 14:14:07 +00:00
#!/usr/bin/lua
-- a heavy duty test.
-- makes thousends of random changes to the source tree
require("posix")
dofile("tests/testlib.lua")
cwriteln("****************************************************************")
cwriteln(" Testing default.direct with random data activity ")
cwriteln("****************************************************************")
local tdir, srcdir, trgdir = mktemps()
-- makes some startup data
churn(srcdir, 10)
2011-02-25 14:39:08 +00:00
local logs = {"-log", "Exec"}
2011-02-08 14:14:07 +00:00
--logs = {"-log", "Delay", "-log", "Fsevents" }
2011-02-08 16:38:55 +00:00
local pid = spawn("./lsyncd", "-nodaemon",
2011-02-08 14:14:07 +00:00
"-direct", srcdir, trgdir, unpack(logs))
cwriteln("waiting for Lsyncd to startup")
posix.sleep(1)
churn(srcdir, 500)
cwriteln("waiting for Lsyncd to finish its jobs.")
posix.sleep(10)
cwriteln("killing the Lsyncd daemon")
posix.kill(pid)
local _, exitmsg, lexitcode = posix.wait(lpid)
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode)
exitcode = os.execute("diff -r "..srcdir.." "..trgdir)
cwriteln("Exitcode of diff = '", exitcode, "'")
if exitcode ~= 0 then
os.exit(1)
else
os.exit(0)
end