From 824797645b0193e312908dc03b2394f2f55defc3 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Fri, 23 Nov 2012 16:04:43 +0100 Subject: [PATCH] beautified some tests --- tests/churn-rsync.lua | 36 ++++++++++++------------- tests/churn-rsyncssh.lua | 57 +++++++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/tests/churn-rsync.lua b/tests/churn-rsync.lua index b3af183..5658a78 100755 --- a/tests/churn-rsync.lua +++ b/tests/churn-rsync.lua @@ -1,12 +1,12 @@ #!/usr/bin/lua -- a heavy duty test. -- makes thousends of random changes to the source tree -require( "posix" ) -dofile( "tests/testlib.lua" ) +require( 'posix' ) +dofile( 'tests/testlib.lua' ) -cwriteln( "****************************************************************" ) -cwriteln( " Testing default.rsync with random data activity" ) -cwriteln( "****************************************************************" ) +cwriteln( '****************************************************************' ) +cwriteln( ' Testing default.rsync with random data activity' ) +cwriteln( '****************************************************************' ) local tdir, srcdir, trgdir = mktemps( ) @@ -16,35 +16,35 @@ churn( srcdir, 100 ) local logs = { } -- logs = { "-log", "Delay", "-log", "Fsevents" } local pid = spawn( - "./lsyncd", - "-nodaemon", - "-delay", "5", - "-rsync", srcdir, trgdir, + './lsyncd', + '-nodaemon', + '-delay', '5', + '-rsync', srcdir, trgdir, unpack( logs ) ) -cwriteln( "waiting for Lsyncd to startup" ) +cwriteln( 'waiting for Lsyncd to startup' ) posix.sleep( 1 ) churn( srcdir, 500 ) -cwriteln( "waiting for Lsyncd to finish its jobs." ) +cwriteln( 'waiting for Lsyncd to finish its jobs.' ) posix.sleep( 10 ) -cwriteln( "killing the Lsyncd daemon" ) +cwriteln( 'killing the Lsyncd daemon' ) -posix.kill(pid) +posix.kill( pid ) local _, exitmsg, lexitcode = posix.wait( lpid ) -cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode) +cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode ) -exitcode = os.execute( "diff -r "..srcdir.." "..trgdir ) -cwriteln( "Exitcode of diff = '", exitcode, "'" ) +exitcode = os.execute( 'diff -r '..srcdir..' '..trgdir ) +cwriteln( 'Exitcode of diff = "', exitcode, '"' ) if exitcode ~= 0 then - os.exit(1) + os.exit( 1 ) else - os.exit(0) + os.exit( 0 ) end diff --git a/tests/churn-rsyncssh.lua b/tests/churn-rsyncssh.lua index 715b919..5f9af0c 100755 --- a/tests/churn-rsyncssh.lua +++ b/tests/churn-rsyncssh.lua @@ -1,47 +1,56 @@ #!/usr/bin/lua -- a heavy duty test. -- makes thousends of random changes to the source tree -require("posix") -dofile("tests/testlib.lua") -cwriteln("****************************************************************"); -cwriteln(" Testing default.rsyncssh with random data activity"); -cwriteln("****************************************************************"); -cwriteln("( this test needs passwordless ssh localhost access )"); -cwriteln("( for current user )"); +require( 'posix' ) + +dofile( 'tests/testlib.lua' ) + +cwriteln( '****************************************************************' ) +cwriteln( ' Testing default.rsyncssh with random data activity ' ) +cwriteln( '****************************************************************' ) +cwriteln( '( this test needs passwordless ssh localhost access )' ) +cwriteln( '( for current user )' ) local tdir, srcdir, trgdir = mktemps() -- makes some startup data -churn(srcdir, 100) +churn( srcdir, 100 ) local logs = {} -logs = {"-log", "Delay" } +logs = { '-log', 'Delay' } -local pid = spawn("./lsyncd", "-nodaemon", "-delay", "5", - "-rsyncssh", srcdir, "localhost", trgdir, - unpack(logs)) +local pid = spawn( + './lsyncd', + '-nodaemon', + '-delay', + '5', + '-rsyncssh', + srcdir, + 'localhost', + trgdir, + unpack(logs) +) -cwriteln("waiting for Lsyncd to startup") -posix.sleep(1) +cwriteln( 'waiting for Lsyncd to startup' ) +posix.sleep( 1 ) -churn(srcdir, 100) +churn( srcdir, 100 ) -cwriteln("waiting for Lsyncd to finish its jobs.") -posix.sleep(10) +cwriteln( 'waiting for Lsyncd to finish its jobs.' ) +posix.sleep( 10 ) -cwriteln("killing the Lsyncd daemon") +cwriteln( 'killing the Lsyncd daemon' ) posix.kill(pid) local _, exitmsg, lexitcode = posix.wait(lpid) -cwriteln("Exitcode of Lsyncd = ", exitmsg, " ", lexitcode) +cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode ) -exitcode = os.execute("diff -r "..srcdir.." "..trgdir) -cwriteln("Exitcode of diff = '", exitcode, "'") +exitcode = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir ) +cwriteln( 'Exitcode of diff = "', exitcode, '"' ) if exitcode ~= 0 then - os.exit(1) + os.exit( 1 ) else - os.exit(0) + os.exit( 0 ) end -