From patchwork Fri Sep 16 11:08:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1678626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=OQZeTZaj; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MTWXv55xvz1ynm for ; Fri, 16 Sep 2022 21:09:02 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oZ9DE-0007TG-PE; Fri, 16 Sep 2022 11:08:48 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oZ9DD-0007T2-0D for kernel-team@lists.ubuntu.com; Fri, 16 Sep 2022 11:08:47 +0000 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 1B0213F37D for ; Fri, 16 Sep 2022 11:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1663326526; bh=j0Y1KoZWcpTj+WhwGT3PFBFExgBuybtcdAulcLgluRc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OQZeTZajBs9dTH9pEVJW+o5n2U+V0PVSEUeNl2zc05ZYneiDDA2fQpVarZdIF5naR ryTz5kPz2Zp8YeoSSzfDzeTZ5kxTOvFKOXxUnSObuu6M+IqkFbzdETn6dQW3rQF2Ni gfpjg8bD/JgB05LFKe1P/gixazXDqhXhfM7aVu9vyZ1s7M4/tLbX53lGE70ukdKdSr w5kJxZyTvS3xROPhxxCav30oN76JL8wC1Js0M0sO1+zPeur+QE/qi1DRy1KiO1EQAp 1I9eCKgLGYwqo3qd+66hFUu/DyiOj1gNE916F3fOe+h70+v+mhCFD1lDgqhsDefTyI u9GhJk+/A2bRQ== Received: by mail-qk1-f199.google.com with SMTP id br14-20020a05620a460e00b006cec4af5a2fso989044qkb.2 for ; Fri, 16 Sep 2022 04:08:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=j0Y1KoZWcpTj+WhwGT3PFBFExgBuybtcdAulcLgluRc=; b=dvXcdIbsqRBTTdNCduZgCzCnHeMpqdU1941m0UnFY57W1lWJwTNHqFv2/HbgU/ucHL LUgwfv11H2f288pc3rJER90bUuA8mZE4KUkKDaNs5pnSsyyaLEFdTMv1lVFw4APP0Fc6 H10a6FkwbFZMzJWXaV42S5Mj7hATBm10rkaEYvP/wV6jYUrsnZAUXelOkHGKxL3AydT9 D+s/eRkbSDDJ9zYbMO1XUPIzJwwK0kOICjja88BXMjhnPM/SCu0/c8ztjEqke6n2/Sc5 1iVVCqWTv9Sj3RXhGzSCDUWSciWP6cj5rgCE32MnGL2ty4PalEndbhNfJyDe+TNQ9U6T JNxg== X-Gm-Message-State: ACrzQf0EHJiBw6Kn6Z6X3LPcJtSuvOUe/wwSHF+m9JQTbvDPrf2uW7pg OZAdbaZHydZfbLmHs/ZHE/31oqRHBMwSFeZTB12wkSoca5m9n4VUVeERW8goJQV5FwlbGHhzuAr l0bZNSt+ss1L1rVPA8Fa01b6KuTZVs18UFcd04yvBDQ== X-Received: by 2002:a05:620a:b0c:b0:6ce:61a2:3f20 with SMTP id t12-20020a05620a0b0c00b006ce61a23f20mr3305863qkg.551.1663326524373; Fri, 16 Sep 2022 04:08:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ky3YfPO4/VKbrwIM6FzqpAaYMdzY1XZBRXTPaw/ptJ8nwPBRod/1Ij1AlwBZZHRgK8NMVPQ== X-Received: by 2002:a05:620a:b0c:b0:6ce:61a2:3f20 with SMTP id t12-20020a05620a0b0c00b006ce61a23f20mr3305848qkg.551.1663326524122; Fri, 16 Sep 2022 04:08:44 -0700 (PDT) Received: from portia-ThinkPad-T490.lan ([2001:67c:1562:8007::aac:42e5]) by smtp.googlemail.com with ESMTPSA id 79-20020a370452000000b006ce441816e0sm5840885qke.15.2022.09.16.04.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 04:08:43 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1] UBUNTU: SAUCE: ubuntu_xilinx: Initial commit of Xilinx test suite Date: Fri, 16 Sep 2022 12:08:36 +0100 Message-Id: <20220916110836.130666-2-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916110836.130666-1-portia.stephens@canonical.com> References: <20220916110836.130666-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" This contains the initial code for ubuntu_xilinx tests. It contains one test splat which checks for kernel errors. Signed-off-by: Portia Stephens --- ubuntu_xilinx/control | 17 +++ ubuntu_xilinx/lib/run-test | 202 +++++++++++++++++++++++++++++++++ ubuntu_xilinx/tests/splat | 25 ++++ ubuntu_xilinx/ubuntu_xilinx.py | 14 +++ 4 files changed, 258 insertions(+) create mode 100644 ubuntu_xilinx/control create mode 100755 ubuntu_xilinx/lib/run-test create mode 100755 ubuntu_xilinx/tests/splat create mode 100644 ubuntu_xilinx/ubuntu_xilinx.py diff --git a/ubuntu_xilinx/control b/ubuntu_xilinx/control new file mode 100644 index 00000000..b56d00f4 --- /dev/null +++ b/ubuntu_xilinx/control @@ -0,0 +1,17 @@ +AUTHOR = "Ubuntu" +NAME = "ubuntu_xilinx" +CRITERIA = """ +Uses the linux-xilinx-zynqmp kernel repo +""" +SUITE = "None" +TIME = "SHORT" +TEST_CLASS = 'kernel' +TEST_CATEGORY = 'Functional' +TEST_TYPE = "client" +DOC = "" + +tests_dir = os.path.join(job.bindir, 'tests', NAME, 'tests') +tests_list = os.listdir(tests_dir) +tests_list.sort() +for test in tests_list: + job.run_test_detail(NAME, test_name=test, tag=test, timeout=60*5) diff --git a/ubuntu_xilinx/lib/run-test b/ubuntu_xilinx/lib/run-test new file mode 100755 index 00000000..bf05d82e --- /dev/null +++ b/ubuntu_xilinx/lib/run-test @@ -0,0 +1,202 @@ +#!/bin/bash +# +# Wrapper script to run a Xilinx SoC regression test (RT) +# This script was copied and modified from: +# https://git.launchpad.net/~juergh/+git/raspi-rt +# +# The following global variables are available to the test scripts: +# RT_TEST_NAME - The name of the test being run +# RT_UNAME - System information (uname -a) +# RT_OS_CODENAME - The codename of the OS (bionic, focal, ...) +# RT_XILINX_MODEL - Xilinx SoC full model name +# RT_XILINX_BOARD - Xilinx board (KV260, KR260, ZCU102, ...) +# RT_XILINX_REV - Xilinx SoC odel revision (1, 2, A, ...) +# +# The following are global variables that can be defined by tests: +# RT_TEMP_FILE - If non-empty, will be deleted when the test terminates. +# + +set -e +set -u + +# ----------------------------------------------------------------------------- +# Public functions +# +# All public functions start with 'rt_' +# + +function rt_echo() +{ + echo "[${RT_TEST_NAME}] ${*}" +} + +function rt_fail() +{ + rt_echo "Test failure: ${*}" >&2 +} + +function rt_assert() +{ + local val1=${1} val2=${2} msg=${3} + + if [ "${val1}" != "${val2}" ] ; then + rt_fail "${msg}" + rt_fail "${val1} != ${val2}" + return 1 + fi +} + +function rt_reboot_required() +{ + touch "${_RT_REBOOT_FLAG}" + return 126 +} + +# ----------------------------------------------------------------------------- +# Private functions +# +# All private functions start with '_' +# + +function _out() +{ + local rc=${?} + + trap - EXIT INT TERM HUP + + # Cleanup after the test + if [ -n "${RT_TEMP_FILE:-}" ] ; then + rm -f "${RT_TEMP_FILE}" + fi + + if [ "${_RT_PRINT_TEST_RESULT}" -eq 1 ] ; then + case "${rc}" in + 0) rt_echo "Test result: PASSED" ;; + 125) rt_echo "Test result: SKIPPED" ;; + 126) rt_echo "Test result: REBOOT_REQUIRED" ;; + *) rt_echo "Test result: FAILED" >&2 ;; + esac + fi + + exit "${rc}" +} + +function _set_globals() +{ + # Test name + RT_TEST_NAME=$(basename "${0}") + + # Print a test result string at the end + _RT_PRINT_TEST_RESULT=1 + + # Check for empty globals + _RT_CHECK_EMPTY_GLOBALS=1 + + # Per-test reboot flag + _RT_REBOOT_FLAG=/tmp/xilinx-rt.reboot.${RT_TEST_NAME} + + # OS Codename + RT_OS_CODENAME=$(lsb_release -s -c) + RT_OS_CODENAME=${RT_OS_CODENAME,,} + RT_OS_CODENAME=${RT_OS_CODENAME^} + + # System information + RT_UNAME=$(uname -a) + + # Boot directory + if [ -d /boot/firmware ] ; then + RT_BOOT_DIR=/boot/firmware + else + RT_BOOT_DIR=/boot + fi + + # shellcheck disable=SC2002 + RT_XILINX_MODEL=$(cat /proc/device-tree/model 2>/dev/null | \ + tr -d '\0\n') + + # Find the board + RT_XILINX_BOARD=$(cat /proc/device-tree/compatible | grep -ao kv260 | head -1) + RT_XILINX_BOARD="$RT_XILINX_BOARD $(cat /proc/device-tree/compatible | grep -ao kr260 | head -1)" + RT_XILINX_BOARD="$RT_XILINX_BOARD $(cat /proc/device-tree/compatible | grep -ao zcu102 | head -1)" + RT_XILINX_BOARD="$RT_XILINX_BOARD $(cat /proc/device-tree/compatible | grep -ao zcu104 | head -1)" + RT_XILINX_BOARD="$RT_XILINX_BOARD $(cat /proc/device-tree/compatible | grep -ao zcu106 | head -1)" + + + # Compute the model revision + RT_XILINX_REV=${RT_XILINX_MODEL#* Rev} + + # Hack to silence shellcheck SC2034 + export RT_UNAME RT_BOOT_DIR RT_XILINX_REV \ + RT_XILINX_BOARD +} + +function _print_globals() +{ + local var error + + rt_echo "-- Globals --" + + error=0 + while IFS= read -r var ; do + if [ -z "${!var}" ] ; then + error=1 + fi + rt_echo "$(printf "%-22s: %s" "${var}" "${!var}")" + done < <(compgen -A variable | grep '^RT_') + + if [ "${_RT_CHECK_EMPTY_GLOBALS}" -eq 1 ] && [ "${error}" -ne 0 ] ; then + rt_fail "Empty global(s) found" + return 1 + fi +} + +function _run_test() +{ + # Bail out if a reboot is required + if [ -e "${_RT_REBOOT_FLAG}" ] ; then + rt_echo "A reboot is required to continue the test" + return 126 + fi + + if [ "$(type -t rt_test_setup)" = "function" ] ; then + rt_echo "-- Test setup --" + rt_test_setup + fi + + rt_echo "-- Test --" + rt_test + + if [ "$(type -t rt_test_cleanup)" = "function" ] ; then + rt_echo "-- Test cleanup --" + rt_test_cleanup + fi + + rt_echo "-- Test done --" +} + +# ----------------------------------------------------------------------------- +# Main entry point + +# Install a generic exit handler +trap _out EXIT INT TERM HUP + +# Set the globals +_set_globals + +case "${1:-}" in + ""|run) + # Print the globals and run the test + _print_globals + _run_test + ;; + globals) + # Print the globals + _RT_PRINT_TEST_RESULT=0 + _RT_CHECK_EMPTY_GLOBALS=0 + _print_globals + ;; + *) + echo "Invalid test command: ${1}" >&2 + exit 2 + ;; +esac diff --git a/ubuntu_xilinx/tests/splat b/ubuntu_xilinx/tests/splat new file mode 100755 index 00000000..165f86ec --- /dev/null +++ b/ubuntu_xilinx/tests/splat @@ -0,0 +1,25 @@ +#!/bin/bash +# +# splat: Check dmesg for kernel splats +# + +function rt_test() +{ + regexes=( + "---\[\scut\shere\s\]---" + "\sBUG:\s" + "\sCall trace:" + ) + regex=$(printf "%s|" "${regexes[@]}") + regex=${regex%|} + + if sudo dmesg | grep -qP -- "${regex}" ; then + rt_fail "Kernel errors found" + sudo dmesg + return 1 + fi +} + +root=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd) +# shellcheck disable=SC1090 +. "${root}"/lib/run-test diff --git a/ubuntu_xilinx/ubuntu_xilinx.py b/ubuntu_xilinx/ubuntu_xilinx.py new file mode 100644 index 00000000..af14a863 --- /dev/null +++ b/ubuntu_xilinx/ubuntu_xilinx.py @@ -0,0 +1,14 @@ +from autotest.client import test, utils +import os + +class ubuntu_xilinx(test.test): + version = 1 + + def initialize(self): + pass + + def run_once(self, test_name): + cmd = os.path.join(self.bindir, 'tests', test_name) + utils.system_output(cmd, retain_output=True) + +# vi:set ts=4 sw=4 expandtab syntax=python: