2012-02-17 11:25:09 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-04-08 11:35:12 +02:00
|
|
|
die () {
|
|
|
|
echo >&2 "error: $*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
arg="$1"
|
|
|
|
case "$arg" in
|
|
|
|
--)
|
|
|
|
break ;;
|
2012-02-17 11:25:09 +01:00
|
|
|
--help)
|
2018-04-08 11:35:12 +02:00
|
|
|
echo "usage: $0 [--config file] [--subsection subsec] [other_git_tree...] [--] [test_scripts]"
|
|
|
|
exit 0 ;;
|
2017-09-23 21:55:56 +02:00
|
|
|
--config)
|
|
|
|
shift
|
|
|
|
GIT_PERF_CONFIG_FILE=$(cd "$(dirname "$1")"; pwd)/$(basename "$1")
|
|
|
|
export GIT_PERF_CONFIG_FILE
|
|
|
|
shift ;;
|
2018-04-08 11:35:12 +02:00
|
|
|
--subsection)
|
|
|
|
shift
|
|
|
|
GIT_PERF_SUBSECTION="$1"
|
|
|
|
export GIT_PERF_SUBSECTION
|
|
|
|
shift ;;
|
|
|
|
--*)
|
|
|
|
die "unrecognised option: '$arg'" ;;
|
|
|
|
*)
|
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
done
|
2012-02-17 11:25:09 +01:00
|
|
|
|
|
|
|
run_one_dir () {
|
|
|
|
if test $# -eq 0; then
|
|
|
|
set -- p????-*.sh
|
|
|
|
fi
|
|
|
|
echo "=== Running $# tests in ${GIT_TEST_INSTALLED:-this tree} ==="
|
|
|
|
for t in "$@"; do
|
|
|
|
./$t $GIT_TEST_OPTS
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
unpack_git_rev () {
|
|
|
|
rev=$1
|
2017-05-20 23:42:19 +02:00
|
|
|
echo "=== Unpacking $rev in build/$rev ==="
|
2012-02-17 11:25:09 +01:00
|
|
|
mkdir -p build/$rev
|
|
|
|
(cd "$(git rev-parse --show-cdup)" && git archive --format=tar $rev) |
|
|
|
|
(cd build/$rev && tar x)
|
|
|
|
}
|
2017-09-23 21:55:56 +02:00
|
|
|
|
2012-02-17 11:25:09 +01:00
|
|
|
build_git_rev () {
|
|
|
|
rev=$1
|
2017-09-23 21:55:56 +02:00
|
|
|
name="$2"
|
2016-09-13 08:58:00 +02:00
|
|
|
for config in config.mak config.mak.autogen config.status
|
|
|
|
do
|
|
|
|
if test -e "../../$config"
|
|
|
|
then
|
|
|
|
cp "../../$config" "build/$rev/"
|
|
|
|
fi
|
|
|
|
done
|
2017-09-23 21:55:56 +02:00
|
|
|
echo "=== Building $rev ($name) ==="
|
2017-05-20 23:42:18 +02:00
|
|
|
(
|
|
|
|
cd build/$rev &&
|
|
|
|
if test -n "$GIT_PERF_MAKE_COMMAND"
|
|
|
|
then
|
|
|
|
sh -c "$GIT_PERF_MAKE_COMMAND"
|
|
|
|
else
|
|
|
|
make $GIT_PERF_MAKE_OPTS
|
|
|
|
fi
|
|
|
|
) || die "failed to build revision '$mydir'"
|
2012-02-17 11:25:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
run_dirs_helper () {
|
|
|
|
mydir=${1%/}
|
|
|
|
shift
|
|
|
|
while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
if test $# -gt 0 -a "$1" = --; then
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
if [ ! -d "$mydir" ]; then
|
|
|
|
rev=$(git rev-parse --verify "$mydir" 2>/dev/null) ||
|
|
|
|
die "'$mydir' is neither a directory nor a valid revision"
|
|
|
|
if [ ! -d build/$rev ]; then
|
|
|
|
unpack_git_rev $rev
|
|
|
|
fi
|
2017-09-23 21:55:56 +02:00
|
|
|
build_git_rev $rev "$mydir"
|
2012-02-17 11:25:09 +01:00
|
|
|
mydir=build/$rev
|
|
|
|
fi
|
|
|
|
if test "$mydir" = .; then
|
|
|
|
unset GIT_TEST_INSTALLED
|
|
|
|
else
|
|
|
|
GIT_TEST_INSTALLED="$mydir/bin-wrappers"
|
2017-03-03 08:36:33 +01:00
|
|
|
# Older versions of git lacked bin-wrappers; fallback to the
|
|
|
|
# files in the root.
|
|
|
|
test -d "$GIT_TEST_INSTALLED" || GIT_TEST_INSTALLED=$mydir
|
2012-02-17 11:25:09 +01:00
|
|
|
export GIT_TEST_INSTALLED
|
|
|
|
fi
|
|
|
|
run_one_dir "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
run_dirs () {
|
|
|
|
while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
|
|
|
|
run_dirs_helper "$@"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
get_subsections () {
|
|
|
|
section="$1"
|
|
|
|
test -z "$GIT_PERF_CONFIG_FILE" && return
|
|
|
|
git config -f "$GIT_PERF_CONFIG_FILE" --name-only --get-regex "$section\..*\.[^.]+" |
|
|
|
|
sed -e "s/$section\.\(.*\)\..*/\1/" | sort | uniq
|
|
|
|
}
|
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
get_var_from_env_or_config () {
|
|
|
|
env_var="$1"
|
2017-09-23 21:55:56 +02:00
|
|
|
conf_sec="$2"
|
|
|
|
conf_var="$3"
|
2018-01-05 10:12:23 +01:00
|
|
|
conf_opts="$4" # optional
|
2017-09-23 21:55:56 +02:00
|
|
|
|
|
|
|
# Do nothing if the env variable is already set
|
|
|
|
eval "test -z \"\${$env_var+x}\"" || return
|
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
test -z "$GIT_PERF_CONFIG_FILE" && return
|
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
# Check if the variable is in the config file
|
2017-09-23 21:55:56 +02:00
|
|
|
if test -n "$GIT_PERF_SUBSECTION"
|
|
|
|
then
|
|
|
|
var="$conf_sec.$GIT_PERF_SUBSECTION.$conf_var"
|
2018-01-05 10:12:23 +01:00
|
|
|
conf_value=$(git config $conf_opts -f "$GIT_PERF_CONFIG_FILE" "$var") &&
|
2017-09-23 21:55:56 +02:00
|
|
|
eval "$env_var=\"$conf_value\"" && return
|
|
|
|
fi
|
|
|
|
var="$conf_sec.$conf_var"
|
2018-01-05 10:12:23 +01:00
|
|
|
conf_value=$(git config $conf_opts -f "$GIT_PERF_CONFIG_FILE" "$var") &&
|
2018-02-25 14:18:05 +01:00
|
|
|
eval "$env_var=\"$conf_value\""
|
2017-09-23 21:55:56 +02:00
|
|
|
}
|
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
run_subsection () {
|
2018-02-25 14:18:05 +01:00
|
|
|
get_var_from_env_or_config "GIT_PERF_REPEAT_COUNT" "perf" "repeatCount" "--int"
|
|
|
|
: ${GIT_PERF_REPEAT_COUNT:=3}
|
2017-09-23 21:55:56 +02:00
|
|
|
export GIT_PERF_REPEAT_COUNT
|
2017-09-23 21:55:56 +02:00
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
get_var_from_env_or_config "GIT_PERF_DIRS_OR_REVS" "perf" "dirsOrRevs"
|
|
|
|
set -- $GIT_PERF_DIRS_OR_REVS "$@"
|
2017-09-23 21:55:56 +02:00
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
get_var_from_env_or_config "GIT_PERF_MAKE_COMMAND" "perf" "makeCommand"
|
|
|
|
get_var_from_env_or_config "GIT_PERF_MAKE_OPTS" "perf" "makeOpts"
|
2017-09-23 21:55:56 +02:00
|
|
|
|
2018-01-05 10:12:26 +01:00
|
|
|
get_var_from_env_or_config "GIT_PERF_REPO_NAME" "perf" "repoName"
|
|
|
|
export GIT_PERF_REPO_NAME
|
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
GIT_PERF_AGGREGATING_LATER=t
|
|
|
|
export GIT_PERF_AGGREGATING_LATER
|
|
|
|
|
|
|
|
if test $# = 0 -o "$1" = -- -o -f "$1"; then
|
|
|
|
set -- . "$@"
|
|
|
|
fi
|
|
|
|
|
2018-01-05 10:12:24 +01:00
|
|
|
codespeed_opt=
|
|
|
|
test "$GIT_PERF_CODESPEED_OUTPUT" = "true" && codespeed_opt="--codespeed"
|
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
run_dirs "$@"
|
2018-01-05 10:12:25 +01:00
|
|
|
|
|
|
|
if test -z "$GIT_PERF_SEND_TO_CODESPEED"
|
|
|
|
then
|
|
|
|
./aggregate.perl $codespeed_opt "$@"
|
|
|
|
else
|
|
|
|
json_res_file="test-results/$GIT_PERF_SUBSECTION/aggregate.json"
|
|
|
|
./aggregate.perl --codespeed "$@" | tee "$json_res_file"
|
|
|
|
send_data_url="$GIT_PERF_SEND_TO_CODESPEED/result/add/json/"
|
|
|
|
curl -v --request POST --data-urlencode "json=$(cat "$json_res_file")" "$send_data_url"
|
|
|
|
fi
|
2017-09-23 21:55:56 +02:00
|
|
|
}
|
2012-02-17 11:25:09 +01:00
|
|
|
|
2018-01-05 10:12:24 +01:00
|
|
|
get_var_from_env_or_config "GIT_PERF_CODESPEED_OUTPUT" "perf" "codespeedOutput" "--bool"
|
2018-01-05 10:12:25 +01:00
|
|
|
get_var_from_env_or_config "GIT_PERF_SEND_TO_CODESPEED" "perf" "sendToCodespeed"
|
2018-01-05 10:12:24 +01:00
|
|
|
|
2012-02-17 11:25:09 +01:00
|
|
|
cd "$(dirname $0)"
|
|
|
|
. ../../GIT-BUILD-OPTIONS
|
|
|
|
|
2017-09-23 21:55:56 +02:00
|
|
|
mkdir -p test-results
|
|
|
|
get_subsections "perf" >test-results/run_subsections.names
|
|
|
|
|
|
|
|
if test $(wc -l <test-results/run_subsections.names) -eq 0
|
|
|
|
then
|
2018-04-08 11:35:12 +02:00
|
|
|
if test -n "$GIT_PERF_SUBSECTION"
|
|
|
|
then
|
|
|
|
if test -n "$GIT_PERF_CONFIG_FILE"
|
|
|
|
then
|
|
|
|
die "no subsections are defined in config file '$GIT_PERF_CONFIG_FILE'"
|
|
|
|
else
|
|
|
|
die "subsection '$GIT_PERF_SUBSECTION' defined without a config file"
|
|
|
|
fi
|
|
|
|
fi
|
2017-09-23 21:55:56 +02:00
|
|
|
(
|
|
|
|
run_subsection "$@"
|
|
|
|
)
|
2018-04-08 11:35:12 +02:00
|
|
|
elif test -n "$GIT_PERF_SUBSECTION"
|
|
|
|
then
|
|
|
|
egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names >/dev/null ||
|
|
|
|
die "subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'"
|
|
|
|
|
|
|
|
egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names | while read -r subsec
|
|
|
|
do
|
|
|
|
(
|
|
|
|
GIT_PERF_SUBSECTION="$subsec"
|
|
|
|
export GIT_PERF_SUBSECTION
|
|
|
|
echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========"
|
|
|
|
run_subsection "$@"
|
|
|
|
)
|
|
|
|
done
|
2017-09-23 21:55:56 +02:00
|
|
|
else
|
|
|
|
while read -r subsec
|
|
|
|
do
|
|
|
|
(
|
|
|
|
GIT_PERF_SUBSECTION="$subsec"
|
|
|
|
export GIT_PERF_SUBSECTION
|
|
|
|
echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========"
|
|
|
|
run_subsection "$@"
|
|
|
|
)
|
|
|
|
done <test-results/run_subsections.names
|
2012-02-17 11:25:09 +01:00
|
|
|
fi
|