Skip to content

Commit 78b1a8a

Browse files
committed
tools/docker: Add Docker image support for devlib
Introduce a Dockerfile in order to create Docker image for devlib and ``run_tests.sh`` script to test Android, Linux, LocalLinux, and QEMU targets on the Docker image. The Dockerfile forks from ``Ubuntu-22.04``, installs required system packages, checks out ``master`` branch of devlib, installs devlib, creates Android virtual devices via ``tools/android/install_base.sh``, and QEMU images for aarch64 and x86_84 architectures. Note that Android command line tools version, buildroot and devlib branches can be customized via environment variables. Signed-off-by: Metin Kaya <metin.kaya@arm.com>
1 parent b8a9cb9 commit 78b1a8a

File tree

4 files changed

+183
-0
lines changed

4 files changed

+183
-0
lines changed

doc/tools.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,27 @@ system, you may want to run commands similar to these:
8383
8484
See https://buildroot.org/downloads/manual/manual.html for details.
8585

86+
Docker support
87+
--------------
88+
89+
A Docker image for devlib can be created via ``tools/docker/Dockerfile``.
90+
91+
Once the Docker image is run, ``tools/docker/run_tests.sh`` script can execute
92+
tests for Android, Linux, LocalLinux, and QEMU targets.
93+
94+
The Dockerfile forks from ``Ubuntu-22.04``, installs required system packages,
95+
checks out ``master`` branch of devlib, installs devlib, creates Android
96+
virtual devices via ``tools/android/install_base.sh``, and QEMU images for
97+
aarch64 and x86_84 architectures.
98+
99+
Version Android command line tools (``CMDLINE_VERSION``), buildroot
100+
(``BUILDROOT_VERSION``) and devlib (``DEVLIB_REF``) branches can be customized
101+
for the Docker image via aforementioned environment variables.
102+
103+
.. code:: shell
104+
105+
cd tools/docker
106+
docker build -t devlib .
107+
docker run -it --privileged devlib
108+
/devlib/tools/docker/run_tests.sh
109+

tools/docker/Dockerfile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Copyright (C) 2024, ARM Limited and contributors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# This Dockerfile creates an image to run devlib CI tests.
18+
#
19+
# Running ``docker build -t devlib .`` command in ``tools/docker`` directory
20+
# creates the docker image.
21+
#
22+
# The image can be runned via ``docker run -it --privileged devlib`` command.
23+
#
24+
25+
FROM ubuntu:22.04
26+
27+
ENV DEBIAN_FRONTEND noninteractive
28+
29+
ENV DEVLIB_REF master
30+
31+
RUN apt-get update && \
32+
apt-get install -y --no-install-recommends \
33+
aapt \
34+
bc \
35+
bison \
36+
build-essential \
37+
cmake \
38+
cpio \
39+
file \
40+
flex \
41+
git \
42+
libelf-dev \
43+
libncurses5-dev \
44+
libssl-dev \
45+
locales \
46+
python3-pip \
47+
qemu-system-arm \
48+
qemu-system-x86 \
49+
rsync \
50+
sudo \
51+
unzip \
52+
wget \
53+
vim \
54+
xz-utils
55+
56+
RUN apt-get -y autoremove && \
57+
apt-get -y autoclean && \
58+
apt-get clean && \
59+
rm -rf /var/cache/apt
60+
61+
RUN git clone -b ${DEVLIB_REF} -v https://github.com/ARM-software/devlib.git /devlib
62+
RUN cd /devlib && pip install .[full]
63+
64+
# Set CMDLINE_VERSION environment variable if you want to use a specific
65+
# version of Android command line tools rather than default which is
66+
# ``11076708`` as of writing this comment.
67+
RUN cd /devlib/tools/android && ./install_base.sh
68+
69+
# Set BUILDROOT_VERSION environment variable if you want to use a specific
70+
# branch of buildroot rather than default which is ``2023.11.1`` as of
71+
# writing this comment.
72+
RUN cd /devlib/tools/buildroot && \
73+
./generate-kernel-initrd.sh && \
74+
./generate-kernel-initrd.sh -a x86_64
75+

tools/docker/run_tests.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Copyright (C) 2024, ARM Limited and contributors.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8+
# not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
# Prepare the groundwork and run tests/test_target.py on the Docker image.
20+
#
21+
22+
set -eu
23+
24+
ANDROID_HOME="/devlib/tools/android/android-sdk-linux"
25+
export ANDROID_HOME
26+
export ANDROID_USER_HOME="${ANDROID_HOME}/.android"
27+
export ANDROID_EMULATOR_HOME="${ANDROID_HOME}/.android"
28+
export PATH=${ANDROID_HOME}/platform-tools/:${PATH}
29+
30+
EMULATOR="${ANDROID_HOME}/emulator/emulator"
31+
EMULATOR_ARGS="-no-window -no-snapshot -memory 2048"
32+
${EMULATOR} -avd devlib-p6-12 ${EMULATOR_ARGS} &
33+
${EMULATOR} -avd devlib-p6-14 ${EMULATOR_ARGS} &
34+
${EMULATOR} -avd devlib-chromeos ${EMULATOR_ARGS} &
35+
36+
echo "Waiting 30 seconds for Android virtual devices to finish boot up..."
37+
sleep 30
38+
39+
cd /devlib
40+
cp -f tools/docker/target_configs.yaml tests/
41+
python3 -m pytest -v -s ./tests/test_target.py

tools/docker/target_configs.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
AndroidTarget:
2+
# Android-12, Pixel-6
3+
entry-0:
4+
timeout: 60
5+
connection_settings:
6+
device: 'emulator-5554'
7+
8+
# Android-14, Pixel-6
9+
entry-1:
10+
connection_settings:
11+
device: 'emulator-5556'
12+
13+
# Android-13, Pixel tablet
14+
entry-2:
15+
connection_settings:
16+
device: 'emulator-5558'
17+
18+
LocalLinuxTarget:
19+
entry-0:
20+
connection_settings:
21+
unrooted: True
22+
23+
QEMUTargetRunner:
24+
entry-0:
25+
qemu_settings:
26+
kernel_image: '/devlib/tools/buildroot/buildroot-v2023.11.1-aarch64/output/images/Image'
27+
28+
ChromeOsTarget:
29+
connection_settings:
30+
device: 'emulator-5558'
31+
32+
entry-1:
33+
connection_settings:
34+
'port' : 8023
35+
36+
qemu_settings:
37+
kernel_image: '/devlib/tools/buildroot/buildroot-v2023.11.1-x86_64/output/images/bzImage'
38+
arch: 'x86_64'
39+
cmdline: 'console=ttyS0'
40+
41+
ChromeOsTarget:
42+
connection_settings:
43+
device: 'emulator-5558'

0 commit comments

Comments
 (0)