From 10bf2a5ab4f87e64aed3758b7cf69d44d9c5c15b Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Mon, 17 Sep 2018 15:44:31 +0100 Subject: [PATCH 1/2] lisa_shell: add a new function to generate buildroot rootfs buildroot rootfs are a better choice to run lisa tests on as they are quieter and provide a minimal userspace that allows testing kernel functionality with minimum interference from userland. Also it is less of a maintanence burden as it's unlikely to find unexpected things configured without our knowledge that might intefere with some of the tests or skew their results. A recent example was found in systemd indirectly causing higher number of kthreads to run on debian and arch-linux distro's which caused random number of failure rates in cpu migration load tracking tests. Signed-off-by: Qais Yousef --- .gitignore | 1 + LisaShell.txt | 1 + src/shell/buildroot_config | 23 +++++ src/shell/lisa_buildroot_create_rootfs | 118 +++++++++++++++++++++++++ src/shell/lisa_shell | 8 ++ 5 files changed, 151 insertions(+) create mode 100644 src/shell/buildroot_config create mode 100755 src/shell/lisa_buildroot_create_rootfs diff --git a/.gitignore b/.gitignore index e86bc51e4..12bf15eb9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /vagrant /tools/wa_venv /tools/wa_user_directory/dependencies +src/buildroot diff --git a/LisaShell.txt b/LisaShell.txt index 1eb9fa538..7f231f952 100644 --- a/LisaShell.txt +++ b/LisaShell.txt @@ -10,6 +10,7 @@ For a longer description type "lisa- help" lisa-help - Print this help, or command specific helps lisa-version - Dump info on the LISA in use +lisa-buildroot-create-rootfs - Create a buildroot based rootfs to be used as userland for testing .:: Maintenance commands ------------------------ diff --git a/src/shell/buildroot_config b/src/shell/buildroot_config new file mode 100644 index 000000000..d32156fac --- /dev/null +++ b/src/shell/buildroot_config @@ -0,0 +1,23 @@ +BR2_arm=y +BR2_cortex_a53=y +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_KERNEL_HEADERS_4_9=y +BR2_TARGET_GENERIC_ROOT_PASSWD="root" +BR2_PACKAGE_LINUX_FIRMWARE=y +BR2_PACKAGE_LINUX_FIRMWARE_TI_WL18XX=y +BR2_PACKAGE_OPENSSH=y +BR2_PACKAGE_WPA_SUPPLICANT=y +BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y +BR2_PACKAGE_WPA_SUPPLICANT_WIFI_DISPLAY=y +BR2_PACKAGE_WPA_SUPPLICANT_MESH_NETWORKING=y +BR2_PACKAGE_WPA_SUPPLICANT_AUTOSCAN=y +BR2_PACKAGE_WPA_SUPPLICANT_EAP=y +BR2_PACKAGE_WPA_SUPPLICANT_HOTSPOT=y +BR2_PACKAGE_WPA_SUPPLICANT_DEBUG_SYSLOG=y +BR2_PACKAGE_WPA_SUPPLICANT_WPS=y +BR2_PACKAGE_WPA_SUPPLICANT_CLI=y +BR2_PACKAGE_WPA_SUPPLICANT_WPA_CLIENT_SO=y +BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y +BR2_TARGET_ROOTFS_CPIO=y +BR2_TARGET_ROOTFS_CPIO_XZ=y +# BR2_TARGET_ROOTFS_TAR is not set diff --git a/src/shell/lisa_buildroot_create_rootfs b/src/shell/lisa_buildroot_create_rootfs new file mode 100755 index 000000000..2e4e58e24 --- /dev/null +++ b/src/shell/lisa_buildroot_create_rootfs @@ -0,0 +1,118 @@ +#! /bin/bash +# +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2018, 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. +# +set -eu + +BUILDROOT_URI=git://git.busybox.net/buildroot +BUILDROOT_VERSION=2018.08 +BUILDROOT_DIR=$LISA_HOME/src/buildroot +BUILDROOT_CONFIG=$(dirname "$0")/buildroot_config + +function print_usage { + echo "Usage: $0 [options]" + echo " options:" + echo " -p: purge buildroot to force a fresh build" + echo " -h: print this help message" +} + +while getopts "hp" opt +do + case $opt in + h) + print_usage + exit 0 + ;; + p) + rm -rf "$BUILDROOT_DIR" + exit 0 + ;; + *) + print_usage + exit -1 + ;; + esac +done + +# Execute function @$1 once +function do_once { + FILE="$BUILDROOT_DIR/.lisa_$1" + if [ ! -e "$FILE" ]; then + "$1" + touch "$FILE" + fi +} + +function br_clone { + git clone $BUILDROOT_URI "$BUILDROOT_DIR" +} + +function br_checkout_version { + pushd "$BUILDROOT_DIR" >/dev/null + git checkout -b $BUILDROOT_VERSION $BUILDROOT_VERSION + popd >/dev/null +} + +function br_pre_patch { + pushd "$BUILDROOT_DIR" >/dev/null + + # Apply 'before build' changes here + + # Automount debugfs + echo "debugfs /sys/kernel/debug debugfs defaults 0 0" >> "$BUILDROOT_DIR/package/skeleton-init-sysv/skeleton/etc/fstab" + + popd >/dev/null +} + +function br_post_patch { + pushd "$BUILDROOT_DIR" >/dev/null + + # Apply 'post build' changes here + + # Generate ssh-keys so that they persist across multiple runs + ssh-keygen -A -f "$BUILDROOT_DIR/output/target/" + # Enable root login on sshd + sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' "$BUILDROOT_DIR/output/target/etc/ssh/sshd_config" + # run udhcpc by default at startup + echo "null::once:/sbin/udhcpc # PATCHED BY LISA" >> "$BUILDROOT_DIR/output/target/etc/inittab" + + popd >/dev/null + + # Rebuild to apply the changes + make -C "$BUILDROOT_DIR" +} + +function br_apply_config { + cp "$BUILDROOT_CONFIG" "$BUILDROOT_DIR/.config" + make -C "$BUILDROOT_DIR" olddefconfig +} + + +do_once br_clone + +do_once br_checkout_version + +do_once br_pre_patch + +do_once br_apply_config + +make -C "$BUILDROOT_DIR" + +do_once br_post_patch + +echo "---===::: RootFS Created :::===---" +echo "Path: $BUILDROOT_DIR/output/images/rootfs.cpio.xz" diff --git a/src/shell/lisa_shell b/src/shell/lisa_shell index 72594f7b9..6ec141284 100755 --- a/src/shell/lisa_shell +++ b/src/shell/lisa_shell @@ -527,6 +527,14 @@ $WLTEST_HOME/test_series "$@" deactivate } +################################################################################ +# LISA Shell buildroot rootfs generation functions +################################################################################ + +function lisa-buildroot-create-rootfs { + "$LISA_HOME/src/shell/lisa_buildroot_create_rootfs" "$@" +} + ################################################################################ # LISA Shell MAIN ################################################################################ -- GitLab From 810451747c8c1c59457c2cf435f1dba0f5688380 Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Fri, 9 Nov 2018 12:30:52 +0000 Subject: [PATCH 2/2] lisa_shell: add a new function to update kernel config for buildroot To help users build their kernels with the created buildroot rootfs, provide a command that will automatically update kernel config to use the new rootfs as initramfs. Signed-off-by: Qais Yousef --- src/shell/lisa_buildroot_update_kernel_config | 65 +++++++++++++++++++ src/shell/lisa_shell | 4 ++ 2 files changed, 69 insertions(+) create mode 100755 src/shell/lisa_buildroot_update_kernel_config diff --git a/src/shell/lisa_buildroot_update_kernel_config b/src/shell/lisa_buildroot_update_kernel_config new file mode 100755 index 000000000..145a7d316 --- /dev/null +++ b/src/shell/lisa_buildroot_update_kernel_config @@ -0,0 +1,65 @@ +#! /bin/bash +# +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2018, 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. +# +set -e + +BUILDROOT_DIR=$LISA_HOME/src/buildroot + +ROOTFS="$1" +KERNEL_DIR="$2" +KERNEL_CONFIG="$2/.config" + +function print_usage { + echo "Usage: $0 " + echo " options:" + echo " -h: print this help message" +} + +while getopts "hp" opt +do + case $opt in + h) + print_usage + exit 0 + ;; + *) + print_usage + exit -1 + ;; + esac +done + +if [[ -z "$1" || -z "$2" ]]; then + echo "ERROR: missing argument" + echo "" + print_usage + exit -1 +fi + +# Automatically detect the arm arch we are building for +ARCH="`grep -owE "(arm|arm64)" $KERNEL_CONFIG`" +if [ -z "$ARCH" ]; then + echo "ERROR: unknown arch, arm and arm64 are assumed" + exit -1 +fi + +set -u + +# Update kernel .config to use the provided rootfs as builtin initramfs +sed -i "s#[.]*CONFIG_INITRAMFS_SOURCE.*#CONFIG_INITRAMFS_SOURCE=\"$ROOTFS\"#" "$KERNEL_CONFIG" +make -C "$KERNEL_DIR" ARCH=$ARCH olddefconfig diff --git a/src/shell/lisa_shell b/src/shell/lisa_shell index 6ec141284..115cc6e50 100755 --- a/src/shell/lisa_shell +++ b/src/shell/lisa_shell @@ -535,6 +535,10 @@ function lisa-buildroot-create-rootfs { "$LISA_HOME/src/shell/lisa_buildroot_create_rootfs" "$@" } +function lisa-buildroot-update-kernel-config { + "$LISA_HOME/src/shell/lisa_buildroot_update_kernel_config" "$@" +} + ################################################################################ # LISA Shell MAIN ################################################################################ -- GitLab