lsyncd/tests/churn-direct.lua

43 lines
1.0 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('****************************************************************')
2011-02-08 14:14:07 +00:00
local tdir, srcdir, trgdir = mktemps()
-- makes some startup data
2011-02-08 14:14:07 +00:00
churn(srcdir, 10)
local logs = {'-log', 'Exec', '-log', 'Delay' }
local pid = spawn(
'./lsyncd',
'-nodaemon',
'-direct', srcdir, trgdir,
unpack(logs)
)
2011-02-08 14:14:07 +00:00
cwriteln('waiting for Lsyncd to startup')
2011-02-08 14:14:07 +00:00
posix.sleep(1)
churn(srcdir, 500)
cwriteln('waiting for Lsyncd to finish its jobs.')
2011-02-08 14:14:07 +00:00
posix.sleep(10)
cwriteln('killing the Lsyncd daemon')
2011-02-08 14:14:07 +00:00
posix.kill(pid)
local _, exitmsg, lexitcode = posix.wait(lpid)
cwriteln('Exitcode of Lsyncd = ',exitmsg,' ',lexitcode)
2011-02-08 14:14:07 +00:00
exitcode = os.execute('diff -r '..srcdir..' '..trgdir)
cwriteln('Exitcode of diff = "', exitcode, '"')
2011-02-08 14:14:07 +00:00
if exitcode ~= 0 then os.exit(1) else os.exit(0) end
2011-02-08 14:14:07 +00:00