[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240503014102.3568130-2-jjang@nvidia.com>
Date: Thu, 2 May 2024 18:41:02 -0700
From: Joseph Jang <jjang@...dia.com>
To: <shuah@...nel.org>, <alexandre.belloni@...tlin.com>, <avagin@...gle.com>,
<jjang@...dia.com>, <amir73il@...il.com>, <brauner@...nel.org>,
<mochs@...dia.com>, <linux-kernel@...r.kernel.org>,
<linux-rtc@...r.kernel.org>, <linux-kselftest@...r.kernel.org>
CC: <sdonthineni@...dia.com>, <treding@...dia.com>,
<linux-tegra@...r.kernel.org>
Subject: [PATCH 1/1] selftest: rtc: Add support rtc alarm content check
Some platforms do not support WAKEUP service by default, we use a shell
script to check the absence of alarm content in /proc/driver/rtc.
The script will validate /proc/driver/rtc when it is not empty and then
check if could find alarm content in it according to the rtc wakealarm
is supported or not.
Requires commit 101ca8d05913b ("rtc: efi: Enable SET/GET WAKEUP services
as optional")
Reviewed-by: Matthew R. Ochs <mochs@...dia.com>
Signed-off-by: Joseph Jang <jjang@...dia.com>
---
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/rtc/property/Makefile | 5 ++++
.../selftests/rtc/property/rtc-alarm-test.sh | 27 +++++++++++++++++++
3 files changed, 33 insertions(+)
create mode 100644 tools/testing/selftests/rtc/property/Makefile
create mode 100755 tools/testing/selftests/rtc/property/rtc-alarm-test.sh
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index e1504833654d..f5d43e2132e8 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -80,6 +80,7 @@ TARGETS += riscv
TARGETS += rlimits
TARGETS += rseq
TARGETS += rtc
+TARGETS += rtc/property
TARGETS += rust
TARGETS += seccomp
TARGETS += sgx
diff --git a/tools/testing/selftests/rtc/property/Makefile b/tools/testing/selftests/rtc/property/Makefile
new file mode 100644
index 000000000000..c6f7aa4f0e29
--- /dev/null
+++ b/tools/testing/selftests/rtc/property/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+TEST_PROGS := rtc-alarm-test.sh
+
+include ../../lib.mk
+
diff --git a/tools/testing/selftests/rtc/property/rtc-alarm-test.sh b/tools/testing/selftests/rtc/property/rtc-alarm-test.sh
new file mode 100755
index 000000000000..3bee1dd5fbd0
--- /dev/null
+++ b/tools/testing/selftests/rtc/property/rtc-alarm-test.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+if [ ! -f /proc/driver/rtc ]; then
+ echo "SKIP: the /proc/driver/rtc is empty."
+ exit 4
+fi
+
+# Check if could find alarm content in /proc/driver/rtc according to
+# the rtc wakealarm is supported or not.
+if [ -n "$(ls /sys/class/rtc/rtc* | grep -i wakealarm)" ]; then
+ if [ -n "$(grep -i alarm /proc/driver/rtc)" ]; then
+ exit 0
+ else
+ echo "ERROR: The alarm content is not found."
+ cat /proc/driver/rtc
+ exit 1
+ fi
+else
+ if [ -n "$(grep -i alarm /proc/driver/rtc)" ]; then
+ echo "ERROR: The alarm content is found."
+ cat /proc/driver/rtc
+ exit 1
+ else
+ exit 0
+ fi
+fi
--
2.34.1
Powered by blists - more mailing lists