fixing table.unpack issue in testsuite

This commit is contained in:
Axel Kittenberger 2018-03-09 11:07:53 +01:00
parent c0a31c215d
commit ff0f4fbd7a
10 changed files with 43 additions and 48 deletions

View File

@ -91,13 +91,13 @@ add_custom_target( tests
COMMAND echo "Note you are expected to:" COMMAND echo "Note you are expected to:"
COMMAND echo " * have lua-posix installed" COMMAND echo " * have lua-posix installed"
COMMAND echo " * have a passwordless ssh access to localhost" COMMAND echo " * have a passwordless ssh access to localhost"
COMMAND tests/schedule.lua COMMAND ${LUA_EXECUTABLE} tests/schedule.lua
COMMAND tests/l4rsyncdata.lua COMMAND ${LUA_EXECUTABLE} tests/l4rsyncdata.lua
COMMAND tests/exclude-rsync.lua COMMAND ${LUA_EXECUTABLE} tests/exclude-rsync.lua
COMMAND tests/exclude-rsyncssh.lua COMMAND ${LUA_EXECUTABLE} tests/exclude-rsyncssh.lua
COMMAND tests/churn-rsync.lua COMMAND ${LUA_EXECUTABLE} tests/churn-rsync.lua
COMMAND tests/churn-rsyncssh.lua COMMAND ${LUA_EXECUTABLE} tests/churn-rsyncssh.lua
COMMAND tests/churn-direct.lua COMMAND ${LUA_EXECUTABLE} tests/churn-direct.lua
COMMAND echo "Finished all successfull!" COMMAND echo "Finished all successfull!"
) )

View File

@ -1,14 +1,14 @@
2018-??-??: 2.2.3 2018-??-??: 2.2.3
enhaencement: supporting includes with new filter and filterFrom options enhaencement: supporting includes with new filter and filterFrom options
change: needing at least Lua 5.2 (was 5.1) change: needing now at least Lua 5.2 (Lua 5.1 no longer supported, Lua5.3 supported)
change: if the target/targetdir ands with a ':' do not append change: if the target/targetdir ands with a ':' do not append
a trailing '/' to it, since that would change it from homedir to rootdir! a trailing '/' to it, since that would change it from homedir to rootdir!
add: example for Amazon S3 Bucket (Daniel Miranda) add: example for Amazon S3 Bucket (Daniel Miranda)
fix: setting stdout/stderr to linebuffer mode. fix: setting stdout/stderr to linebuffer mode.
fix: Lua5.3 compatiblity, using load() instead of loadstring() fix: Lua5.3 compatiblity, using load() instead of loadstring()
Lua5.1 support was thus dropped
fix: cmake lua detection, will resort to "lua" and "luac" binaries only if fix: cmake lua detection, will resort to "lua" and "luac" binaries only if
more specific suffixes (e.g. luac5.3) are not available more specific suffixes (e.g. luac5.3) are not available
fix: test suit, Lua5.3 compatibility (table.unpack)
2017-02-16: 2.2.2 2017-02-16: 2.2.2
fix: checkgauge 'insist' fix: checkgauge 'insist'

2
tests/churn-direct.lua Executable file → Normal file
View File

@ -21,7 +21,7 @@ local pid = spawn(
'./lsyncd', './lsyncd',
'-nodaemon', '-nodaemon',
'-direct', srcdir, trgdir, '-direct', srcdir, trgdir,
unpack( logs ) table.unpack( logs )
) )
cwriteln( 'waiting for Lsyncd to startup' ) cwriteln( 'waiting for Lsyncd to startup' )

2
tests/churn-rsync.lua Executable file → Normal file
View File

@ -20,7 +20,7 @@ local pid = spawn(
'-nodaemon', '-nodaemon',
'-delay', '5', '-delay', '5',
'-rsync', srcdir, trgdir, '-rsync', srcdir, trgdir,
unpack( logs ) table.unpack( logs )
) )
cwriteln( 'waiting for Lsyncd to startup' ) cwriteln( 'waiting for Lsyncd to startup' )

2
tests/churn-rsyncssh.lua Executable file → Normal file
View File

@ -29,7 +29,7 @@ local pid = spawn(
srcdir, srcdir,
'localhost', 'localhost',
trgdir, trgdir,
unpack(logs) table.unpack(logs)
) )
cwriteln( 'waiting for Lsyncd to startup' ) cwriteln( 'waiting for Lsyncd to startup' )

0
tests/exclude-rsync.lua Executable file → Normal file
View File

2
tests/exclude-rsyncssh.lua Executable file → Normal file
View File

