From patchwork Fri Jan 12 07:21:35 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: 13518001 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 82333C4707C for ; Fri, 12 Jan 2024 07:21:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 143AB6B00A0; Fri, 12 Jan 2024 02:21:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F3AF6B00A1; Fri, 12 Jan 2024 02:21:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED6BE6B00A2; Fri, 12 Jan 2024 02:21:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DE0C86B00A0 for ; Fri, 12 Jan 2024 02:21:44 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A278FC02C1 for ; Fri, 12 Jan 2024 07:21:44 +0000 (UTC) X-FDA: 81669814128.12.7C27629 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf07.hostedemail.com (Postfix) with ESMTP id E83DF40003 for ; Fri, 12 Jan 2024 07:21:42 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=FrHH7po2; spf=pass (imf07.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705044103; a=rsa-sha256; cv=none; b=Henxm+q2s8nCrxr+IkEU74RKraawhzi6vlhEeUV9Eq7MiLv3zu57Hy2A/c3ZLdQ8BJJ52c ex+J3cJrbiz+wndrU2Qbb9AVzsclbIZTkPRTaGbIVvnPmKU6N4G05fPz2YoQugPo/IUtyp wc666UfcxTf+comi4hq0WzY410QDWJ4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=FrHH7po2; spf=pass (imf07.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705044103; 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=RRYCrWRPzghdnfa/U625RObew6RS47zcBeUTTW5kUWD4jhFJpiADAfvWrbo8W6sSoeGqLs hyKFzexfXZQ28UyOoE1MEPlEVs6gFwi3UzVpC+2KRMqu+RpFblKCYf6WgbZD6YnJKzQb4c 0UFQ3bAEaLZVAlbXKrCNHlkBisasKjM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1705044101; bh=o1IUw1D3iI8Y90Z4hsu7JwinzA97QoWLS2TEa1p944o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FrHH7po2p6f5bJlnjjARK+E5oPRZy5Mjhz3oMXw6a4KRpAireAwHVRMKyYKttNYQi RpUFQFefBsY+jE/5hw1Ps0LoPTWBUkgW9L+ig/KnkPuRQZMjYM15rUQoXZJBcfTdgi VwUYi3SkK90zBwqL2fpFPYAKbUKAXPCTQ+qsBESUZaaa//vhC7uhDq86ZNNngOZ1Nl dLxYceVowQeEdshFlKMb0jUiOANh0aBJ+ZDwc0Gr2zV/XkhrJYROP56QYlXwQd6i9t VOq0K+dn95R3MOABRQEjVLn1dYf361vSLVza18YnsflWC4PweFc4ee3jqYvYIK7WxC AADZGFRpj+Kxg== 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 06CC23782021; Fri, 12 Jan 2024 07:21:39 +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 v2 2/7] selftests/mm: hugepage-vmemmap: conform test to TAP format output Date: Fri, 12 Jan 2024 12:21:35 +0500 Message-ID: <20240112072144.620098-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240112072144.620098-1-usama.anjum@collabora.com> References: <20240112072144.620098-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E83DF40003 X-Stat-Signature: g51uz1bpmbnsiw3n7fzcdxettwfbzct5 X-Rspam-User: X-HE-Tag: 1705044102-156145 X-HE-Meta: U2FsdGVkX1/9K9pFpBx/WbC7wYdmiOKErNK7D5vUtAZdHdNCFbjIoGMBkZi6EAUABU9S49k1hML36ptuWBNhMJq9x9trTzF0CbgiJg7y+iYOA329S7leuDL6pe2JX0kKzvAuBAfe7fkwKJYh7IwJ8lCHrfrXRveFDUlbQn6ykcgvV0tiGSGYyvLAoF7xqdYeyN42yB6JehMUYHqzY/r3lIyTQckV8197Whwl//Y3I0jtfSN0CPAJAVEqi2P7DK2QD1G8AeVUDwvfTq0ixRYnFpXAkRSt2O9s7dOIiqcwh9SqAIm3oMk3Ws5SkuZ0zC2f5k3TmTjgx9NoOoQdsIjNKE7yZFzMQGQuM7oX42f/k8GTBUc8fTJGDnKcaeBrxsnmyoHy19q3DtG8oumW/Z4+oxRABlt7zjns3kAH7CQilrl6c+aHODUxX9XsWvDgGkpMkshZCZkQ5aFpGOnihZcH3Ud2bxfkjozzbfyeHEjtkoZES7jRWaMSlMP9YbEWyN7MMkNYWTShE1eNnAT/lQM1vVtNd/lah3KsJiTmtwMEBa5d1h2zmKZ8GZwQFlLSbZhbUWDC/3hlUqu/k+nFjI8dL4ueo271N9x8/DgsRgsbdROdFbY+IuTbwFLMpQ6aC48ly9g0/zy7XJRHOzkS7GiR6pX7ytSOpvOao188obe3OpF9HAOmPG2oXV2OBc7q/yUzC8fC/MSyAan4GmB+UDFSWs/nRCHeK5tOtYdYH1QIqD7Rmj9OWiPnGcxG2qa1L10YMcLHDW0P3Ob194AVv0pevu9yrzo9Brd1RKT9iH47LOcoe67hN8fgkTHpXW4Y7OhmBPhn0BgD7XlkRIuI+PuVGJ8IQq5RfjlwZR1Xav6YNVFGMrodKWUqrZqg4s0fWj/7D13uO/ua+ztjuYMCSPcmkRfGl5TojaEWJXIaIlNzqkIKyBkks8NRD1LwI9iw5e8zD6jCClwSFgp0a9jSSF4 qHO93aKR ue9XsOEIQSI/56mh1lvI0OiASj3qiyzwmCuIlGq1oh26MaPqqIkCazfptGYzgA9FKGFvzFX7XF2Ql+lecgp+xO0Z1gy1wGArVkl9eOgf+8Qqi8pQEtBIjfqkyJugUDSOrQ2pljJXw7az9B4HWcEwhISaigTgizNYKwWXoIHJK6YKt7PBguAaJpnMe0DihdL7J7Md0s9rbIOr4o8flSZG2OfIOi5pR/kP9RGEeQmLI+Spm9xdm15UYmQlGUg== 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(); }