genfio: Adding exec_{pre|post}run support
authorErwan Velu <erwan@enovance.com>
Mon, 15 Jul 2013 09:10:27 +0000 (11:10 +0200)
committerErwan Velu <erwan@enovance.com>
Sun, 21 Jul 2013 09:58:49 +0000 (11:58 +0200)
It's pretty useful being able to run some commands before or after a
job. That could be use to ask some external storage array to loose its
cache or return in a particular configuration state.

The -A (stands for After) or -B (stands for Before) allow user to define
what commands shall be run before or after a job.

tools/genfio

index 3f9ab283840a54bef1c1ae2ef70bf2e1ccc7d759..49cbd5032b7a51773fc1ff8ed65953cd65fb54dc 100755 (executable)
@@ -65,6 +65,8 @@ show_help() {
 -x prefix                      : Add a prefix to the fio filename
                                        Useful to let a context associated with the file
                                        If the prefix features a / (slash), prefix will be considered as a directory
 -x prefix                      : Add a prefix to the fio filename
                                        Useful to let a context associated with the file
                                        If the prefix features a / (slash), prefix will be considered as a directory
+-A cmd_to_run                  : System command to run after each job (exec_postrun in fio)
+-B cmd_to_run                  : System command to run before each job (exec_prerun in fio)
 
 Example:
 
 
 Example:
 
@@ -189,7 +191,7 @@ esac
 }
 
 parse_cmdline() {
 }
 
 parse_cmdline() {
-while getopts "hacpsd:b:r:m:x:D:" opt; do
+while getopts "hacpsd:b:r:m:x:D:A:B:" opt; do
   case $opt in
     h)
        show_help
   case $opt in
     h)
        show_help
@@ -239,6 +241,12 @@ while getopts "hacpsd:b:r:m:x:D:" opt; do
     a)
        SEQ=2
       ;;
     a)
        SEQ=2
       ;;
+    B)
+       echo "exec_prerun=$OPTARG" >> $TEMPLATE
+      ;;
+    A)
+       echo "exec_postrun=$OPTARG" >> $TEMPLATE
+      ;;
     \?)
       echo "Invalid option: -$OPTARG" >&2
       ;;
     \?)
       echo "Invalid option: -$OPTARG" >&2
       ;;