2016-04-26 12:51:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Build performance test script wrapper
|
|
|
|
#
|
|
|
|
# Copyright (c) 2016, Intel Corporation.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms and conditions of the GNU General Public License,
|
|
|
|
# version 2, as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
# more details.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This script is a simple wrapper around the actual build performance tester
|
|
|
|
# script. This script initializes the build environment, runs
|
|
|
|
# oe-build-perf-test and archives the results.
|
|
|
|
|
|
|
|
script=`basename $0`
|
2016-09-29 17:10:09 +00:00
|
|
|
archive_dir=~/perf-results/archives
|
|
|
|
|
2016-04-26 12:51:20 +00:00
|
|
|
usage () {
|
2016-08-19 10:48:58 +00:00
|
|
|
cat << EOF
|
|
|
|
Usage: $script [-h] [-c COMMITISH] [-C GIT_REPO]
|
|
|
|
|
|
|
|
Optional arguments:
|
|
|
|
-h show this help and exit.
|
2016-08-19 12:21:06 +00:00
|
|
|
-a ARCHIVE_DIR archive results tarball here, give an empty string to
|
2016-09-29 17:10:09 +00:00
|
|
|
disable tarball archiving (default: $archive_dir)
|
2016-08-19 10:48:58 +00:00
|
|
|
-c COMMITISH test (checkout) this commit
|
2016-08-19 11:57:56 +00:00
|
|
|
-C GIT_REPO commit results into Git
|
2016-08-19 13:18:55 +00:00
|
|
|
-w WORK_DIR work dir for this script
|
2016-09-29 17:10:09 +00:00
|
|
|
(default: GIT_TOP_DIR/build-perf-test)
|
2017-02-23 13:18:33 +00:00
|
|
|
-x create xml report (instead of json)
|
2016-08-19 10:48:58 +00:00
|
|
|
EOF
|
2016-04-26 12:51:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-19 10:48:58 +00:00
|
|
|
# Parse command line arguments
|
|
|
|
commitish=""
|
2017-02-23 13:18:33 +00:00
|
|
|
oe_build_perf_test_extra_opts=()
|
|
|
|
while getopts "ha:c:C:w:x" opt; do
|
2016-08-19 10:48:58 +00:00
|
|
|
case $opt in
|
|
|
|
h) usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2017-01-27 13:24:25 +00:00
|
|
|
a) archive_dir=`realpath -s "$OPTARG"`
|
2016-08-19 12:21:06 +00:00
|
|
|
;;
|
2016-08-19 10:48:58 +00:00
|
|
|
c) commitish=$OPTARG
|
|
|
|
;;
|
2017-02-03 17:53:55 +00:00
|
|
|
C) results_repo=`realpath -s "$OPTARG"`
|
2016-08-19 11:57:56 +00:00
|
|
|
;;
|
2017-01-27 13:24:25 +00:00
|
|
|
w) base_dir=`realpath -s "$OPTARG"`
|
2016-08-19 13:18:55 +00:00
|
|
|
;;
|
2017-02-23 13:18:33 +00:00
|
|
|
x) oe_build_perf_test_extra_opts+=("--xml")
|
|
|
|
;;
|
2016-08-19 10:48:58 +00:00
|
|
|
*) usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2016-04-26 12:51:20 +00:00
|
|
|
|
2016-09-29 17:10:08 +00:00
|
|
|
# Check positional args
|
|
|
|
shift "$((OPTIND - 1))"
|
|
|
|
if [ $# -ne 0 ]; then
|
|
|
|
echo "ERROR: No positional args are accepted."
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-02-02 10:42:12 +00:00
|
|
|
# Open a file descriptor for flock and acquire lock
|
|
|
|
LOCK_FILE="/tmp/oe-build-perf-test-wrapper.lock"
|
|
|
|
if ! exec 3> "$LOCK_FILE"; then
|
|
|
|
echo "ERROR: Unable to open lock file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if ! flock -n 3; then
|
|
|
|
echo "ERROR: Another instance of this script is running"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-08-19 10:48:58 +00:00
|
|
|
echo "Running on `uname -n`"
|
2016-04-26 12:51:20 +00:00
|
|
|
if ! git_topdir=$(git rev-parse --show-toplevel); then
|
|
|
|
echo "The current working dir doesn't seem to be a git clone. Please cd there before running `basename $0`"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$git_topdir"
|
|
|
|
|
|
|
|
if [ -n "$commitish" ]; then
|
|
|
|
# Checkout correct revision
|
|
|
|
echo "Checking out $commitish"
|
|
|
|
git fetch &> /dev/null
|
|
|
|
git checkout HEAD^0 &> /dev/null
|
|
|
|
git branch -D $commitish &> /dev/null
|
|
|
|
if ! git checkout -f $commitish &> /dev/null; then
|
|
|
|
echo "Git checkout failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup build environment
|
2016-08-19 13:18:55 +00:00
|
|
|
if [ -z "$base_dir" ]; then
|
|
|
|
base_dir="$git_topdir/build-perf-test"
|
|
|
|
fi
|
|
|
|
echo "Using working dir $base_dir"
|
|
|
|
|
2016-04-26 12:51:20 +00:00
|
|
|
timestamp=`date "+%Y%m%d%H%M%S"`
|
|
|
|
git_rev=$(git rev-parse --short HEAD) || exit 1
|
|
|
|
build_dir="$base_dir/build-$git_rev-$timestamp"
|
|
|
|
results_dir="$base_dir/results-$git_rev-$timestamp"
|
|
|
|
globalres_log="$base_dir/globalres.log"
|
2016-08-19 11:57:56 +00:00
|
|
|
machine="qemux86"
|
2016-04-26 12:51:20 +00:00
|
|
|
|
|
|
|
mkdir -p "$base_dir"
|
|
|
|
source ./oe-init-build-env $build_dir >/dev/null || exit 1
|
|
|
|
|
|
|
|
# Additional config
|
|
|
|
auto_conf="$build_dir/conf/auto.conf"
|
2016-08-19 11:57:56 +00:00
|
|
|
echo "MACHINE = \"$machine\"" > "$auto_conf"
|
2016-04-26 12:51:20 +00:00
|
|
|
echo 'BB_NUMBER_THREADS = "8"' >> "$auto_conf"
|
|
|
|
echo 'PARALLEL_MAKE = "-j 8"' >> "$auto_conf"
|
|
|
|
echo "DL_DIR = \"$base_dir/downloads\"" >> "$auto_conf"
|
|
|
|
# Disabling network sanity check slightly reduces the variance of timing results
|
|
|
|
echo 'CONNECTIVITY_CHECK_URIS = ""' >> "$auto_conf"
|
|
|
|
# Possibility to define extra settings
|
|
|
|
if [ -f "$base_dir/auto.conf.extra" ]; then
|
|
|
|
cat "$base_dir/auto.conf.extra" >> "$auto_conf"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run actual test script
|
2016-09-30 10:06:07 +00:00
|
|
|
oe-build-perf-test --out-dir "$results_dir" \
|
|
|
|
--globalres-file "$globalres_log" \
|
2017-02-23 13:18:33 +00:00
|
|
|
"${oe_build_perf_test_extra_opts[@]}" \
|
2017-02-03 17:53:55 +00:00
|
|
|
--lock-file "$base_dir/oe-build-perf.lock"
|
|
|
|
|
|
|
|
# Commit results to git
|
|
|
|
if [ -n "$results_repo" ]; then
|
|
|
|
echo -e "\nArchiving results in $results_repo"
|
|
|
|
oe-git-archive \
|
|
|
|
--git-dir "$results_repo" \
|
|
|
|
--branch-name "{hostname}/{branch}/{machine}" \
|
|
|
|
--tag-name "{hostname}/{branch}/{machine}/{commit_count}-g{commit}/{tag_number}" \
|
2017-03-24 14:17:30 +00:00
|
|
|
--exclude "buildstats.json" \
|
|
|
|
--notes "buildstats/{branch_name}" "$results_dir/buildstats.json" \
|
2017-02-03 17:53:55 +00:00
|
|
|
"$results_dir"
|
|
|
|
fi
|
2016-09-30 10:06:07 +00:00
|
|
|
|
|
|
|
case $? in
|
|
|
|
1) echo "ERROR: oe-build-perf-test script failed!"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
2) echo "NOTE: some tests failed!"
|
|
|
|
;;
|
|
|
|
esac
|
2016-04-26 12:51:20 +00:00
|
|
|
|
|
|
|
echo -ne "\n\n-----------------\n"
|
|
|
|
echo "Global results file:"
|
|
|
|
echo -ne "\n"
|
|
|
|
|
|
|
|
cat "$globalres_log"
|
|
|
|
|
2016-08-19 12:21:06 +00:00
|
|
|
if [ -n "$archive_dir" ]; then
|
|
|
|
echo -ne "\n\n-----------------\n"
|
|
|
|
echo "Archiving results in $archive_dir"
|
|
|
|
mkdir -p "$archive_dir"
|
|
|
|
results_basename=`basename "$results_dir"`
|
|
|
|
results_dirname=`dirname "$results_dir"`
|
|
|
|
tar -czf "$archive_dir/`uname -n`-${results_basename}.tar.gz" -C "$results_dirname" "$results_basename"
|
|
|
|
fi
|
2016-04-26 12:51:20 +00:00
|
|
|
|
|
|
|
rm -rf "$build_dir"
|
|
|
|
rm -rf "$results_dir"
|
|
|
|
|
|
|
|
echo "DONE"
|