github.com/anacrolix/torrent@v1.61.0/fs/test.sh (about) 1 #!/usr/bin/env bash 2 echo BASH_VERSION="$BASH_VERSION" 3 set -eux 4 repopath="$(cd "$(dirname "$0")/.."; pwd)" 5 debian_file=debian-10.8.0-amd64-netinst.iso 6 mkdir -p mnt torrents 7 # I think the timing can cause torrents to not get added correctly to the torrentfs client, so add 8 # them first and start the fs afterwards. 9 pushd torrents 10 cp "$repopath/testdata/$debian_file.torrent" . 11 godo -v -- "$repopath/cmd/torrent" metainfo "$repopath/testdata/sintel.torrent" magnet > sintel.magnet 12 popd 13 #file="$debian_file" 14 file=Sintel/Sintel.mp4 15 16 GOPPROF=http godo -v -- "$repopath/fs/cmd/torrentfs" -mountDir=mnt -metainfoDir=torrents &> torrentfs.log & 17 torrentfs_pid=$! 18 trap 'kill "$torrentfs_pid"' EXIT 19 20 check_file() { 21 while [ ! -e "mnt/$file" ]; do sleep 1; done 22 pv -f "mnt/$file" | gmd5sum -c <(cat <<-EOF 23 083e808d56aa7b146f513b3458658292 - 24 EOF 25 ) 26 } 27 28 ( check_file ) & 29 check_file_pid=$! 30 31 trap 'kill "$torrentfs_pid" "$check_file_pid"' EXIT 32 wait -n 33 status=$? 34 sudo umount mnt 35 trap - EXIT 36 echo "wait returned" $status 37 exit $status