From patchwork Tue Nov 15 20:21:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 20536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2925794wru; Tue, 15 Nov 2022 12:24:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5GkFnomPf3GKeyRBRcYoxReaY2cqyghoLGrIjk/b9NeFv/7Ceh617r+cS0CGUSfug4QReY X-Received: by 2002:a17:903:445:b0:186:95ca:1e4c with SMTP id iw5-20020a170903044500b0018695ca1e4cmr5752762plb.13.1668543877383; Tue, 15 Nov 2022 12:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668543877; cv=none; d=google.com; s=arc-20160816; b=ow+ZV8L86f0fShbnQAKr9u5TRNpGujU2crQ6Xn54LzdcLgN8dXqvwR4QHEdBTHyS/s tw5IYbJ5OZ02UU2GJ0mPyu83KJLm6AQ6yTtVDLnO7gfkeK1obdj2pZgxj8bmHdkMIGMn rNi0szpkmtGqZNLTBZqyNd5k+bUiZ3OLojQtInpYSf91xvcPSORnPs4W4wCJFtwmgpve qpsOSps3QfC5CrtwuJLsMOxneumWTcSj4IaNJJtNYiGFXHkVz9zHUzjEuz065nj0TfM+ AvmWXG5+BMKlF4QcdKjw//mU9MFPbbwp+UFFoYatkJRY4AfvD6PAfVAgRrVHVf+AovAL X9bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DbCVDSNTtI3YCzhfWf+yYrEmDHea8PXJym5ThS3OVTc=; b=QVEWI7KN2CF674iTsWqtJAnn4wMSQ3Xf8jri4j6PWwhp7C5EcWQg+6Jmc8pWuy8RV5 Jak+018s+EuuD5CpBHT4hRrhJC+8Y8n7XW3a9/qnm3s0qPCeaku8h2DB2ODlwed2nI/E kuhxkYqbf5wY5vT7fHz5ix1TqlPBjg5OCV/nMqNOVLkEzTtoW4ZF1L2DqKu4ro7tdJMl QYZ+eKrW6cmN+eweBcp3peSQSNxka9qHKNamLEoa5SE2vu271VchwQHK9RXoBx/f2q6H 7LNgf9DDFYd/RhSOUl3+kzwdpGbkoxJUAFl0dsjvrnWVapHg+HPWbsjpbevCcj1Mizb5 sodQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aZyzHlSm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v21-20020a17090a899500b00212fd5f1ad5si16833344pjn.160.2022.11.15.12.24.23; Tue, 15 Nov 2022 12:24:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aZyzHlSm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbiKOUVU (ORCPT + 99 others); Tue, 15 Nov 2022 15:21:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231867AbiKOUVL (ORCPT ); Tue, 15 Nov 2022 15:21:11 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E26C2A731; Tue, 15 Nov 2022 12:21:08 -0800 (PST) Received: (Authenticated sender: alexandre.belloni@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 24A2F1C0004; Tue, 15 Nov 2022 20:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668543667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DbCVDSNTtI3YCzhfWf+yYrEmDHea8PXJym5ThS3OVTc=; b=aZyzHlSmuoLgDmhUzWnMk4M2MOy7PYKSaoIx/gsvjj1e2SYopR7gb2GCKS6IfcR/takEmw 7nOW0Dht3x6UxFUHQFdgBrOPY0tIFQWG4NyOmWYtsTu3U3A+dP8Znp9jY70trLExv2+3yk /B3xZKQ5izfG/zc6kIWuHk26Dj2jS3zfl+C+0mFoVH7z6RHQcODesOZFMVoHbjJMwEH6aD AO4slwzTFaZ6iParr0zfrQk66w2TDaKyyXE91scSAFV5XGl/h6RXbT/DVEckhigd+ixvZZ rYPIBSMMXcpYZgIYmJgjOWWopIM1SNLS2ckLc4hDWKAbc45Kd1fEC6EQI8XBFg== From: alexandre.belloni@bootlin.com To: Alessandro Zummo , Alexandre Belloni , Shuah Khan Cc: Linux Kernel Functional Testing , Daniel Diaz , linux-rtc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] selftests: rtc: skip when RTC is not present Date: Tue, 15 Nov 2022 21:21:05 +0100 Message-Id: <20221115202105.2309859-1-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749595064923084468?= X-GMAIL-MSGID: =?utf-8?q?1749595064923084468?= From: Alexandre Belloni There is no point in failing the tests when RTC is not present. Reported-by: Linux Kernel Functional Testing Signed-off-by: Alexandre Belloni Tested-by: Daniel Diaz --- Changes in v2: - reworded commit message tools/testing/selftests/rtc/rtctest.c | 33 ++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c index 2b9d929a24ed..63ce02d1d5cc 100644 --- a/tools/testing/selftests/rtc/rtctest.c +++ b/tools/testing/selftests/rtc/rtctest.c @@ -31,7 +31,6 @@ FIXTURE(rtc) { FIXTURE_SETUP(rtc) { self->fd = open(rtc_file, O_RDONLY); - ASSERT_NE(-1, self->fd); } FIXTURE_TEARDOWN(rtc) { @@ -42,6 +41,10 @@ TEST_F(rtc, date_read) { int rc; struct rtc_time rtc_tm; + if (self->fd == -1 && errno == ENOENT) + SKIP(return, "Skipping test since %s does not exist", rtc_file); + ASSERT_NE(-1, self->fd); + /* Read the RTC time/date */ rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm); ASSERT_NE(-1, rc); @@ -85,6 +88,10 @@ TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) { struct rtc_time rtc_tm; time_t start_rtc_read, prev_rtc_read; + if (self->fd == -1 && errno == ENOENT) + SKIP(return, "Skipping test since %s does not exist", rtc_file); + ASSERT_NE(-1, self->fd); + TH_LOG("Continuously reading RTC time for %ds (with %dms breaks after every read).", READ_LOOP_DURATION_SEC, READ_LOOP_SLEEP_MS); @@ -119,6 +126,10 @@ TEST_F_TIMEOUT(rtc, uie_read, NUM_UIE + 2) { int i, rc, irq = 0; unsigned long data; + if (self->fd == -1 && errno == ENOENT) + SKIP(return, "Skipping test since %s does not exist", rtc_file); + ASSERT_NE(-1, self->fd); + /* Turn on update interrupts */ rc = ioctl(self->fd, RTC_UIE_ON, 0); if (rc == -1) { @@ -144,6 +155,10 @@ TEST_F(rtc, uie_select) { int i, rc, irq = 0; unsigned long data; + if (self->fd == -1 && errno == ENOENT) + SKIP(return, "Skipping test since %s does not exist", rtc_file); + ASSERT_NE(-1, self->fd); + /* Turn on update interrupts */ rc = ioctl(self->fd, RTC_UIE_ON, 0); if (rc == -1) { @@ -183,6 +198,10 @@ TEST_F(rtc, alarm_alm_set) { time_t secs, new; int rc; + if (self->fd == -1 && errno == ENOENT) + SKIP(return, "Skipping test since %s does not exist", rtc_file); + ASSERT_NE(-1, self->fd); + rc = ioctl(self->fd, RTC_RD_TIME, &tm); ASSERT_NE(-1, rc); @@ -237,6 +256,10 @@ TEST_F(rtc, alarm_wkalm_set) { time_t secs, new; int rc; + if (self->fd == -1 && errno == ENOENT) + SKIP(return, "Skipping test since %s does not exist", rtc_file); + ASSERT_NE(-1, self->fd); + rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time); ASSERT_NE(-1, rc); @@ -285,6 +308,10 @@ TEST_F_TIMEOUT(rtc, alarm_alm_set_minute, 65) { time_t secs, new; int rc; + if (self->fd == -1 && errno == ENOENT) + SKIP(return, "Skipping test since %s does not exist", rtc_file); + ASSERT_NE(-1, self->fd); + rc = ioctl(self->fd, RTC_RD_TIME, &tm); ASSERT_NE(-1, rc); @@ -339,6 +366,10 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) { time_t secs, new; int rc; + if (self->fd == -1 && errno == ENOENT) + SKIP(return, "Skipping test since %s does not exist", rtc_file); + ASSERT_NE(-1, self->fd); + rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time); ASSERT_NE(-1, rc);