2021-07-02 18:01:07 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
fail() {
|
|
|
|
echo FAILED: $1
|
|
|
|
if [ "$MNT" ]
|
|
|
|
then
|
|
|
|
cd
|
|
|
|
umount "$MNT"
|
|
|
|
rmdir "$MNT"
|
|
|
|
rm "$OUT" "$EXP"
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
MNT=$(mktemp -d)
|
|
|
|
OUT=$(mktemp)
|
|
|
|
EXP=$(mktemp)
|
|
|
|
|
|
|
|
printf '{"he":{"dot":"shlishi"},"imnewhere":"derp","it":{".":"primo","..":"secondo"}}' >"$EXP"
|
|
|
|
|
|
|
|
ffs -m "$MNT" -o "$OUT" --target json ../json/obj_rename.json &
|
|
|
|
PID=$!
|
|
|
|
sleep 2
|
|
|
|
case $(ls "$MNT") in
|
2021-07-08 18:55:44 +03:00
|
|
|
(_.*_..*dot*dotdot) ;;
|
2021-07-02 18:01:07 +03:00
|
|
|
(*) fail ls;;
|
|
|
|
esac
|
2021-07-08 18:55:44 +03:00
|
|
|
[ "$(cat $MNT/_.)" = "first" ] || fail .
|
|
|
|
[ "$(cat $MNT/_..)" = "second" ] || fail ..
|
|
|
|
[ "$(cat $MNT/dot)" = "third" ] || fail dot
|
|
|
|
[ "$(cat $MNT/dotdot)" = "fourth" ] || fail dotdot
|
2021-07-02 18:01:07 +03:00
|
|
|
|
2021-07-08 18:55:44 +03:00
|
|
|
echo primo >"$MNT"/_.
|
|
|
|
echo secondo >"$MNT"/_..
|
|
|
|
echo shlishi >"$MNT"/dot
|
|
|
|
echo derp >"$MNT"/dotdot
|
2021-07-02 18:01:07 +03:00
|
|
|
|
|
|
|
mkdir "$MNT"/it
|
|
|
|
mkdir "$MNT"/he
|
|
|
|
|
2021-07-08 18:55:44 +03:00
|
|
|
mv "$MNT"/_. "$MNT"/it
|
|
|
|
mv "$MNT"/_.. "$MNT"/it
|
2021-07-02 18:01:07 +03:00
|
|
|
|
2021-07-08 18:55:44 +03:00
|
|
|
mv "$MNT"/dot "$MNT"/he
|
2021-07-02 18:01:07 +03:00
|
|
|
|
2021-07-08 18:55:44 +03:00
|
|
|
mv "$MNT"/dotdot "$MNT"/imnewhere
|
2021-07-02 18:01:07 +03:00
|
|
|
|
|
|
|
umount "$MNT" || fail unmount
|
|
|
|
sleep 1
|
|
|
|
kill -0 $PID >/dev/null 2>&1 && fail process
|
|
|
|
|
|
|
|
diff "$OUT" "$EXP" || fail diff
|
|
|
|
|
|
|
|
rmdir "$MNT" || fail mount
|
|
|
|
rm "$OUT" "$EXP"
|