working on more tests

This commit is contained in:
Axel Kittenberger 2010-11-18 08:48:14 +00:00
parent 7f9ee536ab
commit e0e7a2a705

48
tests/rand.lua Executable file
View File

@ -0,0 +1,48 @@
#!/usr/bin/lua
-- a heavy duty test.
-- makes thousends of random changes to the source tree
-- checks every X changes if lsyncd managed to keep target tree in sync.
require("posix")
-- always makes the same "random", so failures can be debugged.
math.randomseed(1)
-- escape codes to colorize output on terminal
local c1="\027[47;34m"
local c0="\027[0m"
---
-- writes colorized
--
function cwriteln(...)
io.write(c1)
io.write(...)
io.write(c0, "\n")
end
cwriteln("******************************************************************")
cwriteln("* heavy duty tests duing randoms *")
cwriteln("******************************************************************")
local lpid = posix.fork()
if lpid < 0 then
cwriteln("ERROR: failed fork!")
os.exit(-1);
end
if lpid == 0 then
posix.exec("./lsyncd", "-nodaemon", "-log", "all", "-rsync", "src", "trg")
-- should not return
cwriteln("ERROR: failed to spawn lysncd!")
os.exit(-1);
end
posix.sleep(1)
-- kills the lsyncd daemon
posix.kill(lpid)
local _, exitmsg, exitcode = posix.wait(lpid)
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", exitcode)
os.exit(lexitcode)