14 echo "usage: $0 [--config file] [--subsection subsec] [other_git_tree...] [--] [test_scripts]"
18 GIT_PERF_CONFIG_FILE
=$
(cd "$(dirname "$1")"; pwd)/$
(basename "$1")
19 export GIT_PERF_CONFIG_FILE
23 GIT_PERF_SUBSECTION
="$1"
24 export GIT_PERF_SUBSECTION
27 die
"unrecognised option: '$arg'" ;;
34 if test $# -eq 0; then
37 echo "=== Running $# tests in ${GIT_TEST_INSTALLED:-this tree} ==="
45 echo "=== Unpacking $rev in build/$rev ==="
47 (cd "$(git rev-parse --show-cdup)" && git archive
--format=tar $rev) |
48 (cd build
/$rev && tar x
)
54 for config
in config.mak config.mak.autogen config.status
56 if test -e "../../$config"
58 cp "../../$config" "build/$rev/"
61 echo "=== Building $rev ($name) ==="
64 if test -n "$GIT_PERF_MAKE_COMMAND"
66 sh
-c "$GIT_PERF_MAKE_COMMAND"
68 make $GIT_PERF_MAKE_OPTS
70 ) || die
"failed to build revision '$mydir'"
73 set_git_test_installed
() {
76 mydir_abs
=$
(cd $mydir && pwd)
77 mydir_abs_wrappers
="$mydir_abs/bin-wrappers"
78 if test -d "$mydir_abs_wrappers"
80 GIT_TEST_INSTALLED
=$mydir_abs_wrappers
82 # Older versions of git lacked bin-wrappers;
83 # fallback to the files in the root.
84 GIT_TEST_INSTALLED
=$mydir_abs
86 export GIT_TEST_INSTALLED
87 PERF_SET_GIT_TEST_INSTALLED
=true
88 export PERF_SET_GIT_TEST_INSTALLED
94 while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
97 if test $# -gt 0 -a "$1" = --; then
102 if test "$mydir" = "."
104 unset GIT_TEST_INSTALLED
105 elif test -d "$mydir"
107 PERF_RESULTS_PREFIX
=bindir$
(cd $mydir && printf "%s" "$(pwd)" |
tr -c "[a-zA-Z0-9]" "_").
108 set_git_test_installed
"$mydir"
110 rev=$
(git rev-parse
--verify "$mydir" 2>/dev
/null
) ||
111 die
"'$mydir' is neither a directory nor a valid revision"
112 if [ ! -d build
/$rev ]; then
115 build_git_rev
$rev "$mydir"
118 PERF_RESULTS_PREFIX
=build_
$rev.
119 set_git_test_installed
"$mydir"
121 export PERF_RESULTS_PREFIX
127 while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
135 test -z "$GIT_PERF_CONFIG_FILE" && return
136 git config
-f "$GIT_PERF_CONFIG_FILE" --name-only --get-regex "$section\..*\.[^.]+" |
137 sed -e "s/$section\.\(.*\)\..*/\1/" |
sort |
uniq
140 get_var_from_env_or_config
() {
144 conf_opts
="$4" # optional
146 # Do nothing if the env variable is already set
147 eval "test -z \"\${$env_var+x}\"" ||
return
149 test -z "$GIT_PERF_CONFIG_FILE" && return
151 # Check if the variable is in the config file
152 if test -n "$GIT_PERF_SUBSECTION"
154 var
="$conf_sec.$GIT_PERF_SUBSECTION.$conf_var"
155 conf_value
=$
(git config
$conf_opts -f "$GIT_PERF_CONFIG_FILE" "$var") &&
156 eval "$env_var=\"$conf_value\"" && return
158 var
="$conf_sec.$conf_var"
159 conf_value
=$
(git config
$conf_opts -f "$GIT_PERF_CONFIG_FILE" "$var") &&
160 eval "$env_var=\"$conf_value\""
164 get_var_from_env_or_config
"GIT_PERF_REPEAT_COUNT" "perf" "repeatCount" "--int"
165 : ${GIT_PERF_REPEAT_COUNT:=3}
166 export GIT_PERF_REPEAT_COUNT
168 get_var_from_env_or_config
"GIT_PERF_DIRS_OR_REVS" "perf" "dirsOrRevs"
169 set -- $GIT_PERF_DIRS_OR_REVS "$@"
171 get_var_from_env_or_config
"GIT_PERF_MAKE_COMMAND" "perf" "makeCommand"
172 get_var_from_env_or_config
"GIT_PERF_MAKE_OPTS" "perf" "makeOpts"
174 get_var_from_env_or_config
"GIT_PERF_REPO_NAME" "perf" "repoName"
175 export GIT_PERF_REPO_NAME
177 GIT_PERF_AGGREGATING_LATER
=t
178 export GIT_PERF_AGGREGATING_LATER
180 if test $# = 0 -o "$1" = -- -o -f "$1"; then
185 test "$GIT_PERF_CODESPEED_OUTPUT" = "true" && codespeed_opt
="--codespeed"
189 if test -z "$GIT_PERF_SEND_TO_CODESPEED"
191 .
/aggregate.perl
--results-dir="$TEST_RESULTS_DIR" $codespeed_opt "$@"
193 json_res_file
=""$TEST_RESULTS_DIR"/$GIT_PERF_SUBSECTION/aggregate.json"
194 .
/aggregate.perl
--results-dir="$TEST_RESULTS_DIR" --codespeed "$@" |
tee "$json_res_file"
195 send_data_url
="$GIT_PERF_SEND_TO_CODESPEED/result/add/json/"
196 curl
-v --request POST
--data-urlencode "json=$(cat "$json_res_file")" "$send_data_url"
200 get_var_from_env_or_config
"GIT_PERF_CODESPEED_OUTPUT" "perf" "codespeedOutput" "--bool"
201 get_var_from_env_or_config
"GIT_PERF_SEND_TO_CODESPEED" "perf" "sendToCodespeed"
204 . ..
/..
/GIT-BUILD-OPTIONS
206 if test -n "$TEST_OUTPUT_DIRECTORY"
208 TEST_RESULTS_DIR
="$TEST_OUTPUT_DIRECTORY/test-results"
210 TEST_RESULTS_DIR
=test-results
213 mkdir
-p "$TEST_RESULTS_DIR"
214 get_subsections
"perf" >"$TEST_RESULTS_DIR"/run_subsections.names
216 if test $
(wc -l <"$TEST_RESULTS_DIR"/run_subsections.names
) -eq 0
218 if test -n "$GIT_PERF_SUBSECTION"
220 if test -n "$GIT_PERF_CONFIG_FILE"
222 die
"no subsections are defined in config file '$GIT_PERF_CONFIG_FILE'"
224 die
"subsection '$GIT_PERF_SUBSECTION' defined without a config file"
230 elif test -n "$GIT_PERF_SUBSECTION"
232 egrep "^$GIT_PERF_SUBSECTION\$" "$TEST_RESULTS_DIR"/run_subsections.names
>/dev
/null ||
233 die
"subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'"
235 egrep "^$GIT_PERF_SUBSECTION\$" "$TEST_RESULTS_DIR"/run_subsections.names |
while read -r subsec
238 GIT_PERF_SUBSECTION
="$subsec"
239 export GIT_PERF_SUBSECTION
240 echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========"
248 GIT_PERF_SUBSECTION
="$subsec"
249 export GIT_PERF_SUBSECTION
250 echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========"
253 done <"$TEST_RESULTS_DIR"/run_subsections.names