diff --git a/t/test_opts.sh b/t/test_opts.sh new file mode 100755 index 0000000000..628734f12e --- /dev/null +++ b/t/test_opts.sh @@ -0,0 +1,209 @@ + #!/bin/bash + +# +############################################################################# +# +# test_opts.sh +# +# Script for testing all permutations of command-line options +# +# See sampleTest() for how to define your own test +# + +# +# set these variables for your test environment: +# +fio_executable=./fio + +# +# Demonstration of using this script +# +function sampleTest() { + + # + # sample test execution + # + # 1) Create each of your command-line groups (each in a separate array) + # 2) List the names of all your groups in one array + # 3) Define arguments that are common to all groups (if any) + # 4) Call execGroupList + # + # See getNextCmdLinePermutation() for how the permutation works + # + + local numjobs=("numjobs=1" "numjobs=8") + local rw=("rw=write" "rw=randrw") + local bs=("bs=512" "bs=64K") + local thread=("" "thread") # groups can have empty members, to test with and without option + local all=("numjobs" "rw" "bs" "thread") + + local commonArgs="-name=test -ioengine=null -size=500M -group_reporting -runtime=5" + + echo -e "\nHere are the permutations of options:\n" + printAllPermutations "${all[@]}"; + echo -e "\nHere are options common to all permutations:\n" + echo -e "${commonArgs}\n" + + read -p "Press enter to start tests..." + + execGroupList "test" "$commonArgs" "${all[@]}" +} + +# +# Iterates the next permutation for groups of command-line options +# +# Parameters: +# +# $1 Permutation to generate, 0..n-1, where 'n' is the total +# number of combinations possible in the groups passed. +# $2 Array containing list of array names, each of which contains +# a group of command-line options +# +# Return Value: +# +# retVal Command line string generated +# +# Example: +# +# ops=("op=read" "op=write") +# sizes=("size=10MB" "size=20MB" "size=50MB") +# all=("ops" "sizes") +# +# getNextCmdLinePermutation {0..6} "${all[@]}"; +# +# Results for each permutation number passed: +# +# 0: "--op=read --size=10MB" +# 1: "--op=write --size=10MB" +# 2: "--op=read --size=20MB" +# 3: "--op=write --size=20MB" +# 4: "--op=read --size=50MB" +# 5: "--op=write --size=50MB" +# 6: "" (invalid permutation #) +# +function getNextCmdLinePermutation() { + + local permutationToGet=$1 + shift + local allArgGroups=("$@") + local numArgGroups="${#allArgGroups[@]}" + local cmdLine="" + local groupNum n + + for ((groupNum=0, n=permutationToGet; groupNum