From nobody Mon Feb 9 09:22:22 2026 Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8E3C202F9C; Wed, 12 Nov 2025 06:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.224 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762929012; cv=none; b=KiJ4x7JIVRz0A8ibJ0HLhKFVjfVrddaDevr6Mt9AqLs644CzKV+dGvqm+eRQGK2y6F/AIyjGtjqENnYfd15Qov/ZUdS+uvx9gLF5zkM4Qmw/i2e2OgHvhMidws2+rEDkBfBnaV/CZGmf00OAuZoqClOq2ARKd4892oiheWQlJpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762929012; c=relaxed/simple; bh=Wazx6jWArPi5hlBgtqnEmzLdaAEYpi5VGgrqSmnHRX4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=KD3bS3zORe1gDJ+UDBc1P/flBJ2CqDD30qmtsmVZ/XKIEe7a8LW1vZYfmPJBeRo1BgyeemEcJskn73IQXIsUFDIifedonqxwoFXUk0v5XewTfkGj7lgta6+KsRkVTP2mVEoYNxR07nLhp5H3FTDerB38MEYN0N2qYyP1r7xxNXc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=3XOqYvCL; arc=none smtp.client-ip=113.46.200.224 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="3XOqYvCL" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=lY6cQ7KxBIYOYros9QrVDrG6tiuFNXUR7hTsPWOK194=; b=3XOqYvCLFX80YxJ9ENVokqyC/kaKLmqB/FyTeHFbts6CXUhsfaiVYetlpMThBXja3qRB1kiR/ WXBis9tWdTnnCkWhg1jcVxe5HU121vTwQWQY933lINtZUWNIGtxUoRBLGMy17FlzVv81CIpd+sg BGGWO4n2DtBAxKFR9izX35I= Received: from mail.maildlp.com (unknown [172.19.163.44]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4d5tkz6dVyz1cyNs; Wed, 12 Nov 2025 14:28:27 +0800 (CST) Received: from dggpemr200006.china.huawei.com (unknown [7.185.36.167]) by mail.maildlp.com (Postfix) with ESMTPS id B18221402CC; Wed, 12 Nov 2025 14:30:07 +0800 (CST) Received: from hulk-vt.huawei.com (10.67.175.28) by dggpemr200006.china.huawei.com (7.185.36.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 12 Nov 2025 14:30:07 +0800 From: Xinyu Zheng To: Shuah Khan CC: Moon Hee Lee , , , , , , Subject: [PATCH] selftests: breakpoints: check RTC wakeup alarm support before test Date: Wed, 12 Nov 2025 06:15:32 +0000 Message-ID: <20251112061532.2867859-1-zhengxinyu6@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To dggpemr200006.china.huawei.com (7.185.36.167) Content-Type: text/plain; charset="utf-8" If RTC wakeup alarm feature is unsupported, this testcase may cause infinite suspend if there is no other wakeup source. To solve this problem, set wakeup alarm up before we trigger suspend. In this case, we can test if RTC support RTC_FEATURE_ALARM and efi_set_alarm function. Signed-off-by: Xinyu Zheng --- .../breakpoints/step_after_suspend_test.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c = b/tools/testing/selftests/breakpoints/step_after_suspend_test.c index 8d233ac95696..e738af896ce1 100644 --- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c +++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -159,10 +161,30 @@ void suspend(void) int count_before; int count_after; struct itimerspec spec =3D {}; + char *rtc_file =3D "/dev/rtc0"; + int rtc_fd; + struct rtc_wkalrm alarm =3D { 0 }; + time_t secs; =20 if (getuid() !=3D 0) ksft_exit_skip("Please run the test as root - Exiting.\n"); =20 + rtc_fd =3D open(rtc_file, O_RDONLY); + if (rtc_fd < 0) + ksft_exit_fail_msg("open rtc0 failed\n"); + + err =3D ioctl(rtc_fd, RTC_RD_TIME, &alarm.time); + if (err < 0) + ksft_exit_fail_msg("get rtc time failed\n"); + + secs =3D timegm((struct tm *)&alarm.time) + 3; + gmtime_r(&secs, (struct tm *)&alarm.time); + alarm.enabled =3D 1; + + err =3D ioctl(rtc_fd, RTC_WKALM_SET, &alarm); + if (err < 0) + ksft_exit_fail_msg("set wake alarm test failed, errno %d\n", errno); + timerfd =3D timerfd_create(CLOCK_BOOTTIME_ALARM, 0); if (timerfd < 0) ksft_exit_fail_msg("timerfd_create() failed\n"); @@ -180,6 +202,7 @@ void suspend(void) if (count_after <=3D count_before) ksft_exit_fail_msg("Failed to enter Suspend state\n"); =20 + close(rtc_fd); close(timerfd); } =20 --=20 2.34.1