lsyncd/tests/directorycpr.sh

64 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
# test the case of directory being cp -r'ed and touched. lsyncd 1.0 doesn't handle this case well.
set -e
2010-08-03 14:24:46 +00:00
CON="\E[47;34m"
COFF="\033[0m"
WORKSOURCE=$(mktemp -d)
2010-08-03 14:26:57 +00:00
WORKSOURCE="/tmp/src"
WORKTARGET="/tmp/trg"
PIDFILE=$(mktemp)
LOGFILE=$(mktemp)
2010-08-03 14:24:46 +00:00
echo -e "$CON* populating the filesystem$COFF"
mkdir -p "${WORKSOURCE}"/a/a
echo 'test' > "${WORKSOURCE}"/a/a/file
2010-08-03 14:24:46 +00:00
echo -e "$CON* starting lsyncd$COFF"
./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" --no-daemon "${WORKSOURCE}" "${WORKTARGET}"&
2010-08-03 14:24:46 +00:00
echo -e "$CON* waiting for lsyncd to start$COFF"
2008-11-20 21:38:58 +00:00
sleep 4s
2010-08-03 14:24:46 +00:00
# cp -r the directory
echo -e "$CON* make a lot of copies$OFF"
for A in 1 2 3 4 5 6 7 8 9 10; do
cp -r "${WORKSOURCE}"/a "${WORKSOURCE}"/b${A}
echo 'test2' > "${WORKSOURCE}"/b${A}/a/another
done
2010-08-03 14:24:46 +00:00
echo -e "$CON* mkdir double path$OFF"
mkdir -p "${WORKSOURCE}"/c/a
echo 'test3' > "${WORKSOURCE}"/c/a/file
2010-08-03 14:24:46 +00:00
echo -e "$CON* copy the other dir a few times$COFF"
for A in 1 2 3 4 5 6 7 8 9 10; do
cp -r "${WORKSOURCE}"/c "${WORKSOURCE}"/d${A}
echo 'test2' > "${WORKSOURCE}"/d${A}/a/another
done
2010-08-03 14:24:46 +00:00
echo -e "$CON*waiting until lsyncd does the job.$COFF"
sleep 15s
2010-08-03 14:24:46 +00:00
echo -e "$CON*killing lsyncd"
LSYNCPID=$(cat "${PIDFILE}")
if ! kill "${LSYNCPID}"; then
cat "${LOGFILE}"
diff -urN "${WORKSOURCE}" "${WORKTARGET}" || true
echo "kill failed"
exit 1
fi
sleep 1s
2010-08-03 14:24:46 +00:00
#echo "log file contents"
#cat "${LOGFILE}"
##this should be grep.
2010-08-03 14:24:46 +00:00
echo -e "$CON*differences$COFF"
diff -urN "${WORKSOURCE}" "${WORKTARGET}"
2010-08-03 14:24:46 +00:00
#rm "${PIDFILE}"
#rm "${LOGFILE}"
#rm -rf "${WORKTARGET}"
#rm -rf "${WORKSOURCE}"