summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2015-10-22 13:11:30 +0200
committerRichard Weinberger <richard@nod.at>2015-10-29 20:17:24 +0100
commit1d8077998c46b70e9e3026a3c72b155555749105 (patch)
tree5880db14d685727e1ba5db2fffb61182069ed139
parent3634e0d9d773f05141867fa2ca5aa83c36b40b68 (diff)
downloadubifs-load-1d8077998c46b70e9e3026a3c72b155555749105.tar.gz
Add getopt based option handling
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at> Signed-off-by: Richard Weinberger <richard@nod.at>
-rwxr-xr-xfsstress.sh64
1 files changed, 53 insertions, 11 deletions
diff --git a/fsstress.sh b/fsstress.sh
index c0c65a2..3b112b0 100755
--- a/fsstress.sh
+++ b/fsstress.sh
@@ -12,7 +12,6 @@
# The tests are currently rather archaic due to limitations of Busybox.
#
# TODO:
-# - getopt support
# - report results from UBI stats interface (needs rewrite in C)
#
@@ -122,6 +121,46 @@ read_big_files()
done
}
+usage()
+{
+ SELF=`basename "$0"`
+
+ echo "Usage: $SELF [arguments]"
+ echo " -b, --bulk If set, perform bulk write test."
+ echo " -w, --writemuch If set, perform write stress test."
+ echo " -r, --runs <count> Specify the number of test iterations."
+ echo " -n, --files <count> Specify the number of small files to create."
+ echo " -N, --big-files <count> Specifiy the number of large files to create."
+ echo " -h, --help Display this text and exit."
+ echo " --min-mb <count> The minimum size (MiB) of small files."
+ echo " --max-mb <count> The maximum size (MiB) of small files."
+ echo " --min-bulk-mb <count> The minimum size (MiB) of large files."
+ echo " --max-bulk-mb <count> The maximum size (MiB) of large files."
+ exit
+}
+
+
+O=`getopt -l bulk,writemuch,runs:,files:,big-files:,max-mb:,min-mb:,max-bulk-mb:,min-bulk-mb:,help -- bwr:n:N:h "$@"`
+eval set -- "$O"
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -b|--bulk) BULK_WRITE=1;;
+ -w|--writemuch) WRITE_MUCH=1;;
+ -r|--runs) RUN_NUM=$(($2 - 1)); shift;;
+ -n|--files) FILE_NUM=$(($2 - 1)); shift;;
+ -N|--big-files) BIG_FILE_NUM=$(($2 - 1)); shift;;
+ -h|--help) usage;;
+ --max-mb) MAX_SIZE_MB="$2"; shift;;
+ --min-mb) MIN_SIZE_MB="$2"; shift;;
+ --max-bulk-mb) MAX_BULK_SIZE_MB="$2"; shift;;
+ --min-bulk-mb) MIN_BULK_SIZE_MB="$2"; shift;;
+ --) shift; break;;
+ esac
+ shift
+done
+
+
for r in $(seq 0 $RUN_NUM)
do
drop_caches
@@ -141,17 +180,20 @@ do
read_files
done
- for i in $(seq 1 20)
- do
- read_files
- write_rand_file
- done
+ if [ $FILE_NUM -gt 0 ]
+ then
+ for i in $(seq 1 20)
+ do
+ read_files
+ write_rand_file
+ done
- for i in $(seq 1 20)
- do
- read_files
- write_rand_file_sync
- done
+ for i in $(seq 1 20)
+ do
+ read_files
+ write_rand_file_sync
+ done
+ fi
if [ $WRITE_MUCH -eq 1 ]
then