Skip to content

Commit

Permalink
tools/docker: Add Docker image support for devlib
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
metin-arm committed Mar 12, 2024
1 parent a1718c3 commit a8311dc
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 0 deletions.
27 changes: 27 additions & 0 deletions doc/tools.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Tools
=====

Docker support
--------------

A Docker image for devlib can be created via ``tools/docker/Dockerfile``.

Once the Docker image is run, ``tools/docker/run_tests.sh`` script can execute
tests for Android, Linux, LocalLinux, and QEMU targets.

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.

Version Android command line tools (``CMDLINE_VERSION``), buildroot
(``BUILDROOT_VERSION``) and devlib (``DEVLIB_REF``) branches can be customized
for the Docker image via aforementioned environment variables.

.. code:: shell
cd tools/docker
docker build -t devlib .
docker run -it --privileged devlib
/devlib/tools/docker/run_tests.sh
75 changes: 75 additions & 0 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2024, ARM Limited and contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This Dockerfile creates an image to run devlib CI tests.
#
# Running ``docker build -t devlib .`` command in ``tools/docker`` directory
# creates the docker image.
#
# The image can be runned via ``docker run -it --privileged devlib`` command.
#

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND noninteractive

ENV DEVLIB_REF master

RUN apt-get update && \
apt-get install -y --no-install-recommends \
aapt \
bc \
bison \
build-essential \
cmake \
cpio \
file \
flex \
git \
libelf-dev \
libncurses5-dev \
libssl-dev \
locales \
python3-pip \
qemu-system-arm \
qemu-system-x86 \
rsync \
sudo \
unzip \
wget \
vim \
xz-utils

RUN apt-get -y autoremove && \
apt-get -y autoclean && \
apt-get clean && \
rm -rf /var/cache/apt

RUN git clone -b ${DEVLIB_REF} -v https://github.com/ARM-software/devlib.git /devlib
RUN cd /devlib && pip install .[full]

# Set CMDLINE_VERSION environment variable if you want to use a specific
# version of Android command line tools rather than default which is
# ``11076708`` as of writing this comment.
RUN cd /devlib/tools/android && ./install_base.sh

# Set BUILDROOT_VERSION environment variable if you want to use a specific
# branch of buildroot rather than default which is ``2023.11.1`` as of
# writing this comment.
RUN cd /devlib/tools/buildroot && \
./generate-kernel-initrd.sh && \
./generate-kernel-initrd.sh -a x86_64

41 changes: 41 additions & 0 deletions tools/docker/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2024, ARM Limited and contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Prepare the groundwork and run tests/test_target.py on the Docker image.
#

set -eu

ANDROID_HOME="/devlib/tools/android/android-sdk-linux"
export ANDROID_HOME
export ANDROID_USER_HOME="${ANDROID_HOME}/.android"
export ANDROID_EMULATOR_HOME="${ANDROID_HOME}/.android"
export PATH=${ANDROID_HOME}/platform-tools/:${PATH}

EMULATOR="${ANDROID_HOME}/emulator/emulator"
EMULATOR_ARGS="-no-window -no-snapshot -memory 2048"
${EMULATOR} -avd devlib-p6-12 ${EMULATOR_ARGS} &
${EMULATOR} -avd devlib-p6-14 ${EMULATOR_ARGS} &
${EMULATOR} -avd devlib-chromeos ${EMULATOR_ARGS} &

echo "Waiting 30 seconds for Android virtual devices to finish boot up..."
sleep 30

cd /devlib
cp -f tools/docker/target_configs.yaml tests/
python3 -m pytest -v -s ./tests/test_target.py
42 changes: 42 additions & 0 deletions tools/docker/target_configs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
AndroidTarget:
# Android-12, Pixel-6
entry-0:
connection_settings:
device: 'emulator-5554'

# Android-14, Pixel-6
entry-1:
connection_settings:
device: 'emulator-5556'

# Android-13, Pixel tablet
entry-2:
connection_settings:
device: 'emulator-5558'

LocalLinuxTarget:
entry-0:
connection_settings:
unrooted: True

QEMUTargetRunner:
entry-0:
qemu_settings:
kernel_image: '/devlib/tools/buildroot/buildroot-v2023.11.1-aarch64/output/images/Image'

ChromeOsTarget:
connection_settings:
device: 'emulator-5558'

entry-1:
connection_settings:
'port' : 8023

qemu_settings:
kernel_image: '/devlib/tools/buildroot/buildroot-v2023.11.1-x86_64/output/images/bzImage'
arch: 'x86_64'
cmdline: 'console=ttyS0'

ChromeOsTarget:
connection_settings:
device: 'emulator-5558'

0 comments on commit a8311dc

Please sign in to comment.