2011-02-08 14:14:07 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
-- a heavy duty test.
|
|
|
|
-- makes thousends of random changes to the source tree
|
|
|
|
|
2012-01-31 14:01:11 +00:00
|
|
|
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()
|
|
|
|
|
2012-02-15 23:28:03 +00:00
|
|
|
-- makes some startup data
|
2011-02-08 14:14:07 +00:00
|
|
|
churn(srcdir, 10)
|
|
|
|
|
2012-02-16 15:05:33 +00:00
|
|
|
local logs = {'-log', 'Exec', '-log', 'Delay' }
|
2012-01-31 14:01:11 +00:00
|
|
|
local pid = spawn(
|
|
|
|
'./lsyncd',
|
2012-02-15 23:28:03 +00:00
|
|
|
'-nodaemon',
|
2012-01-31 14:01:11 +00:00
|
|
|
'-direct', srcdir, trgdir,
|
|
|
|
unpack(logs)
|
|
|
|
)
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2012-01-31 14:01:11 +00:00
|
|
|
cwriteln('waiting for Lsyncd to startup')
|
2011-02-08 14:14:07 +00:00
|
|
|
posix.sleep(1)
|
|
|
|
|
|
|
|
churn(srcdir, 500)
|
|
|
|
|
2012-01-31 14:01:11 +00:00
|
|
|
cwriteln('waiting for Lsyncd to finish its jobs.')
|
2011-02-08 14:14:07 +00:00
|
|
|
posix.sleep(10)
|
|
|
|
|
2012-01-31 14:01:11 +00:00
|
|
|
cwriteln('killing the Lsyncd daemon')
|
2011-02-08 14:14:07 +00:00
|
|
|
posix.kill(pid)
|
|
|
|
local _, exitmsg, lexitcode = posix.wait(lpid)
|
2012-01-31 14:01:11 +00:00
|
|
|
cwriteln('Exitcode of Lsyncd = ',exitmsg,' ',lexitcode)
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2012-01-31 14:01:11 +00:00
|
|
|
exitcode = os.execute('diff -r '..srcdir..' '..trgdir)
|
|
|
|
cwriteln('Exitcode of diff = "', exitcode, '"')
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2012-01-31 14:01:11 +00:00
|
|
|
if exitcode ~= 0 then os.exit(1) else os.exit(0) end
|
2011-02-08 14:14:07 +00:00
|
|
|
|