From patchwork Thu Sep 28 14:38:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13403170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0587CE732E0 for ; Thu, 28 Sep 2023 14:38:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 778598D00B2; Thu, 28 Sep 2023 10:38:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 702DC8D0023; Thu, 28 Sep 2023 10:38:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DF088D00B2; Thu, 28 Sep 2023 10:38:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3EFD18D0023 for ; Thu, 28 Sep 2023 10:38:29 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 11DBF1609C1 for ; Thu, 28 Sep 2023 14:38:29 +0000 (UTC) X-FDA: 81286261938.10.176D728 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 33FE4100009 for ; Thu, 28 Sep 2023 14:38:27 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BZQIp7cN; spf=pass (imf05.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695911907; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZBvzOuD8Fr4XtQ4fyCtWwoG6AEeanacXTbZYCGDnSQg=; b=E4gDe+y23ZszJkBeJJZty1MGY70Mfh7BrIsUrugwYDIVUmew0O7Tqfz8FwiMtGFcTi4qbO apoa0y9TQQoQHn0zsO8vn7t2tYbd8/68gl4/dFx7k8JhgjS5VI2JFHrhTP4Ijb/+p6Lhy8 6jMy9pL02XPQWotQbf2gaH6jswFazdM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695911907; a=rsa-sha256; cv=none; b=AOpidNoW0SaMx7l0xJkVvBekZ1ylaR/4VuPKgsdtYUnZ8qnRNAPnc9FwSl/l72lgh1z6Dq Ifm+z7JwLjjKkRQ5HFTV54a9Nn+kYEDdJUG9uyFfQe90JLkPVGTKmiTogb+GY9Urk9tPUQ 7Uv0K3fylSUsGNKhMTORSGInv99J03Q= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BZQIp7cN; spf=pass (imf05.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6223E61CC5; Thu, 28 Sep 2023 14:38:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5255C433C8; Thu, 28 Sep 2023 14:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695911906; bh=q8UFTGCW+PEFQaExarcKjuMastWfb/GcwHIY56H9Tcw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BZQIp7cN2GL57vChOU1kT8bhTIHyB461hx5VZi7EQHsucGSvA9HIFgljqIkq95OkW IapfOzlVzrqPm3gZkrIYLzry6pCbW8Kc7JGUXZ2DFiZQnrJOxUXcUtEupIgSJZmELh 9piUigJVyNW4S/Qn23Qz5inxoA++YG7wr/P5dS3S2ypSplxnXdcDo7TFWXslxuoeVX kOQqIpdkbBW9/3L0vXy6+tAMfe5otOlq9G8eA4aeZrbDEhOjrqPjxhsC5qLSIdggQF iP+QB3U8QFWreajhTBTyT51Urc00S1OlJpdwS8wphP9Vc7KyrTsn6QANcFNfaKFrsu e0m8ZBWmcE6cg== From: Mark Brown Date: Thu, 28 Sep 2023 16:38:11 +0200 Subject: [PATCH 1/2] kselftest: Add a ksft_perror() helper MIME-Version: 1.0 Message-Id: <20230928-ktap-exec-v1-1-1013a2db0426@kernel.org> References: <20230928-ktap-exec-v1-0-1013a2db0426@kernel.org> In-Reply-To: <20230928-ktap-exec-v1-0-1013a2db0426@kernel.org> To: Shuah Khan , Eric Biederman , Kees Cook Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.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/pANAwAKASTWi3JdVIfQAcsmYgBlFY/dyR2RkI4Mf3AjCLdtgSIbCYIqcP2/TW/+f QjOYN+RisqJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZRWP3QAKCRAk1otyXVSH 0LZxB/9rF9qh6VkytpRTD4uzNLpwiQHxuWBhc9JCr9kLoPxnRbAJTvaRe530xMNWvRPC0cIWeDk hhw6WbIo53maSZJl56bQngArBk29ZLRxINJrFzslh7L2PqNf2uFuvOAPN9hrej6d8cxWWUR+KMh LjCExIZCY8nR+W/+OqzUxP9ZjUv3nhIQ6yl5AkhLKfrPYDO9wP2iTjwuaHK160uXwZcwYCRytgh l9Jwk4IupXGCV3vZ6Eggv6zf1fJL1EBkjAc9V40uMaVKwznhKA9ANctrnmLFGnDK/luMYGZc0g8 fGyy026bp0/uCnZAzkF+UE96ngvOl/uimO47/k9nHs22kiy7 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: 33FE4100009 X-Rspam-User: X-Stat-Signature: gj6ghigqp63wa9ca46khdk4e4jr4797c X-Rspamd-Server: rspam03 X-HE-Tag: 1695911907-840361 X-HE-Meta: U2FsdGVkX1/ly7XzZs7dT0NNVaV7E8+iiI48ekWo3R0fX9xs9RJcICNcAn+MMq0ieMKd7VYb+mQ/naeBdou15DmnniG9UOuW5hv6NolDUGJW+b9gOuhmXcpfX6fK+P8FNG0J9Qp/TCHa8hI6UfgiWQs2cWmkh5Mr+ptCzD8uWVBAX9AglP5H/ToiXvxJbUEWLULVbOqFcKO5Ube3zO6hO8gXg+72/FolvkPEVr8VVXk6pYwhDE4Ogad07WzqnjaKUdyd/Zwi9ip7uG0oG4TkZELd74y0rMWJMQHLyoeapbd767nm25Q24ElVHWuOCgoFCnc52uVwalvk/1zJR7RbYIIDjv67ue0kUV/MuajRJsZw4gb387Qd3bHv9egPmw/jTqi1BG/X7vLROscAExjgrCQIjSaL/OPqIx6uSoVCV5EiAveyzquSKFf5ne+ER0TuMsqtONR1NkMUl2N+zJ1eDuNQ5l5lf8d+yylj7UfGS+XWjvlf8lrbnrUO+vozKwqsoED70ytYQ8hd/p3ZcCtaFuWHtPMQrHBnqed8Hso63azjupI4jk3MoEqLl/l/zyi9Cej/MQ6HPDvFCzTMBkUFgW0tuSBMgU7OyzhNcWM1kHZjQ13SOvPvOcOcvzVQrwxJbXiY7gMqS4tWrUwx5yp7Ars3wdrJj8gk23mpyblolfBdJqS9ec7HDOjp/x6JK5TqJ9cL4zRHCwNYvo+jsx4fdrCoVvFQEP0Q6UKXR+oi292nlJV5Fu4Q/CuVlIzRmGYtM44yybtB6e6jMkSDHiPJuxraotqVT5KgmEDW9F+aqsVY70gfzKirKClhdy8Tz+h3mfduc/Q22W/yCh4PrC25AqQax/hjLXPbisKAQhCMhsg1hjv3FpqUM8JQSCsgSwZGtmIJ6c6xKWeaN0llXPAXnhZQbW3rjvAexZvRtlRW7rz+UTj87W5UpAfn7cL35hhMXYKtxUlhyaCXVFbvuPd HzCfCVcV twxK1gGtW6vDT54vZO5OUvN1dzicSCqe9r9Mtv6cJZF0hzhxxnK6W1Eq5ZvRbS/iAn/TVgnEzA9YYD7+77BtoreUQnoPwh/MGaioOmF6O0Azg53UsZKOIO2yraj+4Zo8xkyMmZDd2WYIXaejdtJJTyJOLYE+LoluJPOyoTTq3vmHPFUDmtux08bfn/0CkfyJOE1Zodg/k0WMdH82js0m5t1VNXKjDygna65C+TqnwpJDq2G/ZPmEPKY65xjtKGKgXErUn6eVX0CFHCC7u7BiPyF6xWwteQJ8crsz63tMjCvwrdU4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Kees Cook --- 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;