From patchwork Wed Sep 27 10:18:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 145311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2528362vqu; Wed, 27 Sep 2023 03:31:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/x8JEoM/E0awHnzfORqd+U9qb/9sG5b2H2Nq8QMzjQ8HFXrZxVCyIScbSiUKe9AdaOz2a X-Received: by 2002:a05:6808:130b:b0:3ae:5e0e:1671 with SMTP id y11-20020a056808130b00b003ae5e0e1671mr2123615oiv.4.1695810712731; Wed, 27 Sep 2023 03:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695810712; cv=none; d=google.com; s=arc-20160816; b=viNH/kBEWJr7cKQ//4b47NM7IVgayj2OUR3lx3EnkCoOioGhzbcaz0M3VM4lP1cABg X76XNSyaOt1C8S1n3/suR4Q98G3aBDILveR2pzc1lEd44R4Anh2UZ54xXrvrEkwdxe6R b5peY08wx/LKBhYhphKmVwi68Y/BJLNjTzxMCBNcDClCt+RK8F9PwmCHSP9KBMCNfBpF SfFlD+42yh97iCKXHEMzoAGhsA1sRgivMLA1yuHyA2GId01g+MRoFypxfZx+XPtzz7yE dUXNfVzHTgV/X5zSAIMAXELZjiQQRCdxX0nCJ4hXhTH3rCpbL1RH6BxvrUjlK8eoZjHq JfGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ZBvzOuD8Fr4XtQ4fyCtWwoG6AEeanacXTbZYCGDnSQg=; fh=VMd+jxMzW7UNRcV5RqOB7eB7vRw5ET/VzgdcVBjZ/m0=; b=KWAJ226YtEWE23B8jBWWjWlQFZ5ojivQgLmI0CguyYWK/6KRf4//S6hwn8w0nxJCm4 GcrMIeiNaduOdzVvfzTRzU4H9GfkUH1EM1DZkcL6VCWC3ObrxcjP4Am5TZJkrEdQjpuA g931Op0ug0AZ3mMRRgKg2WBzk/BoCtucJ7hMF8yLkyJkrvMuTYV+YYqJkUcJ+gRwVUdh Huba/GdPm5uFXjZuEJlhLcDc9DB8JE52C3fnw3W7FPt7NenowGsy52iAOGMdzzk7ggQe FzgP18jPTzTyiq8t3i+066ozf2cH1I8KHaaoBZ5t2v23KPac2NcjEP3/n5KcNstdcPng Ijig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="KCp/48Um"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id z16-20020a656650000000b0056c297d1640si13699518pgv.528.2023.09.27.03.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 03:31:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="KCp/48Um"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A4DD28198039; Wed, 27 Sep 2023 03:19:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231224AbjI0KTQ (ORCPT + 22 others); Wed, 27 Sep 2023 06:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbjI0KTL (ORCPT ); Wed, 27 Sep 2023 06:19:11 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C3059DB; Wed, 27 Sep 2023 03:19:10 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D23A6C433C8; Wed, 27 Sep 2023 10:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695809950; bh=q8UFTGCW+PEFQaExarcKjuMastWfb/GcwHIY56H9Tcw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KCp/48UmNhG+JUhenczTWbQ01+AmwHSJ/xcynPmRlgAsXCa4o+g9mRDPbDHUTwFNY knZA5sC1MFntWgcmwvXDf7ki3fruJuUFMVRjBGiFx4tB9FDEboR/yuUGWs5h+NmybG dpVkqylLX+TvWpAoaIOjtKyl+qKIejaU3ad2fHRq15duc7pF1nDVQDaqRCyABs4+fc uF3OBobSRo1FfYDvo8IhFN8FGCvF1ZWurUIrp4q8DD0fMh6JrqhwcJn/hlf8AHxdud 277wi2XqBg2CkrgJw/Tk4+mnEg+UzcIfK//psyM19om44R9Pl1X25jxlNsWL7LYo7k qBvjw4w9aw3qg== From: Mark Brown Date: Wed, 27 Sep 2023 12:18:57 +0200 Subject: [PATCH 1/3] kselftest: Add a ksft_perror() helper MIME-Version: 1.0 Message-Id: <20230927-ktap-posix-timers-v1-1-399de1cbfbea@kernel.org> References: <20230927-ktap-posix-timers-v1-0-399de1cbfbea@kernel.org> In-Reply-To: <20230927-ktap-posix-timers-v1-0-399de1cbfbea@kernel.org> To: Shuah Khan , John Stultz , Thomas Gleixner , Stephen Boyd Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1471; i=broonie@kernel.org; h=from:subject:message-id; bh=q8UFTGCW+PEFQaExarcKjuMastWfb/GcwHIY56H9Tcw=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlFAGYNK6gOtJ44o+Ey79dZT7jaZTXslGQO8ibW 4QF+xvnPF+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZRQBmAAKCRAk1otyXVSH 0MnuB/0fKCe7L0bWZzezE38N7jQMuQoyEPoFefE9z2hmqRzbaxOlz7qYon9WgdI+eJsZKncV8rh ZlKpz5PotKnC6WFxN3zmVoro2yulWq7knYrKKBcP0FQeZ2KdUuEzR2c1+SXfiSI2R0Up1X7JXaO 6PquwMvoc+z+ElwmKiehj74I7f9rxBuxobQBDwlRpjSlcHTYKVHAFkAvD8tqAtawQaM0dI5ZOxC +2A26seWgb7MMnLFFEKGihIBEziLtf539Z78/CmaQ0XuIUSSI6vRtal4H9QaGlurqK4b2sViq0n oGbDsaKEjptRXTElzBtZNSydt/u5eTUEgTR5XKSiHzOAeP/Z X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 27 Sep 2023 03:19:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778186414037759719 X-GMAIL-MSGID: 1778186414037759719 The standard library perror() function provides a convenient way to print an error message based on the current errno but this doesn't play nicely with KTAP output. Provide a helper which does an equivalent thing in a KTAP compatible format. nolibc doesn't have a strerror() and adding the table of strings required doesn't seem like a good fit for what it's trying to do so when we're using that only print the errno. Signed-off-by: Mark Brown --- tools/testing/selftests/kselftest.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index 529d29a35900..af9f1202d423 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -48,6 +48,7 @@ #include #include #include +#include #include #endif @@ -155,6 +156,19 @@ static inline void ksft_print_msg(const char *msg, ...) va_end(args); } +static inline void ksft_perror(const char *msg) +{ +#ifndef NOLIBC + ksft_print_msg("%s: %s (%d)\n", msg, strerror(errno), errno); +#else + /* + * nolibc doesn't provide strerror() and it seems + * inappropriate to add one, just print the errno. + */ + ksft_print_msg("%s: %d)\n", msg, errno); +#endif +} + static inline void ksft_test_result_pass(const char *msg, ...) { int saved_errno = errno;