blob: e03ea978b9f441fce669f2ff696d6719795317e0 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/bin/bash
2#
3# Build performance test script wrapper
4#
5# Copyright (c) 2016, Intel Corporation.
6#
7# This program is free software; you can redistribute it and/or modify it
8# under the terms and conditions of the GNU General Public License,
9# version 2, as published by the Free Software Foundation.
10#
11# This program is distributed in the hope it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14# more details.
15#
16#
17# This script is a simple wrapper around the actual build performance tester
18# script. This script initializes the build environment, runs
19# oe-build-perf-test and archives the results.
20
21script=`basename $0`
22archive_dir=~/perf-results/archives
23
24usage () {
25cat << EOF
26Usage: $script [-h] [-c COMMITISH] [-C GIT_REPO]
27
28Optional arguments:
29 -h show this help and exit.
30 -a ARCHIVE_DIR archive results tarball here, give an empty string to
31 disable tarball archiving (default: $archive_dir)
32 -c COMMITISH test (checkout) this commit
33 -C GIT_REPO commit results into Git
34 -w WORK_DIR work dir for this script
35 (default: GIT_TOP_DIR/build-perf-test)
36EOF
37}
38
39
40# Parse command line arguments
41commitish=""
42while getopts "ha:c:C:w:" opt; do
43 case $opt in
44 h) usage
45 exit 0
46 ;;
47 a) archive_dir=`realpath "$OPTARG"`
48 ;;
49 c) commitish=$OPTARG
50 ;;
51 C) results_repo=`realpath "$OPTARG"`
52 commit_results=("--commit-results" "$results_repo")
53 ;;
54 w) base_dir=`realpath "$OPTARG"`
55 ;;
56 *) usage
57 exit 1
58 ;;
59 esac
60done
61
62# Check positional args
63shift "$((OPTIND - 1))"
64if [ $# -ne 0 ]; then
65 echo "ERROR: No positional args are accepted."
66 usage
67 exit 1
68fi
69
70echo "Running on `uname -n`"
71if ! git_topdir=$(git rev-parse --show-toplevel); then
72 echo "The current working dir doesn't seem to be a git clone. Please cd there before running `basename $0`"
73 exit 1
74fi
75
76cd "$git_topdir"
77
78if [ -n "$commitish" ]; then
79 # Checkout correct revision
80 echo "Checking out $commitish"
81 git fetch &> /dev/null
82 git checkout HEAD^0 &> /dev/null
83 git branch -D $commitish &> /dev/null
84 if ! git checkout -f $commitish &> /dev/null; then
85 echo "Git checkout failed"
86 exit 1
87 fi
88fi
89
90# Setup build environment
91if [ -z "$base_dir" ]; then
92 base_dir="$git_topdir/build-perf-test"
93fi
94echo "Using working dir $base_dir"
95
96timestamp=`date "+%Y%m%d%H%M%S"`
97git_rev=$(git rev-parse --short HEAD) || exit 1
98build_dir="$base_dir/build-$git_rev-$timestamp"
99results_dir="$base_dir/results-$git_rev-$timestamp"
100globalres_log="$base_dir/globalres.log"
101machine="qemux86"
102
103mkdir -p "$base_dir"
104source ./oe-init-build-env $build_dir >/dev/null || exit 1
105
106# Additional config
107auto_conf="$build_dir/conf/auto.conf"
108echo "MACHINE = \"$machine\"" > "$auto_conf"
109echo 'BB_NUMBER_THREADS = "8"' >> "$auto_conf"
110echo 'PARALLEL_MAKE = "-j 8"' >> "$auto_conf"
111echo "DL_DIR = \"$base_dir/downloads\"" >> "$auto_conf"
112# Disabling network sanity check slightly reduces the variance of timing results
113echo 'CONNECTIVITY_CHECK_URIS = ""' >> "$auto_conf"
114# Possibility to define extra settings
115if [ -f "$base_dir/auto.conf.extra" ]; then
116 cat "$base_dir/auto.conf.extra" >> "$auto_conf"
117fi
118
119# Run actual test script
120oe-build-perf-test --out-dir "$results_dir" \
121 --globalres-file "$globalres_log" \
122 --lock-file "$base_dir/oe-build-perf.lock" \
123 "${commit_results[@]}" \
124 --commit-results-branch "{tester_host}/{git_branch}/$machine" \
125 --commit-results-tag "{tester_host}/{git_branch}/$machine/{git_commit_count}-g{git_commit}/{tag_num}"
126
127case $? in
128 1) echo "ERROR: oe-build-perf-test script failed!"
129 exit 1
130 ;;
131 2) echo "NOTE: some tests failed!"
132 ;;
133esac
134
135echo -ne "\n\n-----------------\n"
136echo "Global results file:"
137echo -ne "\n"
138
139cat "$globalres_log"
140
141if [ -n "$archive_dir" ]; then
142 echo -ne "\n\n-----------------\n"
143 echo "Archiving results in $archive_dir"
144 mkdir -p "$archive_dir"
145 results_basename=`basename "$results_dir"`
146 results_dirname=`dirname "$results_dir"`
147 tar -czf "$archive_dir/`uname -n`-${results_basename}.tar.gz" -C "$results_dirname" "$results_basename"
148fi
149
150rm -rf "$build_dir"
151rm -rf "$results_dir"
152
153echo "DONE"