From patchwork Mon Jan 15 07:32:38 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: 13519365 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 EF061C3DA79 for ; Mon, 15 Jan 2024 07:33:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3229C6B0080; Mon, 15 Jan 2024 02:33:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D2716B0081; Mon, 15 Jan 2024 02:33:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19A916B0082; Mon, 15 Jan 2024 02:33:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0440D6B0080 for ; Mon, 15 Jan 2024 02:33:10 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9FEA5140346 for ; Mon, 15 Jan 2024 07:33:09 +0000 (UTC) X-FDA: 81680729298.09.9AF8448 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf15.hostedemail.com (Postfix) with ESMTP id E967CA001C for ; Mon, 15 Jan 2024 07:33:07 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=USadmbn7; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf15.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=1705303988; 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=Zsj2b6XOYid82LY+EXGz8JUhob6mtDPCNfRwBdwIeaAMhLQRJuMQOYIOfruXnXWvZZaSJm D/f9XdQTjBoYzdmlpuWDR5YbYT5EGkM5EW0KFgwLWBuMLA/cXyM6FcrkxB+dYvEHMSXaxx sg4q7drhci7YkeJ1yFH4Kzcmqvu4qwY= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=USadmbn7; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf15.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=1705303988; a=rsa-sha256; cv=none; b=GgeEdbveEFElzfxO+aN27u+iBpbcH6pK8zjBnJwAwpLCMrTXHbvfxf06fAtW5iR7FgSZ4z WcX9PvQhi8f8cQ1r7B68UGUsVL5XX0OShQivZG7hicvAebjEehOvJj77STKvQHkXI5MMOp RRVkDbpMs9NxDdEDXDqUrX878EA9atA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1705303986; bh=o1IUw1D3iI8Y90Z4hsu7JwinzA97QoWLS2TEa1p944o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=USadmbn7PKHWToYkvjVZ3AC9iI/3+wePMhbl5oyp9VALBYEYxXCLsmpwTUDdZ7qch pK15+SiFt97hasoGzAIIIMuSTPRsKI/c8mB3YgKxiYlaJ6x0JFKwqFUuJ7oS804wgq iwbR39xeZxL6mbejPq19dqYziJSfQPiHUtJQnESxPB1pZpOICzFN5GxlMNiTkgb/AT 3T+VM2viAh8oKC+WjyMZsC+SX2WE/u9a/zm96hYFKMKXUqxVn9maqbdb7IPBFJ7kUy wSq2OwCGeWVhc/TcF3igjZU99k/C1a+8W/wv2CTSA7UjMNocOR/JUSZ74UGeiMe+QD vv/XSvNU81h+Q== 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 374EF3781F80; Mon, 15 Jan 2024 07:33:05 +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 v3 2/7] selftests/mm: hugepage-vmemmap: conform test to TAP format output Date: Mon, 15 Jan 2024 12:32:38 +0500 Message-ID: <20240115073247.1280266-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240115073247.1280266-1-usama.anjum@collabora.com> References: <20240115073247.1280266-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: E967CA001C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: cu9omn8mbishz8ofgw4eadniyqe4asxk X-HE-Tag: 1705303987-525646 X-HE-Meta: U2FsdGVkX18XmAcI270lQ8Yo6SneGg8jJbe2HmZN3ReKorb9n4IYcNRjOZKGBmuZuuMPGSAKUZSgd9AeG49BQoRnuuDOXiwKFl6qp27wDrkq4qzN0hSLTxE8rDOSDCUuJZLGr3jVb4EbFze2XLSpz/rtLEhI8ONtFcJYDek1YLwDbGYfO+PJHT89ahinwYx2/kwsE9RJlw7x6SR85ZT8kYhAvJ12BTYm208pgwfJHGgsSOCPBGM4MKr2O4hFUcGzaYw2yp7tKdlKHACWGIsNYefpqgadsBKXZoHbXVKvhUsD6zY2pAuAriI2x51GtkDhh1ZgHoul81fNWxPNqSe8urHMenFFnuuaKLcYgD0PGzftil+blmhr3PxWsJzQb3dOKXfwBO6FIwTrbUhid7izETSk4IYhegfx4Z40CZ8a6M9oYzDH1c9DZep999uKOMemlHuo87CsG1MrAts4Zx1qyTWEUBuThbGBO4PuKOxPnAAG/wb0MuwmkAHcHFw1QuX3JyWA/1CxiLONcV/XuVMkmCkQvzjGWTfipjHTZuujVXaZDAWHENxYYPb40Uvs1sC4SI/dICJ5Zfpv2z31bp7MI3bdDI2EpShI828rxzrKGjakLfsuDnOZJRLIKwr1TV9zoTDfv7YmD9Gt8viOpKg2ok72ticbZmO1EMtM/ahVjhUoHtPyocYUyjI8zbw9f/la1VfvUUREKjwKnPchcAIjK6Xu/M9bIbGruypLJ+cV1jdwpHxrlLRHqj4oKacVMnDxiEvPkbrTHGlHa05WtQ1qDoMD/uoS1Doy7Wqx0eBCD5SG4uAsw4wj8PjpjiuBOP010bkytZsle81Q+rxRA8fBQq1n5WyjNEE0mBJInDMQfSnsTLHrvtkr/iEKnorI5pRW4ri5mbWKy7CPpNfuOunTqZj1reK8QruhhtmkQJ57BmPn24+hH8sy5PpkegLvuLDxMQn0FVIP/ijWtDLtEOU tAM/Zm09 ALTKK4RG4a6M0x5Hz78XZA80wXZTXz2UmXoyuu6aryGycu2CUrZMy66xE3sMl8IkRASumiHfjJm2G0Xw6lC+/Ows+XUcll8dzIVA8gzi9cmgIAaRq78eamyuXBAXjlAbWlUOqwFBjtdNcpY9f9uQ/4+e0Kk2uLcg24q/WbbotpjsJZln+sHqlKd6BU67qWPN+eHh/3pqv3klkCtwaDxZpInszbXXVV5/Yce1bt/OFq802cMp7xPPqcgmKYg== 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(); }