lsyncd/tests/churn-direct.lua

56 lines
1.2 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( )
2011-02-08 14:14:07 +00:00
-- makes some startup data
churn( srcdir, 10 )
2011-02-08 14:14:07 +00:00
2012-10-07 18:48:09 +00:00
local logs = { }
--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' )
posix.sleep( 1 )
2011-02-08 14:14:07 +00:00
churn( srcdir, 500 )
2011-02-08 14:14:07 +00:00
cwriteln( 'waiting for Lsyncd to finish its jobs.' )
posix.sleep( 10 )
2011-02-08 14:14:07 +00:00
cwriteln( 'killing the Lsyncd daemon' )
posix.kill( pid )
2011-02-08 14:14:07 +00:00
local _, exitmsg, lexitcode = posix.wait( lpid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
2011-02-08 14:14:07 +00:00
_, result, code = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
if result == 'exit'
then
cwriteln( 'Exitcode of diff = ', code )
else
cwriteln( 'Signal terminating diff = ', code )
end
if code ~= 0
then
os.exit( 1 )
else
os.exit( 0 )
end
2011-02-08 14:14:07 +00:00