File: l4rsyncdata.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 (79 lines) | stat: -rw-r--r-- 1,742 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require( 'posix' )
dofile( 'tests/testlib.lua' )

cwriteln( '****************************************************************' )
cwriteln( ' Testing layer 4 default rsync with simulated data activity     ' )
cwriteln( '****************************************************************' )

local tdir, srcdir, trgdir = mktemps()
local logfile = tdir .. 'log'
local range = 5
local log = { '-log', 'all' }

posix.mkdir( srcdir .. 'd'   )
posix.mkdir( srcdir .. 'd/e' )

if not writefile( srcdir .. "d/e/f1", 'test' )
then
	os.exit( 1 )
end
cwriteln( 'starting Lsyncd' )

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

cwriteln( 'waiting for lsyncd to start' )
posix.sleep( 2 )

cwriteln( '* making some data' )
cwriteln( '* creating d[x]/e/f2' )

for i = 1, range
do
	cwriteln( '[cp -r ' .. srcdir .. 'd ' .. srcdir .. 'd' .. i .. ']' )
	os.execute( 'cp -r ' .. srcdir .. 'd ' .. srcdir .. 'd' .. i )
end

-- mkdir -p "$S"/m/n
-- echo 'test3' > "$S"/m/n/file
-- for i in $RANGE; do
--    cp -r "$S"/m "$S"/m$i
--    echo 'test4' > "$S"/m${i}/n/another
-- done

cwriteln( '* waiting for Lsyncd to do its job.' )
posix.sleep( 10 )

cwriteln( '* killing Lsyncd' )

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

cwriteln( '* differences:' )
_, result, code = os.execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )

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

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

-- TODO remove temp