testsuite to move directory and remove a directory.

lsyncd1.0 doesn't handle this case very well, and lsyncd does not copy
the files, and does not detect an error condition, or simply dies.
This commit is contained in:
Junichi Uekawa 2008-10-08 04:09:02 +00:00
parent 03a32b6e1e
commit 82302ad03e
2 changed files with 53 additions and 0 deletions

View File

@ -2,6 +2,7 @@
bin_PROGRAMS = lsyncd
lsyncd_SOURCES = lsyncd.c
TESTS = tests/help.sh \
tests/directorymv.sh \
tests/pidfile.sh \
tests/version.sh \
tests/wrong-logfile.sh \

52
tests/directorymv.sh Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
# test the case of directory being mv'ed and rm'ed. lsyncd 1.0 didn't handle this case well.
set -e
WORKSOURCE=$(mktemp -d)
WORKTARGET=$(mktemp -d)
PIDFILE=$(mktemp)
LOGFILE=$(mktemp)
# populate the filesystem.
mkdir "${WORKSOURCE}"/a
mkdir "${WORKSOURCE}"/b
touch "${WORKSOURCE}"/a/f
touch "${WORKSOURCE}"/b/g
./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" "${WORKSOURCE}" "${WORKTARGET}"
# try to wait until lsyncd starts and rsyncs initial file, hope 1s is enough.
sleep 2s
# move a file
mv "${WORKSOURCE}"/a "${WORKSOURCE}"/c
touch "${WORKSOURCE}"/c/h
#lsyncd 1.0 dies here
rm -r "${WORKSOURCE}"/b
# try to wait until lsyncd does the job.
sleep 2s
LSYNCPID=$(cat "${PIDFILE}")
if ! kill "${LSYNCPID}"; then
cat "${LOGFILE}"
diff -ur "${WORKSOURCE}" "${WORKTARGET}" || true
echo "kill failed"
exit 1
fi
sleep 1s
echo "log file contents"
cat "${LOGFILE}"
#this should be grep.
diff -ur "${WORKSOURCE}" "${WORKTARGET}"
rm "${PIDFILE}"
rm "${LOGFILE}"
rm -rf "${WORKTARGET}"
rm -rf "${WORKSOURCE}"