test working, lsyncd fixing

This commit is contained in:
Axel Kittenberger 2010-11-19 19:16:53 +00:00
parent 7359e11459
commit c3b071d759
2 changed files with 37 additions and 26 deletions

View File

@ -1438,7 +1438,7 @@ local Inotifies = (function()
-- lets the core registers watch with the kernel -- lets the core registers watch with the kernel
local wd = lsyncd.inotifyadd(root .. path); local wd = lsyncd.inotifyadd(root .. path);
if wd < 0 then if wd < 0 then
log("Error","Failure adding watch ",dir," -> ignored ") log("Error","Failure adding watch ",root,path," -> ignored ")
return return
end end

View File

@ -16,7 +16,7 @@ local trgdir = tdir.."trg/"
posix.mkdir(srcdir) posix.mkdir(srcdir)
posix.mkdir(trgdir) posix.mkdir(trgdir)
-- local pid = spawn("./lsyncd","-nodaemon","-rsync",srcdir,trgdir) local pid = spawn("./lsyncd","-nodaemon","-rsync",srcdir,trgdir)
cwriteln("waiting for Lsyncd to startup") cwriteln("waiting for Lsyncd to startup")
posix.sleep(1) posix.sleep(1)
@ -119,6 +119,7 @@ end
-- just gives it a pause -- just gives it a pause
-- --
local function sleep() local function sleep()
cwriteln("..zzz..")
posix.sleep(1) posix.sleep(1)
end end
@ -179,19 +180,29 @@ local function mvdir()
return return
end end
-- chooses a random directory to move -- chooses a random directory to move
local odir = pickDir() local odir = pickDir(true)
-- chooses a random directory to move to -- chooses a random directory to move to
local tdir = pickDir(true) local tdir = pickDir()
if tdir[odir.name] == nil then
-- origin name not in target dir already -- makes sure tdir is not a subdir of odir
local on = dirname(odir) local dd = tdir
local tn = dirname(tdir) while dd do
cwriteln("mvdir ",srcdir,on," -> ",srcdir,tn,odir.name) if odir == dd then
os.rename(srcdir..on, srcdir..tn..odir.name) return
odir.parent[odir.name] = nil end
odir.parent = tdir dd = dd.parent
tdir[odir.name] = odir
end end
-- origin name in the target dir already
if tdir[odir.name] ~= nil then
return
end
local on = dirname(odir)
local tn = dirname(tdir)
cwriteln("mvdir ",srcdir,on," -> ",srcdir,tn,odir.name)
os.rename(srcdir..on, srcdir..tn..odir.name)
odir.parent[odir.name] = nil
odir.parent = tdir
tdir[odir.name] = odir
end end
---- ----
@ -229,17 +240,16 @@ local function rmfile()
local dn = dirname(dir) local dn = dirname(dir)
cwriteln("rmfile ",srcdir,dn,fn) cwriteln("rmfile ",srcdir,dn,fn)
posix.unlink(srcdir..dn..fn) posix.unlink(srcdir..dn..fn)
rmFileReference(odir, mn, c) rmFileReference(dir, fn, c)
end end
end end
local dice = { local dice = {
{ 10, sleep }, { 1, sleep },
{ 10, mkfile }, { 20, mkfile },
{ 10, mkdir }, { 20, mkdir },
{ 10, rmdir }, { 20, mvdir },
{ 10, mvdir }, { 20, rmfile },
{ 10, rmfile },
} }
cwriteln("making random data") cwriteln("making random data")
@ -249,12 +259,13 @@ for i, d in ipairs(dice) do
d[1] = ndice d[1] = ndice
end end
for ai=1,15 do for ai=1,20 do
-- throw a die what to do -- throw a die what to do
local acn = math.random(ndice) local acn = math.random(ndice)
for i, d in ipairs(dice) do for i, d in ipairs(dice) do
if d[1] <= acn then if acn <= d[1] then
d[2]() d[2]()
break
end end
end end
end end
@ -262,10 +273,10 @@ end
cwriteln("waiting for Lsyncd to finish its jobs.") cwriteln("waiting for Lsyncd to finish its jobs.")
posix.sleep(20) posix.sleep(20)
cwriteln("killing the Lsyncd daemon") -- cwriteln("killing the Lsyncd daemon")
posix.kill(pid) -- posix.kill(pid)
local _, exitmsg, exitcode = posix.wait(lpid) -- local _, exitmsg, exitcode = posix.wait(lpid)
cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", exitcode) -- cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", exitcode)
exitcode = os.execute("diff -r "..srcdir.." "..trgdir) exitcode = os.execute("diff -r "..srcdir.." "..trgdir)
cwriteln("Exitcode of diff = ", exitcode) cwriteln("Exitcode of diff = ", exitcode)