Merge ~canonical-kernel-team/+git/autotest-client-tests:portias/xilinx into ~canonical-kernel-team/+git/autotest-client-tests:master

Proposed by Portia Stephens
Status: Merged
Merged at revision: 87f0881535dc5bbde8c351d7666416954c182633
Proposed branch: ~canonical-kernel-team/+git/autotest-client-tests:portias/xilinx
Merge into: ~canonical-kernel-team/+git/autotest-client-tests:master
Diff against target: 293 lines (+269/-0)
4 files modified
ubuntu_xilinx/control (+17/-0)
ubuntu_xilinx/lib/run-test (+222/-0)
ubuntu_xilinx/tests/xlnx-config (+16/-0)
ubuntu_xilinx/ubuntu_xilinx.py (+14/-0)
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Po-Hsu Lin Approve
Hsuan-Yu Lin Pending
Sean Feole Pending
Review via email: mp+430431@code.launchpad.net

Description of the change

This adds regression tests for the linux-xilinx-zynqmp/focal kernel. These tests are expected to run on Xilinx hardware, specifically kv260 and zcu boards. These scripts were copied and modified from the raspberry_pi regression tests. v1 and v2 of these scripts were send via email.

To post a comment you must log in.
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

LGTM.
Tested on ZCU102 and it works.
+1 here.

review: Approve
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Applied and pushed.
Let's get this rolling!

I will update the test plan in CKCT later.

Revision history for this message
Francis Ginther (fginther) wrote :

