From patchwork Thu Apr 4 16:14:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13618039 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 AF818CD1292 for ; Thu, 4 Apr 2024 16:14:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D4B26B008C; Thu, 4 Apr 2024 12:14:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3878C6B009E; Thu, 4 Apr 2024 12:14:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 227E96B0099; Thu, 4 Apr 2024 12:14:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 039A96B009E for ; Thu, 4 Apr 2024 12:14:16 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A86A8804D5 for ; Thu, 4 Apr 2024 16:14:16 +0000 (UTC) X-FDA: 81972346512.07.0AFF5F2 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf25.hostedemail.com (Postfix) with ESMTP id 042F9A0027 for ; Thu, 4 Apr 2024 16:14:14 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=Ge1bY6gJ; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf25.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712247255; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rYfcPB4AxSG0Elguh372X9YReOtOGGmex5J7vbKWRPs=; b=4pIHLJ3ATuJjuASjbXIXjCdJSHybh17J3VMs2gtutgZbIixYifSFG0Dc9vlzStuNvl4aTl BiJpWRA/Fghi9JzDQZHR/DYFApnCZgS1g70+QYKG+l8KvzsoMeyiUlTbMopz7Al6IvDikf JNn2+6YkPK9ygUYVwAmAoKBpk33HcEQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=Ge1bY6gJ; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf25.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712247255; a=rsa-sha256; cv=none; b=MVBB5QWR5DRkhBOKdLjN1lBVFRoAp932K6lg4NHcqmBObj07oO1bPE8OAXD/VahJlVDgha JXDWUQyqNYaqFGMNs1TGlLsnsvNryz5o4tC+p1itFkRHFjb16OgA9LPs1vgtXCxJ3Vyqe/ oeAW4+dD/nmkbbAC4s9hPRYNGOwcWXE= 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: 042F9A0027 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: to1mb3nn7ao3wgnh3p9fd9otj1c65ike X-HE-Tag: 1712247254-661695 X-HE-Meta: U2FsdGVkX18xT4ene89Drw6cLF2YQPhazcoeFvw/Jm0aBqoQjgzSCAMdjPQ4sfWqhunTd+qHkQhrdlObK3FId8K+X6IKp9epu4gzrN/F178bGaVaiW9nVlTwqxWl9IhlQ1BQk6WHbLvIwP//MZ0UrfYADxSnA2q89O1C+sNO4WRcmzAOZcW7rof6GMft0RSMNO3yaH8am/diBLmgHbIwTYiymkfevjD+NFGOqg9Wksdffhe40WKPVSW0Dw4m490XBea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4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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();