Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1722240lqa; Mon, 29 Apr 2024 18:12:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaH1yNMDGUhuEpR4jcoZUJ5HI2tKzXWVu7zfoStCo4vliATa6gerf3RKi1+FKfAwFIQ4vw/dcEDNlf6EopW35vITLqJPWf28wVl81PyA== X-Google-Smtp-Source: AGHT+IH++Iu2telHnG1BfPOO5l3TUSaOpSAbnmCGCAZ1Wr6ODtbD8evPaT1cQxbDSG42itD9/CRy X-Received: by 2002:a05:600c:310d:b0:41b:285:8417 with SMTP id g13-20020a05600c310d00b0041b02858417mr873323wmo.40.1714439538294; Mon, 29 Apr 2024 18:12:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714439538; cv=pass; d=google.com; s=arc-20160816; b=KYRoVaW8F5CuV0af2EUdkkxLwKYzdLojwqw+XOPeKXUyx8KEPKNpVcEUwe3/Gp/ESx fFULXa3Vx+Bhc/xZGDm8nyQsivbqfoe4cdMAMqdw1sDLqZnEUQ5J09SkvLZnzzwqDwTI OnkBfeOpzW1FGVla9JWDm7kGreYqlLZfU3L47Ay0LtwxidaCR5kZLn3sy0TROtSCDr7n DFfvPQTDqu9qzbKZvTG6BUo/6oHG5o0GvAlIZ7mPMK52+qh7oQo3hTnpy7Z5bv6CFnZL XKbPWwl/CLOOh5pmihbwZ9V+MSgE29WUm5XOKM1EWSflQwu6RWTazki6hMyNyc7H4Dag uTcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=o1ppiacHBGt4deDldEbdpGFMwipyVa+kEjFesHxd+4M=; fh=91rHFKFe0+xpt9afzhOGWSuph89gcLPFhOwkuxoir/o=; b=GgTdXPDZaEWgakiUKLlp/F5iVNsrBHU+l21fttxo6ZpwRj0NbErVR04dPy7r0WwhAG uSzAZGUJn4yqJzB9bdX/4ooe6uojOoCtNauN1dZMTHP1yY63c8EywmcKkaYZVBIVT2Gg +laIqIWuRVkO/sy1fn8t73HzXJxUYOaucuxNrNURaioZpiNrKr7HgbmhNk08o4lB0BfI KoEf1Kk4m1vhj5ncKlK0P6sXJA6nmkZOaVcfkuGqgpxN6P0ETjQGlUauRAsU7nMMU+C0 pb8KcVzN+ftqB5kaz5lZGNla0c0Qz9Uvqd277UcP8arBKNIR1z+tlFCH1aWHT4zXUcXt opkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pIUnrvPu; arc=pass (i=1 spf=pass spfdomain=flex--edliaw.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-163205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n6-20020aa7db46000000b005724a74dc0bsi4985245edt.685.2024.04.29.18.12.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 18:12:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pIUnrvPu; arc=pass (i=1 spf=pass spfdomain=flex--edliaw.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-163205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1BEAE1F241FA for ; Tue, 30 Apr 2024 01:06:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B4CD2107; Tue, 30 Apr 2024 01:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pIUnrvPu" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 794AD17F5 for ; Tue, 30 Apr 2024 01:06:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714439194; cv=none; b=P3OlU3ILhOEiOgQiOEh/MG5Po++8QHJBLYcXfpkMW7yD1AevGgfyRfLaaRYxE1nagFGGC92GlH7zo22ntweJoq828W8Ph3ga+4t3yM8illAeAVA2dbWZI0lYGNsQlWarjr+AslfyTDWnk1xEp+D21U/x3TBrT5/r2h7btusInUc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714439194; c=relaxed/simple; bh=CQZ+rutb34tlCcqKjJD9BEd+5QtdQSwRC5IuvL3355o=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=jdUxGCP3Y3SxZsd9IuIocicdGHa05Jghr76pUDvKDVPa8FfxWEcf+UuK/V8CUMKTC1o0qWXYh4ayg4fsDvzQQbe7LSLNYLDT/pKfZ5pI6CPhRddkNc0m7AZMRLKupRzUxX6frv2xFx7rC9zAIaK0rgqTWJc1SB7JQ3LmLz+4PsA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edliaw.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pIUnrvPu; arc=none smtp.client-ip=209.85.215.202 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--edliaw.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-60f1bd44f4aso3221847a12.2 for ; Mon, 29 Apr 2024 18:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714439192; x=1715043992; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=o1ppiacHBGt4deDldEbdpGFMwipyVa+kEjFesHxd+4M=; b=pIUnrvPu19HKo6KofwgjMrtkwNpbkF3GtTZC7LSI0Om2iqrAKRwaSaKeS6iw3h9UMV ZdMho5vD2PhzadZJAxpE6ayXw1XlXLRsMNaxMSlGjHUfExHrEeg2fHjwScmIDonSCXH5 uhEydjFRqeuauhJZV2SZWAPL+tLh/TDI3sj8Oe0fbCy+wN5eQeciKbcvhhLBX20/q8Fz OGa03/tm23pzRyVtNSL2kJtBf5nReYZMmgMw5j5TZZbGKEwaMYS6Lb2SIW+JIWjT/TzY zNkIIM1KBvItOnmFkiYt64OsREUPs9D9bXObKwV394b6NiRULc5/huPoCimnwff1BUUv eTfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714439192; x=1715043992; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=o1ppiacHBGt4deDldEbdpGFMwipyVa+kEjFesHxd+4M=; b=g3467SoeVcI/Gn3K/KDyRptVeiIVBZXnzM7YtV0akz+BxEx3Sdgqw5QHfJbmewujzX +mpxQPvWbNaybf6kuFCAOj4SJdcO9dbf6Kcx2iE34EHtdXA874cEvfP72HJZ5rz/8Xtl DeeszPOpHaMMPKMcxQ/iVR7FIvUIwJ0l8ZyLHHHOaYrfLutpGywPsBtV0Zj9Vpr2xXkM oRFwWoDdDA1a6weyiz/+Ws580azslk5qM8WXE6F0cMrHDBgRYZTtliVQVvx9d+eQWWc0 ZpoQsqprafec7PA0hsxLwJcqnLBAvc2H8Im+CtRnHc22PDXOJg4zukdtw97rnqyuCU+B YuOg== X-Forwarded-Encrypted: i=1; AJvYcCV15CYwuziDoCLkhCqBD/gjuU/BYfp+kKhMxiKI1FfhlFPY6U+kDZFeOPtRflvE/Nbe2p1hQjm/SwWyx8wZpkTakE/suq/l6fKfaJVY X-Gm-Message-State: AOJu0YxIc7pEwlhJUgzUlRcxc5WzS6BCyBn0b3aCIOva3PgJ9dG3X9ac 9wrGVYkFihixIh8BvOdkafcDvHA9j4Z6Q40Lr93CxzD49iwWTVbE45+yC7em9+8xrqM8inWP7rP Hyw== X-Received: from edliaw.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:305d]) (user=edliaw job=sendgmr) by 2002:a63:33c4:0:b0:60a:869f:3a6c with SMTP id z187-20020a6333c4000000b0060a869f3a6cmr2542pgz.5.1714439191602; Mon, 29 Apr 2024 18:06:31 -0700 (PDT) Date: Tue, 30 Apr 2024 01:06:27 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Message-ID: <20240430010628.430427-1-edliaw@google.com> Subject: [PATCH 6.6.y] kselftest: Add a ksft_perror() helper From: Edward Liaw To: stable@vger.kernel.org, Shuah Khan Cc: kernel-team@android.com, Mark Brown , Kees Cook , Shuah Khan , Edward Liaw , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" From: Mark Brown [ Upstream commit 907f33028871fa7c9a3db1efd467b78ef82cce20 ] 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 Signed-off-by: Shuah Khan Stable-dep-of: 071af0c9e582 ("selftests: timers: Convert posix_timers test to generate KTAP output") Signed-off-by: Edward Liaw --- 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 e8eecbc83a60..ad7b97e16f37 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #endif @@ -156,6 +157,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; -- 2.44.0.769.g3c40516874-goog