From patchwork Thu Jan 11 11:56:31 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: 13517286 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 9F2D8C47077 for ; Thu, 11 Jan 2024 11:57:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2766E6B0092; Thu, 11 Jan 2024 06:57:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D2126B0093; Thu, 11 Jan 2024 06:57:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 024596B0095; Thu, 11 Jan 2024 06:57:41 -0500 (EST) 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 DEE126B0092 for ; Thu, 11 Jan 2024 06:57:41 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B3EC5404A2 for ; Thu, 11 Jan 2024 11:57:41 +0000 (UTC) X-FDA: 81666880722.04.93C60E4 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf10.hostedemail.com (Postfix) with ESMTP id 03515C0015 for ; Thu, 11 Jan 2024 11:57:39 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=YyH92dge; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf10.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=1704974260; 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=s2SklXwDrfN2CthrOooNixZyo9tqgugJGAtaQibUEUA=; b=YUJuL/SapLo8IVNIAEYOY9WSlYsD6PJ0Tue9U5bdP7x7jCDyay9BysYIHPNJh7NugZ4d2k GLl8q/l0M+0lQvhKgCkPt2UrN/D/fRI22NjiLCJsX4fJE/sg7q/C2Ud/OIoEUay4qzXHnp OXeSGjDRnWThmV9Cs9dzgHCsaQT0AbU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=YyH92dge; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf10.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=1704974260; a=rsa-sha256; cv=none; b=J3Qr7x3+EwuxooqOvKJBC4ENNp7A5eHV3Xr6/v5uNdO7Ca0PYurJhXAdHjLQqhyctOhmx3 Ox1L/QtIg4FHp84x0fakx76iqz3Qs8I0BvnoinMTsuygqywGadA8gEehflbYsTtgPijPu/ vKqy3OfQqUHREtXgcCeymA8VETotsZo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1704974258; bh=o1IUw1D3iI8Y90Z4hsu7JwinzA97QoWLS2TEa1p944o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YyH92dgeAon6MwJA8uNb6o5qO2XLK/X0xqX53PQOwHgbvmzvZEA/ZHU0gFtlOCL+9 fLPPOgRMZsNaVXjBs7X3OUFc9fexxdlEVBkUQkJcGBGk6Msly8uNdz1yMydkeHFBqp jMYJD+Dh8fGRJjCP2r9YNXQXb4viVw53YPVi1oNhbTnzgNXucKPlmIbmcUHwD/sieO hkya9Sc2SIzVDYnP2d964GmUZRCEsptHsiL4dZVaqqStTT29LhCOw5fqEBKPbnECBr +n4eP+O2zQ/YZpCzgHR5r1O15fX/cPgJkiWj9GDRvEbScZpzEm5XVyPh6c3UcYj6dD Yx/zQuE4K/Bog== Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (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 263693781184; Thu, 11 Jan 2024 11:57:35 +0000 (UTC) From: Muhammad Usama Anjum To: Andrew Morton , Shuah Khan Cc: Muhammad Usama Anjum , kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] selftests/mm: hugepage-vmemmap: conform test to TAP format output Date: Thu, 11 Jan 2024 16:56:31 +0500 Message-ID: <20240111115639.3981970-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240111115639.3981970-1-usama.anjum@collabora.com> References: <20240111115639.3981970-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 03515C0015 X-Stat-Signature: kqowgzoxtt9u65wwt613e9m41m5bom3x X-Rspam-User: X-HE-Tag: 1704974259-313537 X-HE-Meta: U2FsdGVkX1/Tug+QcumbOlfKuGM7UTkGAKhcHOmNVO9aNrD/VyYvNHifYwSokJjXkeUY8ASB/tTGTZegtdtxfIWgmLDNLFcvGTDeYZuZdn7F/xH7kDxTQnTIVts6/zPBaCFm2j2ml4dYzfAinVTNH7u1j40TDiSYqfmZ83Xf1dO9MPbcU3JX6p7UfHba7vgcDKSLy1bpcgZxRyLXlSABnIC/d4wEG0KC9LZhIJay5cW1U7X2GLqF6V88BwbVNOyrd+yduNZvuwaU4dztpsjSTkDGhSFEC7sXIjxycYE7g5U198MJX7TgMbkL0jN8PTvfrm037jOufw6A2zceqcwWh+hZjmBqoBk6D2ZJnZcKiCuUsGE/hndEI7L/kNLcy4p1Npt/RGFVGd2VZnEtydb8iq2pMQ3zEHHE3Y7Ph3Abx1wcmhqmWl6etQytpJbG8hs8p0mGp7VhyyTMXmH9yWjFAJ+GshqDgeP4uNpPM2k6ZdYpvdaC4zoGSOANSuscE3euggqpiIHB4OF4zkd8ol7Pmxa/Siqi4OuiKOOARcpgcEVEm4KrbhH7riIV3gNr4m0reW3oxG6aOrUGbhwn3UtYCVR9wIb08stx1rVXcRZtkJecxg4jx+746BOlrQqTsKo3Yo8nemUGgzTWy3luhxwR7Yq5usgWljvQFXeabyLbjXLGW5fRFHiKKxO6N0y5iQR7Sn4dYb4FIzlQ4Wq1guxwdwRGII68w3eOl9bCA3DW2Kqd1C47SNiQ0Y5c/z6kxuUiKU045nXWVJHNdBwUr4w74EJnVwh+gylEUwgz4029xjGPxY126CivqRm8RA06NwZzPTVOTrY83C3udtvkEtfNraC+wDwR5qagmBDhT3sPVNci264gugN+NvfZoae4OYEoIgWRbJPYxO/PEDRXnxnsNNYIEJy2g+IEEXDHYffKMQ+wwyoUMqLzR9pqkKBMyRFfSSM7qpKx2zj4vJukhmF 0z3M5ANo kbPw+M6+4FEzTLXGg+7O33DGkQSw2FFkonBib3OfiRC8/xqA/KjgZXndpu+wNR1mNErD70sxd5idxz8bGXt/4luC9r2NPTDQl1oiMPsrQekVq5r8JaNRs/rSrv7pizPiWsevNH/cy3KEylzg5eRvgIATg+bvh4z1DlGMzhuC3feQZn1BzULoBrDO8OcU8VFn5SDs/HxYhjRmQW4B7qbDEvVPZOG+Nl5KmOTB9gkWVcI1Vu7OTXS+fFur9BQ== 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: List-Subscribe: List-Unsubscribe: Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/hugepage-vmemmap.c | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/mm/hugepage-vmemmap.c b/tools/testing/selftests/mm/hugepage-vmemmap.c index 5b354c209e93..125b96a65286 100644 --- a/tools/testing/selftests/mm/hugepage-vmemmap.c +++ b/tools/testing/selftests/mm/hugepage-vmemmap.c @@ -10,6 +10,7 @@ #include #include #include +#include "../kselftest.h" #define MAP_LENGTH (2UL * 1024 * 1024) @@ -77,7 +78,7 @@ static int check_page_flags(unsigned long pfn) read(fd, &pageflags, sizeof(pageflags)); if ((pageflags & HEAD_PAGE_FLAGS) != HEAD_PAGE_FLAGS) { close(fd); - printf("Head page flags (%lx) is invalid\n", pageflags); + ksft_print_msg("Head page flags (%lx) is invalid\n", pageflags); return -1; } @@ -91,7 +92,7 @@ static int check_page_flags(unsigned long pfn) if ((pageflags & TAIL_PAGE_FLAGS) != TAIL_PAGE_FLAGS || (pageflags & HEAD_PAGE_FLAGS) == HEAD_PAGE_FLAGS) { close(fd); - printf("Tail page flags (%lx) is invalid\n", pageflags); + ksft_print_msg("Tail page flags (%lx) is invalid\n", pageflags); return -1; } } @@ -106,11 +107,12 @@ int main(int argc, char **argv) void *addr; unsigned long pfn; + ksft_print_header(); + ksft_set_plan(1); + addr = mmap(MAP_ADDR, MAP_LENGTH, PROT_READ | PROT_WRITE, MAP_FLAGS, -1, 0); - if (addr == MAP_FAILED) { - perror("mmap"); - exit(1); - } + if (addr == MAP_FAILED) + ksft_exit_fail_msg("mmap: %s\n", strerror(errno)); /* Trigger allocation of HugeTLB page. */ write_bytes(addr, MAP_LENGTH); @@ -118,23 +120,19 @@ int main(int argc, char **argv) pfn = virt_to_pfn(addr); if (pfn == -1UL) { munmap(addr, MAP_LENGTH); - perror("virt_to_pfn"); - exit(1); + ksft_exit_fail_msg("virt_to_pfn: %s\n", strerror(errno)); + } else if (!pfn && geteuid()) { + ksft_test_result_skip("Unable to read the pfn as non-root user\n"); + ksft_finished(); } - printf("Returned address is %p whose pfn is %lx\n", addr, pfn); + ksft_print_msg("Returned address is %p whose pfn is %lx\n", addr, pfn); - if (check_page_flags(pfn) < 0) { - munmap(addr, MAP_LENGTH); - perror("check_page_flags"); - exit(1); - } + ksft_test_result(!check_page_flags(pfn), "Check page flags\n"); /* munmap() length of MAP_HUGETLB memory must be hugepage aligned */ - if (munmap(addr, MAP_LENGTH)) { - perror("munmap"); - exit(1); - } + if (munmap(addr, MAP_LENGTH)) + ksft_exit_fail_msg("munmap: %s\n", strerror(errno)); - return 0; + ksft_finished(); }