summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorTrevor Gamblin <trevor.gamblin@windriver.com>2020-02-25 09:11:15 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-24 14:10:08 +0100
commit691f8c5fc8f2b63a85b87b40592e3596072c6748 (patch)
treebbe91747dbd9db94de58df69e5ae5411ca927317 /scripts
parentda0ab97f6104e63aa5e822f57eef8dfc3b524941 (diff)
downloadpoky-691f8c5fc8f2b63a85b87b40592e3596072c6748.tar.gz
buildall-qemu: automate build testing for qemu MACHINEs
buildall-qemu simplifies the process of build testing an upgraded or patched recipe by cycling through the build steps for each available qemu target, with desired LIBC specified by the user as an option (defaulting to both glibc and musl if no option is provided). While building, a log file with the name "<recipe>-buildall.log" is written, containing a PASS or FAIL line upon completion of the build for each architecture. For now, qemu targets are not selectable (i.e. the recipe is built for all qemu targets found in meta/conf/machine), but this functionality can be added in the future along with other useful options. The log file created by buildall-qemu also includes some basic system info (e.g. build start time, hostname, host OS, host kernel). Since it is not guaranteed that tools such as lsb_release will be available on the host (it isn't by default on my Fedora machine), this information is collected manually. Additionally, the previous run's log is retained for comparison by renaming it in the format <recipe>-buildall.log.old once a new set of builds is triggered for the same recipe. We've seen multiple variations of this concept in use as one-liners and as bash functions in dotfiles, so it seemed appropriate to submit it in script form to oe-core for everyone to use. Sample log output: BUILDALL-QEMU LOG FOR aspell START TIME: 2020-02-11_19:50:02 HOSTNAME: yow-tgamblin-fedora2 HOST OS: Fedora 31 (Server Edition) HOST KERNEL: 5.4.10-200.fc31.x86_64 =============== BUILD RESULTS: [glibc] PASS: qemuarmv5 PASS: qemux86 PASS: qemuppc PASS: qemumips64 PASS: qemux86-64 PASS: qemumips PASS: qemuarm PASS: qemuarm64 PASS: qemuriscv64 [musl] PASS: qemuarmv5 PASS: qemux86 PASS: qemuppc PASS: qemumips64 PASS: qemux86-64 FAIL: qemumips FAIL: qemuarm FAIL: qemuarm64 FAIL: qemuriscv64 =============== PASSED: 14 FAILED: 4 (From OE-Core rev: ee64b7db6651df4ed419e3d2649b4fb2f2faf830) Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/buildall-qemu120
1 files changed, 120 insertions, 0 deletions
diff --git a/scripts/buildall-qemu b/scripts/buildall-qemu
new file mode 100755
index 0000000000..ca9aafadf7
--- /dev/null
+++ b/scripts/buildall-qemu
@@ -0,0 +1,120 @@
1#!/bin/sh
2# Copyright (c) 2020 Wind River Systems, Inc.
3#
4# SPDX-License-Identifier: GPL-2.0-only
5#
6# buildall-qemu: a tool for automating build testing of recipes
7# TODO: Add support for selecting which qemu architectures to build
8# TODO: Add support for queueing up multiple recipe builds
9# TODO: Add more logging options (e.g. local.conf info, bitbake env info)
10
11usage ()
12{
13 base=$(basename "$0")
14 echo "Usage: $base [options] [recipename/target]"
15 echo "Executes a build of a given target for selected LIBCs. With no options, default to both libc and musl."
16 echo "Options:"
17 echo "-l, --libc Specify one of \"glibc\" or \"musl\""
18}
19
20
21buildall ()
22{
23 # Get path to oe-core directory. Since oe-init-build-env prepends $PATH with
24 # the path to the scripts directory, get it from there
25 SCRIPTS_PATH="$(echo "$PATH" | cut -d ":" -f 1)"
26 OE_CORE_PATH=$(echo "$SCRIPTS_PATH" | sed 's|\(.*\)/.*|\1|')
27
28 # Get target list and host machine information
29 TARGET_LIST=$(find "$OE_CORE_PATH"/meta/conf/machine -maxdepth 1 -type f | grep qemu | sed 's|.*/||' | sed -e 's/\.conf//')
30
31 # Set LIBC value to use for the builds based on options provided by the user
32 if [ -n "$2" ]
33 then
34 LIBC_LIST="$2"
35 echo "$LIBC_LIST"
36 else
37 LIBC_LIST="glibc musl"
38 echo "$LIBC_LIST"
39 fi
40
41 START_TIME=$(date "+%Y-%m-%d_%H:%M:%S")
42 LOG_FILE="$1-buildall.log"
43 OS_INFO=$(grep "PRETTY_NAME=" /etc/os-release | awk -F "=" '{print $2}' | sed -e 's/^"//' -e 's/"$//')
44
45 # Append an existing log file for this build with .old if one exists
46 if [ -f "${LOG_FILE}" ]
47 then
48 mv "${LOG_FILE}" "${LOG_FILE}.old"
49 else
50 touch "${LOG_FILE}"
51 fi
52
53 # Fill the log file with build and host info
54 echo "BUILDALL-QEMU LOG FOR $1" >> "${LOG_FILE}"
55 echo "START TIME: ${START_TIME}" >> "${LOG_FILE}"
56 echo "HOSTNAME: $(uname -n)" >> "${LOG_FILE}"
57 echo "HOST OS: ${OS_INFO}" >> "${LOG_FILE}"
58 echo "HOST KERNEL: $(uname -r)" >> "${LOG_FILE}"
59 echo "===============" >> "${LOG_FILE}"
60 echo "BUILD RESULTS:" >> "${LOG_FILE}"
61
62 # start the builds for each MACHINE and TCLIBC
63 for j in ${LIBC_LIST}
64 do
65 echo "[$j]" >> "${LOG_FILE}"
66 for i in ${TARGET_LIST}
67 do
68 echo "$i" "$j"; \
69 TCLIBC=$j MACHINE=$i bitbake "$1" && echo "PASS: $i" >> "${LOG_FILE}" || echo "FAIL: $i" >> "${LOG_FILE}"
70 done
71 done
72
73 # Get pass/fail totals and add them to the end of the log
74 PASSED=$(grep "PASS:" "${LOG_FILE}" | wc -l)
75 FAILED=$(grep "FAIL:" "${LOG_FILE}" | wc -l)
76
77 echo "===============" >> "${LOG_FILE}"
78 echo "PASSED: ${PASSED}" >> "${LOG_FILE}"
79 echo "FAILED: ${FAILED}" >> "${LOG_FILE}"
80}
81
82
83# fail entire script if any command fails
84set -e
85
86# print usage and exit if not enough args given
87[ $# -eq 0 ] && usage && exit 1
88
89# handle arguments
90RECIPE=
91while [ $# -gt 0 ]
92do
93 arg=$1
94 case $arg in
95 -l|--libc)
96 if [ "$2" = "glibc" ] || [ "$2" = "musl" ]
97 then
98 LIBC_LIST="$2"
99 else
100 echo "Unrecognized libc option."
101 usage && exit 1
102 fi
103 shift
104 shift
105 ;;
106 *)
107 RECIPE="$1"
108 shift
109 ;;
110 esac
111done
112
113set -- "$RECIPE"
114
115# run buildall for the given recipe and LIBC
116if [ -n "$1" ]
117then
118 buildall "$1" "$LIBC_LIST"
119fi
120