@ -88,7 +88,7 @@ end
cwriteln( 'testing startup excludes' ) cwriteln( 'testing startup excludes' )
writefiles( ) writefiles( )
cwriteln( 'starting Lsyncd' ) cwriteln( 'starting Lsyncd' )
local pid = spawn( './lsyncd', cfgfile, unpack( log ) ) local pid = spawn( './lsyncd', cfgfile, table.unpack( log ) )
cwriteln( 'waiting for Lsyncd to start' ) cwriteln( 'waiting for Lsyncd to start' )
posix.sleep( 10 ) posix.sleep( 10 )
cwriteln( 'testing excludes after startup' ) cwriteln( 'testing excludes after startup' )

2
tests/l4rsyncdata.lua Executable file → Normal file
View File

@ -28,7 +28,7 @@ local pid =
'-nodaemon', '-nodaemon',
'-delay', '5', '-delay', '5',
"-rsync", srcdir, trgdir, "-rsync", srcdir, trgdir,
unpack( logs ) table.unpack( logs )
) )
cwriteln( 'waiting for lsyncd to start' ) cwriteln( 'waiting for lsyncd to start' )

52
tests/schedule.lua Executable file → Normal file
View File

@ -1,10 +1,10 @@
#!/usr/bin/lua #!/usr/bin/lua
require("posix") require( 'posix' )
dofile("tests/testlib.lua") dofile( 'tests/testlib.lua' )
cwriteln("****************************************************************") cwriteln( '****************************************************************' )
cwriteln(" Testing Lsyncd scheduler ") cwriteln( ' Testing Lsyncd scheduler ' )
cwriteln("****************************************************************") cwriteln( '****************************************************************' )
local tdir, srcdir, trgdir = mktemps() local tdir, srcdir, trgdir = mktemps()
local logfile = tdir .. "log" local logfile = tdir .. "log"
@ -47,30 +47,36 @@ sync {ccircuit, source ="]]..srcdir..[[", target = "]]..trgdir..[["}
-- test if the filename exists, fails if this is different to expect -- test if the filename exists, fails if this is different to expect
local function testfile(filename) local function testfile
(
filename
)
local stat, err = posix.stat(filename) local stat, err = posix.stat(filename)
if not stat then
cwriteln("failure: ",filename," missing") if not stat
os.exit(1) then
cwriteln( 'failure: ', filename, ' missing' )
os.exit( 1 )
end end
end end
cwriteln("starting Lsyncd") cwriteln( 'starting Lsyncd' )
local pid = spawn("./lsyncd", cfgfile, unpack(logs)) local pid = spawn( './lsyncd', cfgfile, table.unpack( logs ) )
cwriteln("waiting for Lsyncd to do a few cycles") cwriteln( 'waiting for Lsyncd to do a few cycles' )
posix.sleep(30) 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..'a' )
testfile(srcdir.."b") testfile( srcdir..'b' )
testfile(srcdir.."c") testfile( srcdir..'c' )
cwriteln("killing started Lsyncd") cwriteln( 'killing started Lsyncd' )
posix.kill(pid) posix.kill( pid )
local _, exitmsg, lexitcode = posix.wait(lpid) local _, exitmsg, lexitcode = posix.wait( lpid )
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode) cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode)
posix.sleep(1); posix.sleep(1);
if lexitcode == 143 then if lexitcode == 143
cwriteln("OK") then
cwriteln( 'OK' )
os.exit( 0 ) os.exit( 0 )
else else
os.exit( 1 ) os.exit( 1 )

View File

@ -58,17 +58,11 @@ end
function mktemps function mktemps
( ) ( )
local tdir = mktempd() .. '/' local tdir = mktempd() .. '/'
cwriteln( 'using ', tdir, ' as test root' ) cwriteln( 'using ', tdir, ' as test root' )
local srcdir = tdir..'src/' local srcdir = tdir..'src/'
local trgdir = tdir..'trg/' local trgdir = tdir..'trg/'
posix.mkdir( srcdir ) posix.mkdir( srcdir )
posix.mkdir( trgdir ) posix.mkdir( trgdir )
return tdir, srcdir, trgdir return tdir, srcdir, trgdir
end end
@ -90,9 +84,7 @@ function writefile
end end
f:write( text ) f:write( text )
f:write( '\n' ) f:write( '\n' )
f:close( ) f:close( )
return true return true
@ -143,11 +135,8 @@ function churn
) )
-- all dirs created, indexed by integer and path -- all dirs created, indexed by integer and path
root = { name = '' } root = { name = '' }
alldirs = { root } alldirs = { root }
dirsWithFileI = { } dirsWithFileI = { }
dirsWithFileD = { } dirsWithFileD = { }
-- --