@cypressyew Thanks for reviewing and applying. I have no additional comments. LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/ubuntu_xilinx/control b/ubuntu_xilinx/control
0new file mode 1006440new file mode 100644
index 0000000..b56d00f
--- /dev/null
+++ b/ubuntu_xilinx/control
@@ -0,0 +1,17 @@
1AUTHOR = "Ubuntu"
2NAME = "ubuntu_xilinx"
3CRITERIA = """
4Uses the linux-xilinx-zynqmp kernel repo
5"""
6SUITE = "None"
7TIME = "SHORT"
8TEST_CLASS = 'kernel'
9TEST_CATEGORY = 'Functional'
10TEST_TYPE = "client"
11DOC = ""
12
13tests_dir = os.path.join(job.bindir, 'tests', NAME, 'tests')
14tests_list = os.listdir(tests_dir)
15tests_list.sort()
16for test in tests_list:
17 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
0new file mode 10075518new file mode 100755
index 0000000..652e6ef
--- /dev/null
+++ b/ubuntu_xilinx/lib/run-test
@@ -0,0 +1,222 @@
1#!/bin/bash
2#
3# Wrapper script to run a Xilinx SoC regression test (RT)
4# This script was copied and modified from:
5# https://git.launchpad.net/~juergh/+git/raspi-rt
6#
7# The following global variables are available to the test scripts:
8# RT_TEST_NAME - The name of the test being run
9# RT_UNAME - System information (uname -a)
10# RT_OS_CODENAME - The codename of the OS (bionic, focal, ...)
11# RT_XILINX_MODEL - Xilinx SoC full model name
12# RT_XILINX_BOARD - Xilinx board (KV260, KR260, ZCU102, ...)
13# RT_XILINX_REV - Xilinx SoC odel revision (1, 2, A, ...)
14#
15# The following are global variables that can be defined by tests:
16# RT_TEMP_FILE - If non-empty, will be deleted when the test terminates.
17#
18
19set -e
20set -u
21
22# -----------------------------------------------------------------------------
23# Public functions
24#
25# All public functions start with 'rt_'
26#
27
28function rt_echo()
29{
30 echo "[${RT_TEST_NAME}] ${*}"
31}
32
33function rt_fail()
34{
35 rt_echo "Test failure: ${*}" >&2
36}
37
38function rt_assert()
39{
40 local val1=${1} val2=${2} msg=${3}
41
42 if [ "${val1}" != "${val2}" ] ; then
43 rt_fail "${msg}"
44 rt_fail "${val1} != ${val2}"
45 return 1
46 fi
47}
48
49function rt_reboot_required()
50{
51 touch "${_RT_REBOOT_FLAG}"
52 return 126
53}
54
55# -----------------------------------------------------------------------------
56# Private functions
57#
58# All private functions start with '_'
59#
60
61function _out()
62{
63 local rc=${?}
64
65 trap - EXIT INT TERM HUP
66
67 # Cleanup after the test
68 if [ -n "${RT_TEMP_FILE:-}" ] ; then
69 rm -f "${RT_TEMP_FILE}"
70 fi
71
72 if [ "${_RT_PRINT_TEST_RESULT}" -eq 1 ] ; then
73 case "${rc}" in
74 0) rt_echo "Test result: PASSED" ;;
75 125) rt_echo "Test result: SKIPPED" ;;
76 126) rt_echo "Test result: REBOOT_REQUIRED" ;;
77 *) rt_echo "Test result: FAILED" >&2 ;;
78 esac
79 fi
80
81 exit "${rc}"
82}
83
84function _set_globals()
85{
86 # Test name
87 RT_TEST_NAME=$(basename "${0}")
88
89 # Print a test result string at the end
90 _RT_PRINT_TEST_RESULT=1
91
92 # Check for empty globals
93 _RT_CHECK_EMPTY_GLOBALS=1
94
95 # Per-test reboot flag
96 _RT_REBOOT_FLAG=/tmp/xilinx-rt.reboot.${RT_TEST_NAME}
97
98 # OS Codename
99 RT_OS_CODENAME=$(lsb_release -s -c)
100 RT_OS_CODENAME=${RT_OS_CODENAME,,}
101 RT_OS_CODENAME=${RT_OS_CODENAME^}
102
103 # System information
104 RT_UNAME=$(uname -a)
105
106 # Boot directory
107 if [ -d /boot/firmware ] ; then
108 RT_BOOT_DIR=/boot/firmware
109 else
110 RT_BOOT_DIR=/boot
111 fi
112
113 # shellcheck disable=SC2002
114 RT_XILINX_MODEL=$(cat /proc/device-tree/model 2>/dev/null | \
115 tr -d '\0\n')
116
117 # Find the board
118 if [ $(cat /proc/device-tree/compatible | grep -ao k26 | head -1) ] ; then
119 RT_XILINX_BOARD="kv260"
120 fi
121
122 if [ $(cat /proc/device-tree/compatible | grep -ao zcu102 | head -1) ] ; then
123 RT_XILINX_BOARD="zcu102"
124 fi
125
126 if [ $(cat /proc/device-tree/compatible | grep -ao zcu104 | head -1) ] ; then
127 RT_XILINX_BOARD="zcu104"
128 fi
129
130 if [ $(cat /proc/device-tree/compatible | grep -ao zcu106 | head -1) ] ; then
131 RT_XILINX_BOARD="zcu106"
132 fi
133
134
135 # Compute the model revision
136 RT_XILINX_REV=${RT_XILINX_MODEL#* Rev}
137
138 # Hack to silence shellcheck SC2034
139 export RT_UNAME RT_BOOT_DIR RT_XILINX_REV \
140 RT_XILINX_BOARD
141}
142
143function _print_globals()
144{
145 local var error
146
147 rt_echo "-- Globals --"
148
149 error=0
150 while IFS= read -r var ; do
151 if [ -z "${!var}" ] ; then
152 error=1
153 fi
154 rt_echo "$(printf "%-22s: %s" "${var}" "${!var}")"
155 done < <(compgen -A variable | grep '^RT_')
156
157 if [ "${_RT_CHECK_EMPTY_GLOBALS}" -eq 1 ] && [ "${error}" -ne 0 ] ; then
158 rt_fail "Empty global(s) found"
159 return 1
160 fi
161}
162
163function _run_test()
164{
165 # Bail out if a reboot is required
166 if [ -e "${_RT_REBOOT_FLAG}" ] ; then
167 rt_echo "A reboot is required to continue the test"
168 return 126
169 fi
170
171 if [ "$(type -t rt_test_setup)" = "function" ] ; then
172 rt_echo "-- Test setup --"
173 rt_test_setup
174 fi
175
176 rt_echo "-- Test --"
177 rt_test
178
179 if [ "$(type -t rt_test_cleanup)" = "function" ] ; then
180 rt_echo "-- Test cleanup --"
181 rt_test_cleanup
182 fi
183
184 rt_echo "-- Test done --"
185}
186
187function _install_deps()
188{
189 if [ ${RT_OS_CODENAME} == "Focal" ] ; then
190 rt_echo "Installing depedencies for Focal"
191 sudo snap install \
192 xlnx-config --classic --channel=1.x
193 fi
194}
195
196# -----------------------------------------------------------------------------
197# Main entry point
198
199# Install a generic exit handler
200trap _out EXIT INT TERM HUP
201
202# Set the globals
203_set_globals
204
205case "${1:-}" in
206 ""|run)
207 # Print the globals and run the test
208 _print_globals
209 _install_deps
210 _run_test
211 ;;
212 globals)
213 # Print the globals
214 _RT_PRINT_TEST_RESULT=0
215 _RT_CHECK_EMPTY_GLOBALS=0
216 _print_globals
217 ;;
218 *)
219 echo "Invalid test command: ${1}" >&2
220 exit 2
221 ;;
222esac
diff --git a/ubuntu_xilinx/tests/xlnx-config b/ubuntu_xilinx/tests/xlnx-config
0new file mode 100755223new file mode 100755
index 0000000..ccc3bd0
--- /dev/null
+++ b/ubuntu_xilinx/tests/xlnx-config
@@ -0,0 +1,16 @@
1#!/bin/bash
2#
3# xlnx-config: Check the board configuration
4#
5
6function rt_test()
7{
8 board=$(xlnx-config --get-board)
9 if [[ ${board} != ${RT_XILINX_BOARD} ]] ; then
10 rt_fail "Device tree board does not match xlnx-config. ${board} != ${RT_XILINX_BOARD}"
11 fi
12}
13
14root=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)
15# shellcheck disable=SC1090
16. "${root}"/lib/run-test
diff --git a/ubuntu_xilinx/ubuntu_xilinx.py b/ubuntu_xilinx/ubuntu_xilinx.py
0new file mode 10064417new file mode 100644
index 0000000..af14a86
--- /dev/null
+++ b/ubuntu_xilinx/ubuntu_xilinx.py
@@ -0,0 +1,14 @@
1from autotest.client import test, utils
2import os
3
4class ubuntu_xilinx(test.test):
5 version = 1
6
7 def initialize(self):
8 pass
9
10 def run_once(self, test_name):
11 cmd = os.path.join(self.bindir, 'tests', test_name)
12 utils.system_output(cmd, retain_output=True)
13
14# vi:set ts=4 sw=4 expandtab syntax=python:

Subscribers

People subscribed via source and target branches

to all changes: