adapting test scripts

This commit is contained in:
Axel Kittenberger 2012-10-07 20:48:09 +02:00
parent 1217fef9ba
commit 998f9ab3d0
6 changed files with 71 additions and 51 deletions

View File

@ -14,7 +14,8 @@ local tdir, srcdir, trgdir = mktemps()
-- makes some startup data
churn(srcdir, 10)
local logs = {'-log', 'Exec', '-log', 'Delay' }
local logs = { }
--local logs = {'-log', 'Exec', '-log', 'Delay' }
local pid = spawn(
'./lsyncd',
'-nodaemon',

View File

@ -1,42 +1,50 @@
#!/usr/bin/lua
-- a heavy duty test.
-- makes thousends of random changes to the source tree
require("posix")
dofile("tests/testlib.lua")
require( "posix" )
dofile( "tests/testlib.lua" )
cwriteln("****************************************************************")
cwriteln(" Testing default.rsync with random data activity")
cwriteln("****************************************************************")
cwriteln( "****************************************************************" )
cwriteln( " Testing default.rsync with random data activity" )
cwriteln( "****************************************************************" )
local tdir, srcdir, trgdir = mktemps()
local tdir, srcdir, trgdir = mktemps( )
-- makes some startup data
churn(srcdir, 100)
churn( srcdir, 100 )
local logs = {}
-- logs = {"-log", "Delay", "-log", "Fsevents" }
local pid = spawn("./lsyncd", "-nodaemon", "-delay", "5",
"-rsync", srcdir, trgdir, unpack(logs))
local logs = { }
-- logs = { "-log", "Delay", "-log", "Fsevents" }
local pid = spawn(
"./lsyncd",
"-nodaemon",
"-delay", "5",
"-rsync", srcdir, trgdir,
unpack( logs )
)
cwriteln("waiting for Lsyncd to startup")
posix.sleep(1)
cwriteln( "waiting for Lsyncd to startup" )
churn(srcdir, 500)
posix.sleep( 1 )
cwriteln("waiting for Lsyncd to finish its jobs.")
posix.sleep(10)
churn( srcdir, 500 )
cwriteln( "waiting for Lsyncd to finish its jobs." )
posix.sleep( 10 )
cwriteln( "killing the Lsyncd daemon" )
cwriteln("killing the Lsyncd daemon")
posix.kill(pid)
local _, exitmsg, lexitcode = posix.wait(lpid)
local _, exitmsg, lexitcode = posix.wait( lpid )
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode)
exitcode = os.execute("diff -r "..srcdir.." "..trgdir)
cwriteln("Exitcode of diff = '", exitcode, "'")
exitcode = os.execute( "diff -r "..srcdir.." "..trgdir )
cwriteln( "Exitcode of diff = '", exitcode, "'" )
if exitcode ~= 0 then
os.exit(1)
else
os.exit(0)
end

View File

@ -37,6 +37,7 @@ cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode)
exitcode = os.execute("diff -r "..srcdir.." "..trgdir)
cwriteln("Exitcode of diff = '", exitcode, "'")
if exitcode ~= 0 then
os.exit(1)
else

View File

@ -79,11 +79,13 @@ posix.sleep(3)
cwriteln("testing excludes after startup");
testfiles();
cwriteln("ok, removing sources");
if srcdir:sub(1,4) ~= "/tmp" then
-- just to make sure before rm -rf
cwriteln("exist before drama, srcdir is '", srcdir, "'");
os.exit(1);
end
os.execute("rm -rf "..srcdir.."/*");
cwriteln("waiting for Lsyncd to remove destination");
posix.sleep(5);
@ -92,20 +94,22 @@ if os.execute("diff -urN "..srcdir.." "..trgdir) ~= 0 then
os.exit(1);
end
cwriteln("writing files after startup");
writefiles();
cwriteln("waiting for Lsyncd to transmit changes");
posix.sleep(5);
testfiles();
cwriteln( "writing files after startup" );
writefiles( );
cwriteln( "waiting for Lsyncd to transmit changes" );
posix.sleep( 5 );
testfiles( );
cwriteln("killing started Lsyncd");
posix.kill(pid);
local _, exitmsg, lexitcode = posix.wait(lpid);
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode);
posix.sleep(1);
if lexitcode == 0 then
cwriteln("OK");
cwriteln( "killing started Lsyncd" );
posix.kill( pid );
local _, exitmsg, lexitcode = posix.wait( lpid );
cwriteln( "Exitcode of Lsyncd = ", exitmsg, " ", lexitcode );
if lexitcode == 143 then
cwriteln( "OK" );
os.exit( 0 );
else
os.exit( 1 );
end
os.exit(lexitcode);
-- TODO remove temp

View File

@ -108,9 +108,12 @@ posix.kill(pid);
local _, exitmsg, lexitcode = posix.wait(lpid);
cwriteln('Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode);
posix.sleep(1);
if lexitcode == 0 then
cwriteln('OK');
if lexitcode == 143 then
cwriteln( 'OK' );
os.exit( 0 );
else
os.exit( 1 );
end
os.exit(lexitcode);
-- TODO remove temp

View File

@ -50,27 +50,30 @@ sync {ccircuit, source ="]]..srcdir..[[", target = "]]..trgdir..[["}
local function testfile(filename)
local stat, err = posix.stat(filename)
if not stat then
cwriteln("failure: ",filename," missing");
os.exit(1);
cwriteln("failure: ",filename," missing")
os.exit(1)
end
end
cwriteln("starting Lsyncd");
local pid = spawn("./lsyncd", cfgfile, unpack(logs));
cwriteln("waiting for Lsyncd to do a few cycles");
cwriteln("starting Lsyncd")
local pid = spawn("./lsyncd", cfgfile, unpack(logs))
cwriteln("waiting for Lsyncd to do a few cycles")
posix.sleep(30)
cwriteln("look if every circle got a chance to run");
cwriteln("look if every circle got a chance to run")
testfile(srcdir.."a")
testfile(srcdir.."b")
testfile(srcdir.."c")
cwriteln("killing started Lsyncd");
posix.kill(pid);
local _, exitmsg, lexitcode = posix.wait(lpid);
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode);
cwriteln("killing started Lsyncd")
posix.kill(pid)
local _, exitmsg, lexitcode = posix.wait(lpid)
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode)
posix.sleep(1);
if lexitcode == 0 then
cwriteln("OK");
if lexitcode == 143 then
cwriteln("OK")
os.exit( 0 )
else
os.exit( 1 )
end
os.exit(lexitcode);
-- TODO remove temp