Last active
April 15, 2016 12:36
-
-
Save itisravi/886e5461406e2519a6d83bb2097f88da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Original script here: https://gist.github.com/Harshavardhana/6502979r | |
#TARPATH="/root/bin/tar-1.23/usr/local/bin/" | |
TARPATH="/root/bin/tar-1.26/usr/local/bin/" | |
_init() | |
{ | |
DIRZ=$( seq 1 100 ) | |
} | |
cleanup() | |
{ | |
echo "Cleaning the test" | |
if [ -f /tmp/tar_read_errors.txt ]; then | |
rm -f /tmp/tar_read_errors.txt; | |
fi | |
for dir in $DIRZ | |
do | |
rm -fr $dir | |
rm -fr ${dir}.tar | |
done | |
} | |
samples() | |
{ | |
echo "Creating samples" | |
# create dirs | |
for dir in $DIRZ | |
do | |
[ -f $dir/afile ] && continue | |
mkdir $dir | |
if [ "$1" == "sync" ]; then | |
dd if=/dev/urandom of=$dir/afile bs=4096 count=10 oflag=sync >/dev/null 2>&1 | |
else | |
dd if=/dev/urandom of=$dir/afile bs=4096 count=10 >/dev/null 2>&1 | |
fi | |
done | |
} | |
readtest(){ | |
echo "Performing read test" | |
# do the tars | |
for dir in $DIRZ | |
do | |
$TARPATH/tar cf ${dir}.tar $dir 2>>/tmp/tar_read_errors.txt | |
done | |
} | |
main() | |
{ | |
cleanup; | |
if [ "$1" == "sync" ]; then | |
echo "O_SYNC is turned on" | |
samples $1; | |
readtest; | |
count=`wc -l /tmp/tar_read_errors.txt` | |
elif [ "$1" == "flush" ]; then | |
echo "Flushing filesystem buffers"; | |
samples; | |
sync; | |
readtest; | |
count=`wc -l /tmp/tar_read_errors.txt` | |
else | |
samples; | |
readtest; | |
count=`wc -l /tmp/tar_read_errors.txt` | |
fi | |
echo "Total read failures ${count}" | |
} | |
_init "$@" && main "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment