Files
mediafire-fuse/tests/valgrind_fuse.sh

98 lines
1.9 KiB
Bash
Raw Normal View History

2014-09-21 00:03:20 +02:00
#!/bin/sh
set -ex
2014-09-21 00:03:20 +02:00
case $# in
0)
source_dir="."
binary_dir="."
;;
2)
source_dir=$1
binary_dir=$2
;;
*)
echo "usage: $0 [source_dir] [binary_dir]"
exit 1
;;
esac
cmd="valgrind --suppressions="${source_dir}/valgrind.supp" --fullpath-after="$source_dir" --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes --error-exitcode=1 --quiet"
2014-09-21 00:03:20 +02:00
if [ ! -f "$XDG_CONFIG_HOME/mediafire-tools/config" -a ! -f ~/.config/mediafire-tools/config ]; then
echo "no configuration file found" >&2
exit 1
fi
if [ `mount -t fuse.mediafire-fuse | wc -l` -ne 0 ]; then
echo "a fuse fs is already mounted" >&2
exit 1
fi
$cmd "${binary_dir}/mediafire-fuse" -f -d /mnt &
fusepid="$!"
2014-12-05 13:05:33 +01:00
# wait for the file system to be mointed
for i in `seq 1 10`; do
sleep 1
if [ `mount -t fuse.mediafire-fuse | wc -l` -ne 0 ]; then
break;
fi
done
2014-12-05 13:05:33 +01:00
# check if mounting was successful
if [ `mount -t fuse.mediafire-fuse | wc -l` -eq 0 ]; then
echo "cannot mount fuse" >&2
fusermount -u /mnt
wait "$fusepid"
exit 1
fi
2014-12-05 13:05:33 +01:00
# print tree
tree /mnt
2014-12-05 13:05:33 +01:00
# make new directory
mkdir "/mnt/test"
2014-12-19 10:15:31 +01:00
# FIXME: also test for moving and renaming of directories
2015-01-18 09:42:09 +01:00
# FIXME: also test for creating files and folder with special characters
# FIXME: also test for creating files and folder with name longer than 255
2014-12-19 10:15:31 +01:00
# create file in the root directory
echo foobar > "/mnt/foobar2"
# move the file to the new directory
mv /mnt/foobar2 /mnt/test/foobar
2014-12-05 13:05:33 +01:00
# wait a bit because above operation finishes before the release() call finished
sleep 5
# print tree
tree /mnt
# check content of new file
diff=`echo "foobar" | diff - "/mnt/test/foobar" >/dev/null 2>&1 && echo 0 || echo 1`
if [ $diff -ne 0 ]; then
2014-12-05 13:05:33 +01:00
printf "foobar" | diff - "/mnt/test/foobar" || true
fi
2014-12-05 13:05:33 +01:00
# delete directory and file inside
rm -rf "/mnt/test"
# print tree
tree /mnt
sleep 2
fusermount -u /mnt
wait "$fusepid"
valg=$?
if [ $diff -eq 0 -a $valg -eq 0 ]; then
exit 0
else
exit 1
fi