From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793848118; b=g4O0uZT6xpvriFdrsVRP1A7JaqYUWe9Eug63Ob3R0uBb/z47X3imDDENbT5jKrlqIzj1 kwXv4XDpF0pz2UHCo/zgYEyjvQOGCxBP9M+Mf1KcQgEe8Tf5NKBoKLCkFIlJC3L4bUhbR fapuAazN/cc88q/iFX83LmXDUWhx6e3VljDqfEy9y7BrnIUgI66Hn7rZNQwyXytBdTiWx xN0cKZktcnOHZdvb9joWWTGfOiEv8Lq/EYsVHVoMhTruyoWm/HNs7Qrd5n4WANcNmbePt sz5gN49o6giG4fSfhF35d7Af6tV9/cqPbDi1KqcG430n/Kbti30DSdVf2C4/B3oEszA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793848118; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=+hTcrw2qlCHhO70X54WC3Z16qJoO8Le0y8rhZa3WBPA=; b=R58lM1DQRcmhhrED+z++9qM0mufbOO1AfX+qcgb3+7SJSwsBENGVRlSvpikg6M6mxTXZ mVhz/FaPRmBj58lWKJUK2z/1eTFitEWgvVYU6qYFuX0tKTBKu7suMGoJ/bjlxj6uB5gtF M2pevqA+ZQ4Uy2MsgJu514aNa6wXGATzdEP7nJuXjAZhQqeS/WELXrZZwjQ1joP31JBjp RrbXBqTBMh34jq0xL44eP9ShMWzBZ2luOJ7uFbOXt679pbMU33X5uHfeAHQEWt0hrxejC Q5wI9GBvL6cUQO5d9osQ1ZBs/aIQ1kpdfdtWHeabNKh1OXSfi7WcbgaWc1HQzw/4GCQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--wakel.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=XhKUI6Xq; arc=none smtp.remote-ip=209.85.214.197 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD991606A329 for ; Thu, 5 Nov 2026 03:08:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CD991606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wakel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=XhKUI6Xq Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2eaf8ea208bso12094775ad.1 for ; Wed, 04 Nov 2026 19:08:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1793848117; x=1794452917; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+hTcrw2qlCHhO70X54WC3Z16qJoO8Le0y8rhZa3WBPA=; b=XhKUI6XqNxb34vhkv7Xp1GhTqJ/8iFS/JNQCI+ZjY1NqHajvZqgZxCFZrDUwYMwvE6 BP3hw1pJEKqMfWHwNp4VFifFDntIMLzANbnT39cBRcH2bcpyXKvyGeh/g2k6i4WZ+1DM waphUfBfdMgHKwUp0jio826vFDu9gAZOm5JagNhghm9vpnKVlVA3xf/GKx/Isqbl8W4+ yoxLa6+9ZH3GPn0TmquzEUxOlC9dKnWE/YbAWz/aZGxDK9lov4bf9BhqFksAazbDyvQj 0ELyOh6vCKlysmai1zFRysjZHoQ3AuJkQPY3bHNWaybinsO5k/NqxRmSG7+RkICE/i2J YWmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793848117; x=1794452917; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+hTcrw2qlCHhO70X54WC3Z16qJoO8Le0y8rhZa3WBPA=; b=LL0AEpc7Da+enTiR+5S/kqPfPv1nqF9NIJYtbEPvguvZ3Dd39A8O0MTDMQrBXND/mU B571dzE37bcH1tjZjg8n3pX1zUgtnrw2qpLxd2sIxIxEvByYAWmPro2L/JiqRPps6djH vxCWVSx2uG7eWDjrwPDycVq3OO5c9rogfZSTnzA3v01eNzwC9TNyUNbTB+zh19/u1kIP LpFvhlOeqbUI7WBgB0R9FqWUP0j0WrD22g6STdQzmCCs4OD8Fa8i0La4XJqT/f/+Nwjn dqu0gcFXyy4y+CcwAs3g8PHkqrc1dUn3889MLoyLS6wWqyEW0vFgeiiUOz6kzNmv/XPT 9UfA== X-Forwarded-Encrypted: i=1; AKwUvBy/attVMPoj4CtKnv9Q18WdrrJDdYXxWrMuILapOPJFE7NrSjQFUW/WmT7wOTpoVJXJAhkSMweT1aoiZIQ=@vger.kernel.org X-Gm-Message-State: APuU4Z9F/XT/cDh4n2w1BZCFmKbxP4L3MLjQOrefzwpCL+rI4hxhoIZh btxjfEE+KtwW6UqpBuOEXnVNz+PLETgiCk7YWiPDPWGTORRkNrGgh/XzHRJwLp+BYN5iESAFrKV 6Zw== X-Received: from plof6.prod.google.com ([2002:a17:902:8606:b0:2e2:f305:e980]) (user=wakel job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:3b8b:b0:2e9:7ff5:544c with SMTP id d9443c01a7336-2eb3642fe87mr148706835ad.25.1793848116599; Wed, 04 Nov 2026 19:08:36 -0800 (PST) Date: Thu, 5 Nov 2026 03:08:34 +0000 In-Reply-To: <20260910034821.2935214-1-wakel@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20260910034821.2935214-1-wakel@google.com> X-Mailer: git-send-email 2.56.0.398.g882cbad275-goog Message-ID: <20261105030834.3318480-1-wakel@google.com> Subject: [PATCH v2] selftests: rtc: Support harness test filtering and arguments From: Wake Liu To: Alexandre Belloni , Shuah Khan Cc: Shuah Khan , linux-rtc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Wake Liu Content-Type: text/plain; charset="UTF-8" rtctest implements its own main() function with a rigid switch (argc) check that only accepts an optional single argument for the RTC device node path. This prevents kselftest_harness standard arguments from working properly: 1. Passing filter options like -t or -T triggers a usage error because argc is greater than 2. 2. Passing -l or -h causes rtctest to treat "-l" or "-h" as the device node path and fail with access() errors before ever reaching the harness argument checker. Parse command line arguments with getopt() to pass all kselftest harness options (such as -t, -T, -v, -V, -f, -F, -r, -d, -h, and -l) through to test_harness_run(), while preserving the ability to specify an optional RTC device node path as a non-option argument. Also ensure optind is reset before invoking test_harness_run() so the harness can inspect the options, and bypass device accessibility checks when help or test listing is requested. Signed-off-by: Wake Liu Acked-by: Alexandre Belloni --- v2: - Rebased onto v7.4-rc1, no code changes. - Added Alexandre's Acked-by. Alexandre, the other rtctest changes for v7.4 went through the RTC tree. Would you be willing to queue this one there as well? Shuah, please let me know if you would rather take it via kselftest. v1: https://lore.kernel.org/all/20260910034821.2935214-1-wakel@google.com/ tools/testing/selftests/rtc/rtctest.c | 44 +++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c index 552191fe1ca0..eb26d957835d 100644 --- a/tools/testing/selftests/rtc/rtctest.c +++ b/tools/testing/selftests/rtc/rtctest.c @@ -487,18 +487,44 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) { int main(int argc, char **argv) { int ret = -1; + int opt, i; + int non_opt = 0; + + while ((opt = getopt(argc, argv, "dhlF:f:V:v:t:T:r:")) != -1) { + switch (opt) { + case 'h': + fprintf(stderr, + "Usage: %s [-h|-l|-d] [-t|-T|-v|-V|-f|-F|-r name] [rtcdev]\n\n", + argv[0]); + optind = 1; + return test_harness_run(argc, argv); + case 'l': + optind = 1; + return test_harness_run(argc, argv); + case '?': + fprintf(stderr, + "Usage: %s [-h|-l|-d] [-t|-T|-v|-V|-f|-F|-r name] [rtcdev]\n", + argv[0]); + return KSFT_FAIL; + default: + break; + } + } - switch (argc) { - case 2: - rtc_file = argv[1]; - /* FALLTHROUGH */ - case 1: - break; - default: - fprintf(stderr, "usage: %s [rtcdev]\n", argv[0]); - return 1; + for (i = optind; i < argc; i++) { + if (non_opt == 0) { + rtc_file = argv[i]; + non_opt++; + } else { + fprintf(stderr, + "Usage: %s [-h|-l|-d] [-t|-T|-v|-V|-f|-F|-r name] [rtcdev]\n", + argv[0]); + return KSFT_FAIL; + } } + optind = 1; + /* Run the test if rtc_file is accessible */ if (access(rtc_file, R_OK) == 0) ret = test_harness_run(argc, argv); base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 -- 2.56.0.398.g882cbad275-goog