Git fork

perf/run: add --subsection option

This new option makes it possible to run perf tests as defined
in only one subsection of a config file.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Christian Couder and committed by
Junio C Hamano
8796b307 2e3efd06

+46 -10
+46 -10
t/perf/run
··· 1 1 #!/bin/sh 2 2 3 - case "$1" in 3 + die () { 4 + echo >&2 "error: $*" 5 + exit 1 6 + } 7 + 8 + while [ $# -gt 0 ]; do 9 + arg="$1" 10 + case "$arg" in 11 + --) 12 + break ;; 4 13 --help) 5 - echo "usage: $0 [--config file] [other_git_tree...] [--] [test_scripts]" 6 - exit 0 7 - ;; 14 + echo "usage: $0 [--config file] [--subsection subsec] [other_git_tree...] [--] [test_scripts]" 15 + exit 0 ;; 8 16 --config) 9 17 shift 10 18 GIT_PERF_CONFIG_FILE=$(cd "$(dirname "$1")"; pwd)/$(basename "$1") 11 19 export GIT_PERF_CONFIG_FILE 12 20 shift ;; 13 - esac 14 - 15 - die () { 16 - echo >&2 "error: $*" 17 - exit 1 18 - } 21 + --subsection) 22 + shift 23 + GIT_PERF_SUBSECTION="$1" 24 + export GIT_PERF_SUBSECTION 25 + shift ;; 26 + --*) 27 + die "unrecognised option: '$arg'" ;; 28 + *) 29 + break ;; 30 + esac 31 + done 19 32 20 33 run_one_dir () { 21 34 if test $# -eq 0; then ··· 172 185 173 186 if test $(wc -l <test-results/run_subsections.names) -eq 0 174 187 then 188 + if test -n "$GIT_PERF_SUBSECTION" 189 + then 190 + if test -n "$GIT_PERF_CONFIG_FILE" 191 + then 192 + die "no subsections are defined in config file '$GIT_PERF_CONFIG_FILE'" 193 + else 194 + die "subsection '$GIT_PERF_SUBSECTION' defined without a config file" 195 + fi 196 + fi 175 197 ( 176 198 run_subsection "$@" 177 199 ) 200 + elif test -n "$GIT_PERF_SUBSECTION" 201 + then 202 + egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names >/dev/null || 203 + die "subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'" 204 + 205 + egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names | while read -r subsec 206 + do 207 + ( 208 + GIT_PERF_SUBSECTION="$subsec" 209 + export GIT_PERF_SUBSECTION 210 + echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========" 211 + run_subsection "$@" 212 + ) 213 + done 178 214 else 179 215 while read -r subsec 180 216 do