File: churn-rsync.lua

package info (click to toggle)
lsyncd 2.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 484 kB
  • sloc: ansic: 2,640; sh: 81; makefile: 11
file content (57 lines) | stat: -rw-r--r-- 1,232 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- a heavy duty test.
-- makes thousends of random changes to the source tree

require( 'posix' )
dofile( 'tests/testlib.lua' )

cwriteln( '****************************************************************' )
cwriteln( ' Testing default.rsync with random data activity'                 )
cwriteln( '****************************************************************' )

local tdir, srcdir, trgdir = mktemps( )

-- makes some startup data
churn( srcdir, 100, true )

local logs = { }
-- logs =  { "-log", "Delay", "-log", "Fsevents" }
local pid = spawn(
	'./lsyncd',
	'-nodaemon',
	'-delay', '5',
	'-rsync', srcdir, trgdir,
	table.unpack( logs )
)

cwriteln( 'waiting for Lsyncd to startup' )

posix.sleep( 1 )

churn( srcdir, 500, false )

cwriteln( 'waiting for Lsyncd to finish its jobs.' )

posix.sleep( 10 )

cwriteln( 'killing the Lsyncd daemon' )

posix.kill( pid )
local _, exitmsg, lexitcode = posix.wait( lpid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )

_, result, code = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )

if result == 'exit'
then
	cwriteln( 'Exitcode of diff = ', code  )
else
	cwriteln( 'Signal terminating diff = ', code )
end

if code ~= 0
then
	os.exit( 1 )
else
	os.exit( 0 )
end