Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp4817230rwp; Sun, 16 Jul 2023 11:27:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlH5jyW32/hvl8huyqBYkKf1qYWrKvG0uUbg1MJ5VTmJviaSrD1gB4j2X8X+vkjLmqU0K3ro X-Received: by 2002:a17:906:2205:b0:988:73e4:b781 with SMTP id s5-20020a170906220500b0098873e4b781mr7627061ejs.2.1689532070039; Sun, 16 Jul 2023 11:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689532070; cv=none; d=google.com; s=arc-20160816; b=XY6LfIgOLnvcCBYuy1YpHamOVR9d3+5vL6cftF48synV3onNnqcODdbif/fdSkal4A s1cQsFAtuISz23Z+pVNkAMH7VkVFThc68a+4Fm54VCFuaOIP1tmcVnSSBXAhbUg1wcjm 9n9ZE6+k2wsTIbibe787KHwJAudyNIT9xPwzHN0DSII4S3pE9qBw9UCuYdpj/Cw1iU7m GR813MegS30F5o9t/pTEnz0B/v33DQH9Z2UFT6rmTRypNw8Do3S050BMoj7t+omkM8x2 k8aJmNk4PQ1nTOvi3H9fKpqUsoKnYJ3oy0Noj2vOsQncsyNSmfzVz88PAwS+zTR7ZUfy v4Kg== 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=uRr4t72OqG7bbsdSQp36s5QmJpiGmQDwT7OtOfgVJAs=; fh=MZch7evULrTFhAm6DsZaMdKTMWTIr4RtVLY9sN6D0/s=; b=y/FANMY55wXQ3jMSXRG7uNiYs+PxIGLws9rgV6DPkhXv+quKzjKuoJhiTgHVNynCIx QRBFCGo37QSNhAKnXtTVGoarVa/+iLuhkZp9pHvtxzw4DBImd/tlhK4MI0aI+iEGOIVD kcFA1j8IEPXronIi6WC8yCl90rRwS0HwUdo68XVkff6/+gq9ZiL4HwCRNDubekYJ266B m+Pcxn5kfbfiLCPeUOkf15t2tlZdU3AZqaa4zsU278uHIGrVHJalbBOLhhdwy70DvmMN heYLOD6mHETFHb1nwKIaxWjo6j7JgDxIBnEyJX8kyGDpPAvadrgQTui0mSAwOfdZTviC cv+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=GaaYjzKL; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020a1709064a4b00b0098e3e818952si12596339ejv.326.2023.07.16.11.27.26; Sun, 16 Jul 2023 11:27:50 -0700 (PDT) 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=@gmail.com header.s=20221208 header.b=GaaYjzKL; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbjGPSSi (ORCPT + 99 others); Sun, 16 Jul 2023 14:18:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjGPSSh (ORCPT ); Sun, 16 Jul 2023 14:18:37 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97E091B0; Sun, 16 Jul 2023 11:18:36 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1b9e9765f2cso21858475ad.3; Sun, 16 Jul 2023 11:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689531516; x=1692123516; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uRr4t72OqG7bbsdSQp36s5QmJpiGmQDwT7OtOfgVJAs=; b=GaaYjzKLGGS1UieotsqzLzc8zg49fL2l6LbQTq3nbfRE+3kPmSrdRXeC5u7qg1VvXB ruuwP3vXsuw7i7PcoixYO4rTMutHMuhoAoT3wQ5lO0TZi5uBCYh/B1j8b1Tkuh+p1Jw5 GMyOpBuH6+TcBxZYOBO7/F0bG+EraHMrDfGydgkurseGk/ofa92an7A/FhERLpHr4pte OwQINR0kLvSSLFs9k4ApiPmnIGKO79f9d38yBzjXvL6Cj1FNF3U3Trp8ZGs/fSG1hzdK A8pZkBlstHyHiWzs/QntkFLl6bp9ddzq4TpFicx12n3wumpjmvzZaC1DUudpjgA9OeVg EzoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689531516; x=1692123516; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uRr4t72OqG7bbsdSQp36s5QmJpiGmQDwT7OtOfgVJAs=; b=OMe7v2235ncjIfyuUvOVSeUa96RHL2FxtZ8CXieSDEjDLHt/jzJ8F0/I4RJxWeZrQK 50PexF7fqmf1UfCk+R+gdHau/Axda/c0tIOOLfZlQuvX0bt4BLpULY4OPheLrVOBUa1X fkNUe6IHU4Trq0GzZe6Ljrb0C7FQ6bKHbe1MAYDvO2H2VaHFMAzPO1E3Igl72PaXfqHi bRBjwXBzD7dWg5rhWb6BSIYwF2U4jmeAMTBr7XY2llSdQFaA48MKvA4iUALFTIj9NPIP IGJnDU6txtdzmheoSGjOKlgxHem8X0fCmiEgB0Ep2yS8XY1LDc+hITcUt+A1uf4pWUxo Vflg== X-Gm-Message-State: ABy/qLbcMxhO7pZHW6wWGihLQavI51Jiuz/wMkW56WV6K+3FaSux7l59 BGFXvh9sRqHk8j+ItALY+4n/Oq6alT4= X-Received: by 2002:a17:903:182:b0:1b8:944a:a932 with SMTP id z2-20020a170903018200b001b8944aa932mr10984982plg.2.1689531516055; Sun, 16 Jul 2023 11:18:36 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c009:58ea:65e4:f662:2536:5ba8]) by smtp.gmail.com with ESMTPSA id e15-20020a17090301cf00b001b87d3e845bsm11242422plh.149.2023.07.16.11.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 11:18:35 -0700 (PDT) From: Atul Kumar Pant To: a.zummo@towertech.it, alexandre.belloni@bootlin.com Cc: Atul Kumar Pant , shuah@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-rtc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] selftests: rtc: Improves rtctest error handling. Date: Sun, 16 Jul 2023 23:48:25 +0530 Message-Id: <20230716181825.44337-1-atulpant.linux@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 When running the rtctest if we pass wrong rtc device file as an argument the test fails expectedly, but prints the logs that are not useful to point out the issue. To handle this, the patch adds a checks to verify if the rtc_file is valid. Signed-off-by: Atul Kumar Pant --- changes since v3: Added Linux-kselftest and Linux-kernel mailing lists. changes since v2: Changed error message when rtc file does not exist. changes since v1: Removed check for uid=0 If rtc file is invalid, then exit the test. tools/testing/selftests/rtc/rtctest.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c index 63ce02d1d5cc..630fef735c7e 100644 --- a/tools/testing/selftests/rtc/rtctest.c +++ b/tools/testing/selftests/rtc/rtctest.c @@ -17,6 +17,7 @@ #include #include "../kselftest_harness.h" +#include "../kselftest.h" #define NUM_UIE 3 #define ALARM_DELTA 3 @@ -419,6 +420,8 @@ __constructor_order_last(void) int main(int argc, char **argv) { + int ret = -1; + switch (argc) { case 2: rtc_file = argv[1]; @@ -430,5 +433,11 @@ int main(int argc, char **argv) return 1; } - return test_harness_run(argc, argv); + // Run the test if rtc_file is valid + if (access(rtc_file, F_OK) == 0) + ret = test_harness_run(argc, argv); + else + ksft_exit_fail_msg("[ERROR]: Cannot access rtc file %s - Exiting\n", rtc_file); + + return ret; } -- 2.25.1