2011-02-08 14:14:07 +00:00
|
|
|
-- a heavy duty test.
|
|
|
|
-- makes thousends of random changes to the source tree
|
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
require( 'posix' )
|
2016-12-21 13:21:32 +00:00
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
dofile( 'tests/testlib.lua' )
|
2012-01-31 14:01:11 +00:00
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
cwriteln( '****************************************************************' )
|
|
|
|
cwriteln( ' Testing default.direct with random data activity ' )
|
|
|
|
cwriteln( '****************************************************************' )
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
local tdir, srcdir, trgdir = mktemps( )
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2012-02-15 23:28:03 +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' }
|
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,
|
2018-03-09 10:07:53 +00:00
|
|
|
table.unpack( logs )
|
2012-01-31 14:01:11 +00:00
|
|
|
)
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2015-10-14 12:23:37 +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
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
cwriteln( 'waiting for Lsyncd to finish its jobs.' )
|
|
|
|
posix.sleep( 10 )
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
cwriteln( 'killing the Lsyncd daemon' )
|
|
|
|
posix.kill( pid )
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
local _, exitmsg, lexitcode = posix.wait( lpid )
|
|
|
|
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
2011-02-08 14:14:07 +00:00
|
|
|
|
2015-10-14 12:23:37 +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
|
|
|
|