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

Subscribers

People subscribed via source and target branches

to all changes: