mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-05-31 15:30:51 +00:00
working on more tests
This commit is contained in:
parent
7f9ee536ab
commit
e0e7a2a705
48
tests/rand.lua
Executable file
48
tests/rand.lua
Executable 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)
|
||||
|
Loading…
Reference in New Issue
Block a user