Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp151267lqp; Thu, 4 Apr 2024 09:14:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXX3lxI5FJ4Y5u71/bbdKKCIGKya6DMlpwTWqvJyvquCoaGRK7w/w7rgL+TzV6bWRG5cvyOvfPmclcYZL0lRBLoACt+dPuBsbwuMS3f6w== X-Google-Smtp-Source: AGHT+IH0o6nCOwvJ5Ri/qI+Yg5FGY0LUzvTDQrWXHkeha5Iu3BOL32BgMAz5VBilNdHhhXOAJOyd X-Received: by 2002:a05:6512:21b:b0:516:9fab:75de with SMTP id a27-20020a056512021b00b005169fab75demr2398693lfo.5.1712247279920; Thu, 04 Apr 2024 09:14:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712247279; cv=pass; d=google.com; s=arc-20160816; b=wrUcVmzeh+s+XwVxJhLdDayF8umCepymKPWyGSVVA68u4zRPJIuhIhz4AXjncraWjJ S+cReEkHEBEaip+2iSx1MbJrw3NyXmlCg8HSOF1sWg5gYazS3BC3i6XymVcioHy9ptVI XPTDXMAKnZP4va/V6FrPHITFywN6Ic/Kpx4Ytj0R1wXojwL7dHeR0bCVd51qcM6F7TJM 12sFHRi892G6t0WBgbUO3c1QqK6MTJF54aBOfeNjBj/gheyswGMNB848ze3lPCTAEjEr nLg2UCj4E100UwZO3r1iwK0lAv0Kxu9tPQR1z48UoAPAxFDNpoE5DQNCU59edypdLGLl tkuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rYfcPB4AxSG0Elguh372X9YReOtOGGmex5J7vbKWRPs=; fh=ALOkOm1SoolRUSrKjSdmSuEh7ZIj8elqIkR3FAJ9z28=; b=M3TwKnL1q5OJGLJArSNWSt/cb4bspZr+EZcm9rrgtBtSmf5nEdXnwaUjYisRLPYt82 h+3OOaHEVQsQiEoGzBViAh12eqTSElz3pWz2QSlzs2jPI7N3OnKkG9uURPlkhpzBVoqD qd2EzmDNs+tTBekgPdA2+9g56El8HP4auo4Cizws3Z/Kpw39Z3WPRvDqxI6W+2AplHbI GwQpujCEMA7Pno1Bli68KfmDLtpnExr8682fnZeBDlVQTz9ik7iHUKQWG7tQF9jmm3Mj ULG1czS0CuLo+xuFue03xJ8TyxKoiRNZTS78Lz1n2qUZJmqC279VoIyb9jXuaJjUd+Q+ ZsiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ge1bY6gJ; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-131800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131800-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.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 hs11-20020a1709073e8b00b00a4e28db8858si7811766ejc.793.2024.04.04.09.14.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 09:14:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131800-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=@collabora.com header.s=mail header.b=Ge1bY6gJ; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-131800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131800-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.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 A0AD71F2514D for ; Thu, 4 Apr 2024 16:14:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD580224DE; Thu, 4 Apr 2024 16:14:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="Ge1bY6gJ" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E97212C7FA; Thu, 4 Apr 2024 16:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712247256; cv=none; b=nXk4p42TD17j8KEbQCbycve4zGGFSpVxGv2sOH6dArmpGoZqdzDK5fp69mKLaruXB2Ui7fa3DuoVSId/m7ThU1ZHlU6/Zq+Rt7E+V5kRI46jkL06J3GunF6cL+Nm+oVeEENgUMvZoedzdkBTHFVdbwDVbvzrTzOADLmQ8uHOgkQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712247256; c=relaxed/simple; bh=boDL5nHOi6Lw/iE+qqB7X+GYBlXdpClEfHq4s6TIuWo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QEo9Q+i8qYxO7XPKHYk1Quw9+68PxhovUFh53/19f3DY10qJ8tQDM8CFSmJbxxFBC2SWjc29Je8CIBVWDsXPdzjkOuSQJZLF8Bj29nkFknjxnT0wD3h4iBwfVEOFywPOs/LzjedogivsqGNnuqkb34xaSi4eVZJMUmnjIysDUOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=Ge1bY6gJ; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712247253; bh=boDL5nHOi6Lw/iE+qqB7X+GYBlXdpClEfHq4s6TIuWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ge1bY6gJXP/VQg+cVNTG6HkpGguexAj/rR7+IrElRFFuC6JIWVk2BTA+MEQ/wtY8V qtyRZ8S2iIl+4J/4u4qMxUWf2k3VRpdg6ktbBjv3mBfE0p0Ynzlf4Wsw4OhHI7bDIW D4SvB2DcTayeOHd9wgGb13zqts5ZlfpBArMT6h72PANYY9Uigq2GeTA5eaJcAQ2URx 9u68VpEuWE4sbNOCOOo3ZzOZRIn7FyPZ1gWMeg0Ldd5XHiu2HzV0gq0XffLOirrdDk NuBVPhqxowuMVTRZ+YfFiXoWFsyMQHmBKAsHWhwKic+f6mFBgYehR/Ht7THAxSPg+D GEv+GZ8oU8NEA== Received: from localhost.localdomain (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 50B4F3782129; Thu, 4 Apr 2024 16:14:08 +0000 (UTC) From: Muhammad Usama Anjum To: Eric Biederman , Kees Cook , Shuah Khan , Muhammad Usama Anjum , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel@collabora.com Subject: [PATCH 1/2] selftests: add ksft_exit_fail_perror() Date: Thu, 4 Apr 2024 21:14:32 +0500 Message-Id: <20240404161433.114497-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240404161433.114497-1-usama.anjum@collabora.com> References: <20240404161433.114497-1-usama.anjum@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a version of ksft_exit_fail_msg() which prints the errno and its string form with ease. There is no benefit of exit message without errno. Whenever some error occurs, instead of printing errno manually, this function would be very helpful. In the next TAP ports or new tests, this function will be used instead of ksft_exit_fail_msg() as it prints errno. Signed-off-by: Muhammad Usama Anjum --- 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 159bf8e314fa3..2cd93d220f434 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -41,6 +41,7 @@ * the program is aborting before finishing all tests): * * ksft_exit_fail_msg(fmt, ...); + * ksft_exit_fail_perror(msg); * */ #ifndef __KSELFTEST_H @@ -370,6 +371,19 @@ static inline __printf(1, 2) int ksft_exit_fail_msg(const char *msg, ...) exit(KSFT_FAIL); } +static inline void ksft_exit_fail_perror(const char *msg) +{ +#ifndef NOLIBC + ksft_exit_fail_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_exit_fail_msg("%s: %d)\n", msg, errno); +#endif +} + static inline int ksft_exit_xfail(void) { ksft_print_cnts(); -- 2.39.2