lsyncd/tests/churn-direct.lua

56 lines
1.2 KiB
Lua
Raw Normal View History

2011-02-08 14:14:07 +00:00
-- a heavy duty test.
-- makes thousends of random changes to the source tree
require( 'posix' )
2016-12-21 13:21:32 +00:00
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
2016-12-21 13:21:32 +00:00
churn( srcdir, 10, init )
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,
2018-03-09 10:07:53 +00:00
table.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
2016-12-21 13:21:32 +00:00
churn( srcdir, 500, false )
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