2010-11-18 16:33:48 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
-- a heavy duty test.
|
|
|
|
-- makes thousends of random changes to the source tree
|
2012-11-23 15:04:43 +00:00
|
|
|
require( 'posix' )
|
|
|
|
dofile( 'tests/testlib.lua' )
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2012-11-23 15:04:43 +00:00
|
|
|
cwriteln( '****************************************************************' )
|
|
|
|
cwriteln( ' Testing default.rsync with random data activity' )
|
|
|
|
cwriteln( '****************************************************************' )
|
2011-01-26 11:05:53 +00:00
|
|
|
|
2012-10-07 18:48:09 +00:00
|
|
|
local tdir, srcdir, trgdir = mktemps( )
|
2010-11-24 19:21:43 +00:00
|
|
|
|
2012-02-17 08:12:01 +00:00
|
|
|
-- makes some startup data
|
2016-12-21 13:21:32 +00:00
|
|
|
churn( srcdir, 100, true )
|
2010-11-24 21:26:41 +00:00
|
|
|
|
2012-10-07 18:48:09 +00:00
|
|
|
local logs = { }
|
|
|
|
-- logs = { "-log", "Delay", "-log", "Fsevents" }
|
|
|
|
local pid = spawn(
|
2012-11-23 15:04:43 +00:00
|
|
|
'./lsyncd',
|
|
|
|
'-nodaemon',
|
|
|
|
'-delay', '5',
|
|
|
|
'-rsync', srcdir, trgdir,
|
2012-10-07 18:48:09 +00:00
|
|
|
unpack( logs )
|
|
|
|
)
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2012-11-23 15:04:43 +00:00
|
|
|
cwriteln( 'waiting for Lsyncd to startup' )
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2012-10-07 18:48:09 +00:00
|
|
|
posix.sleep( 1 )
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2016-12-21 13:21:32 +00:00
|
|
|
churn( srcdir, 500, false )
|
2012-10-07 18:48:09 +00:00
|
|
|
|
2012-11-23 15:04:43 +00:00
|
|
|
cwriteln( 'waiting for Lsyncd to finish its jobs.' )
|
2012-10-07 18:48:09 +00:00
|
|
|
|
|
|
|
posix.sleep( 10 )
|
|
|
|
|
2012-11-23 15:04:43 +00:00
|
|
|
cwriteln( 'killing the Lsyncd daemon' )
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2012-11-23 15:04:43 +00:00
|
|
|
posix.kill( pid )
|
2012-10-07 18:48:09 +00:00
|
|
|
local _, exitmsg, lexitcode = posix.wait( lpid )
|
2012-11-23 15:04:43 +00:00
|
|
|
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
2010-11-18 16:33:48 +00:00
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
_, result, code = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
2012-10-07 18:48:09 +00:00
|
|
|
|
2015-10-14 12:23:37 +00:00
|
|
|
if result == 'exit'
|
|
|
|
then
|
|
|
|
cwriteln( 'Exitcode of diff = ', code )
|
|
|
|
else
|
|
|
|
cwriteln( 'Signal terminating diff = ', code )
|
|
|
|
end
|
|
|
|
|
2017-01-05 10:39:00 +00:00
|
|
|
if code ~= 0
|
2015-10-14 12:23:37 +00:00
|
|
|
then
|
2012-11-23 15:04:43 +00:00
|
|
|
os.exit( 1 )
|
2010-11-20 22:51:53 +00:00
|
|
|
else
|
2012-11-23 15:04:43 +00:00
|
|
|
os.exit( 0 )
|
2010-11-20 22:51:53 +00:00
|
|
|
end
|
2010-11-18 16:33:48 +00:00
|
|
|
|