lsyncd/tests/directorymv.sh

64 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
2010-08-03 15:03:42 +00:00
CON="\E[47;34m"
COFF="\033[0m"
echo -e "$CON************************************************************$COFF"
echo -e "$CON** Testing the case of directory being moved and removed. **$COFF"
echo -e "$CON************************************************************$COFF"
WORKSOURCE=$(mktemp -d)
WORKTARGET=$(mktemp -d)
PIDFILE=$(mktemp)
LOGFILE=$(mktemp)
2010-05-22 16:24:16 +00:00
echo $WORKSOURCE
echo $WORKTARGET
echo $PIDFILE
2010-08-03 15:03:42 +00:00
echo -e "$CON* populating the filesystem.$COFF"
mkdir "${WORKSOURCE}"/a
mkdir "${WORKSOURCE}"/b
touch "${WORKSOURCE}"/a/f
touch "${WORKSOURCE}"/b/g
2010-08-03 15:03:42 +00:00
echo -e "$CON* starting lsyncd.$COFF"
./lsyncd --no-daemon --logfile "${LOGFILE}" --pidfile "${PIDFILE}" "${WORKSOURCE}" "${WORKTARGET}"&
2010-05-22 16:24:16 +00:00
LSYNCPID=$(cat "${PIDFILE}")
2010-08-03 15:03:42 +00:00
echo -e "$CON* waiting for lsyncd to start.$COFF"
sleep 4s
# move a file
2010-08-03 15:03:42 +00:00
echo -e "$CON* moving a directory$COFF"
mv "${WORKSOURCE}"/a "${WORKSOURCE}"/c
2010-08-03 15:03:42 +00:00
echo -e "$CON* creating a file there$COFF"
touch "${WORKSOURCE}"/c/h
2010-08-03 15:03:42 +00:00
echo -e "$CON* and deleting a directory$COFF"
rm -r "${WORKSOURCE}"/b
2010-08-03 15:03:42 +00:00
echo -e "$CON* waiting for lsyncd to do the job.$COFF"
sleep 20s
2010-08-03 18:02:46 +00:00
echo -e "$CON* killing lsyncd$COFF"
if ! kill "${LSYNCPID}"; then
cat "${LOGFILE}"
diff -ur "${WORKSOURCE}" "${WORKTARGET}" || true
echo "kill failed"
exit 1
fi
sleep 1s
2010-08-03 15:03:42 +00:00
echo -e "$CON* log file contents$COFF"
cat "${LOGFILE}"
2010-08-03 15:03:42 +00:00
echo -e "$CON* differences$COFF"
diff -ur "${WORKSOURCE}" "${WORKTARGET}"
2010-08-03 15:03:42 +00:00
rm "${PIDFILE}"
rm "${LOGFILE}"
rm -rf "${WORKTARGET}"
rm -rf "${WORKSOURCE}"