diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2015-10-22 13:11:30 +0200 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2015-10-29 20:17:24 +0100 |
commit | 1d8077998c46b70e9e3026a3c72b155555749105 (patch) | |
tree | 5880db14d685727e1ba5db2fffb61182069ed139 | |
parent | 3634e0d9d773f05141867fa2ca5aa83c36b40b68 (diff) | |
download | ubifs-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-x | fsstress.sh | 64 |
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 |