From patchwork Fri Sep 16 11:19: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: 1678631 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=EzDmebzA; 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 4MTWnS0P8bz1ypx for ; Fri, 16 Sep 2022 21:19:55 +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 1oZ9Nt-0008M0-D7; Fri, 16 Sep 2022 11:19:49 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oZ9Nr-0008LW-Bw for kernel-team@lists.ubuntu.com; Fri, 16 Sep 2022 11:19:47 +0000 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (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-1.canonical.com (Postfix) with ESMTPS id 342573F0E8 for ; Fri, 16 Sep 2022 11:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1663327187; bh=j0Y1KoZWcpTj+WhwGT3PFBFExgBuybtcdAulcLgluRc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EzDmebzAInaOhB4UVFOt4L/POosY0jh/9gK0xW5m4xrppL8ydUXWiemgcNc64Wv87 2khcw18Hg2Nl37g42aozE/JUqwMZxKgMSzFtufE65TZVpuNhzpEPv3b6BD3mM5Lnzf bNce5t736yKt3wfvxGNVLbroDoqzaq8Cw8L11HSGipmINf9N1QVnApWBTVpAd6uuTE MvUTcSvvgWKXNA65XF7dSBJzJGlccJzJiCw3NHtUd/yFtFG+PVPJy/DsiF4MYyF1JL mZuc9fLKMNaHmnfprm3MJMbtJzCMv1fH8Pv1zYVplaNoT8hF7CNHcED8eqY82hANo+ 42AYIg0O3Jnng== Received: by mail-qv1-f70.google.com with SMTP id oj15-20020a056214440f00b004ac6db57cacso14705114qvb.17 for ; Fri, 16 Sep 2022 04:19:47 -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=m4/AP/ZKwd9ZKldzGXPa7G5uQDiFTQXcN0/g+pbIy1mllmlarBJOthI/+iPL3zlTaV 8RLJ4Vb7iPt3p30MuQ509YCVi4GHJDwPZete9kj5hMNQDxpZpjI1uV4qt0oQ69pF5wm+ 99W90QCnXvRnhEctOIqxGR87wCltiX7IRp5MY04o72IhvFAJ9XtfwVYQfzsw7HV3UEOZ bJhpTkx9by78W0pnm99FP+30ogx163pG7U2aLE113/SK81diJFKBRyFPGWAWi+eQ4Nmt GwVx6dDEw9+zbBSgWBbjwLKuTD8MA/9cqVYMIgoTaq3V2LH8OXQuvTBweB7AMUvspY2W Gpog== X-Gm-Message-State: ACrzQf0OheBA8wqPBXW0D9CY/FaewivJW/wv4BwRiQBAeZSnkkmKGcbk aQV+28dnW0CqTsfA2A90zoz2fVPEvd5aa5liCSBToJZAmOMywF81mYykkJ0ztC5MjIOTLf6lSEG PXVEEJtwhFIYqP6aWqtQNeTdiG5RXUTXbcG1U9zJXAg== X-Received: by 2002:a05:6214:20a6:b0:4ac:ba17:e20f with SMTP id 6-20020a05621420a600b004acba17e20fmr3786873qvd.101.1663327185589; Fri, 16 Sep 2022 04:19:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gNjxFVRa4uuM7kf16ITbJV7UDejJCYpg32pMSjLxCUFn74p8bdhLH1PUiF6NLY6vTwk2XHQ== X-Received: by 2002:a05:6214:20a6:b0:4ac:ba17:e20f with SMTP id 6-20020a05621420a600b004acba17e20fmr3786859qvd.101.1663327185332; Fri, 16 Sep 2022 04:19:45 -0700 (PDT) Received: from portia-ThinkPad-T490.lan ([2001:67c:1562:8007::aac:42e5]) by smtp.googlemail.com with ESMTPSA id w28-20020a05622a191c00b00342f8984348sm4893574qtc.87.2022.09.16.04.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 04:19:44 -0700 (PDT) From: Portia Stephens To: kernel-team@lists.ubuntu.com Subject: [autotest-client-tests][PATCH 1/1 v2] UBUNTU: SAUCE: ubuntu_xilinx: Initial commit of Xilinx test suite Date: Fri, 16 Sep 2022 12:19:36 +0100 Message-Id: <20220916111936.132068-2-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916111936.132068-1-portia.stephens@canonical.com> References: <20220916111936.132068-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: