From patchwork Fri Jan 26 11:21:21 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: 13532447 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 B8C6FC47422 for ; Fri, 26 Jan 2024 11:21:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30ADD6B008A; Fri, 26 Jan 2024 06:21:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BBD26B008C; Fri, 26 Jan 2024 06:21:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 182F16B0095; Fri, 26 Jan 2024 06:21:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 04AD56B008A for ; Fri, 26 Jan 2024 06:21:39 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CC9C0120F19 for ; Fri, 26 Jan 2024 11:21:38 +0000 (UTC) X-FDA: 81721221876.28.B26C321 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf02.hostedemail.com (Postfix) with ESMTP id 1C5D180004 for ; Fri, 26 Jan 2024 11:21:36 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=ZiXOzuzg; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf02.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=1706268097; a=rsa-sha256; cv=none; b=2oJBxipMS/n0S0fMTlP0GIYFM3t/4m+LrdBPN42mGJh7CXOQCwX5ZGbCEl861BvRY5xoMI PwOLks35/43dHAqO1xJnPsLCF+R0z4cM0OQ2/u5r1ApXoozOSDdwk1CRqTtQ2ZHzqrjAWH KGRBCCkb+WbGjQdeADusrIelnoIeYGw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=ZiXOzuzg; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf02.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=1706268097; 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=kr5lSN379C/SqHbk1CjZmomG0TDndJ1Au3BImCQXJyA=; b=uyk78fU2bfiyU7py0tAJJELEs4R4OxHyvbuaPf8T1WhmlRY+AXDRc1OEOMMzZjZSNWbDks b3E9HQmIu1APTEuJ9uySS5avjxB5+CslStyntjCgPFRq4C5vkfvi9NnGKSbUY6SH8EQGvm SwcmAzuFu9TB/0Rdy4RdWkyvFRdtjUo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706268095; bh=gbp4bpldYXMai1bSsa5vwkMEe02OYwC/9Rhgk1A/iN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZiXOzuzg4aiDky/02dRhLu7ldeJ5EX4dN9lM/S0aVqQR4Yky3olG3YSE/YIcP1Qk/ eAAMVqLc8KRz10wrcDNHJY6bMaM4ajMWVqxWOE8QN5HoB8QUwHRmQiUiJ1hDnUS/g+ 4RCopsCTurJp07GIIP5VT/3fTke48y2U7OyNjiM/PlCeF0+T3jKFLn1l1QdvNd8xts bB0Y73sgNEM37YCVFVqvLu4Ow5EsPT0HrxoY7AZYB+CDr8inXJdtSHnQaT7Bw73wib 0pSiZ3aUdoWqgysiCLrEFYOwgPj0jusvrHmdyyUqNKk3j2yKNXLu0BUNfzxAYpcz4W OyEIVOLfpjg4A== 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 761883782075; Fri, 26 Jan 2024 11:21:33 +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 v4 2/7] selftests/mm: hugepage-vmemmap: conform test to TAP format output Date: Fri, 26 Jan 2024 16:21:21 +0500 Message-ID: <20240126112129.1480265-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240126112129.1480265-1-usama.anjum@collabora.com> References: <20240126112129.1480265-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1C5D180004 X-Stat-Signature: huhw3ba6yrufyf8oaimkgjhwmopsaec8 X-HE-Tag: 1706268096-58511 X-HE-Meta: U2FsdGVkX1+CSsSZnTJNnXEsHAGivHFMUX1MT3X+WZ2g93uesAyNnHZ1l+PTEUV0yk2DB1lJI65HN8Db/h2eoAVutb/QZZiBXJpTlBkPYsfVrhngqU5tWuWa58kZUyRFC51fwFUpxxiRuumWKQyjxR6BDzaKGv6jsylg3LVNzfYMsoAUaWoggW7RI53x5KykP0Tyvenk7/MMZbdgTZ/C9WcAE2T0a8XRm7QyjkkSWxAA4VhhAK4KFm0aGqukWd3miv10iCc7urC3lvpJKU8X4UL5GZbBOAdGbW/p3+NDv3iQ8DZZ91bd+mDF7NSBXCmDqX1zffsDBsvHn9onbfflw//eRcwVfhQbiVI3Ta2hEmKe8mZvc1eNE7gbX0cOHNWPJRlK7jcbMZgaQHXyWfPpeBn9poC9cvCCjVsx40ejYAYwegCnZ9why+3T70+zCIiZ90ZCLsn53rL376wUefjpIlHMA/mV0vkKrUxueAwBDt6fG/jUTLUceUnm6xkbDHYrSpj9lOdTv1/k+cxcLDikfi187Hw8xhc3eQ98oIZnkxqiJtR81c3uflG7EBX+aZe34DAiAg2L8ITkRB/pwZO8Npsx0GTzuH5h9BNPfG1RJCoMCKgqbVUPJEJZF3T2L8yqRwgwgOi9C1SGSoBQSYCrhWKGfyWNK3ujjZmySrbEHxeXpM60bSH9KMJFHT8QXWZwHVmPDZbMiAh4IypUrNRZjnbsmCa1emDtknJ57f/ivwdjqEayDOD+NF/f/NbpFdwFdpww7Um1w04IoIK0HNER2x276kFZz/SBZ0co8qm9LUOgu8bfRV73bucRS4MhapC/viPluSBuzGCaIS6UgPoceDNO0GASncNn+R7f6rj8Z7wpOlF9HndYadUzas18o2nfinxCHgc9Z+aI7IU42ztsAr3GyTkyHOcJOzVwfg9371CSGG6GXFFL4Yl9h9OWAIBSLb3eRB6MLEjvCCr5Eio kSXOfpev qEVwmPKL99AUMJhWKKzgYpg2z/ncQvWnYHVDcw8W+V6yPOQDhWAIXnk5TFQgdnfsESLEXezNRWqlqr6zK7nBJqykTgfI7LGNquSk2K4ILg6U6P5M28Lj7DrogtqxVHrAPHqbVePFfICXZKm5YTq2NuNX+ywvTJii+lanJQUv1yLjRVFmjO1rfrGG9/5JMOySUGVvI/m4T6sVOS/3Ud5cT+8nLuH7d9vbAQlNdgykAwwQfJ6YAmZntCRHUvQ== 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 --- Changes since v3: - Rebase to next-20240125 - Update newly updated code --- tools/testing/selftests/mm/hugepage-vmemmap.c | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/mm/hugepage-vmemmap.c b/tools/testing/selftests/mm/hugepage-vmemmap.c index 894d28c3dd478..9080e34bb297e 100644 --- a/tools/testing/selftests/mm/hugepage-vmemmap.c +++ b/tools/testing/selftests/mm/hugepage-vmemmap.c @@ -11,6 +11,7 @@ #include #include #include "vm_util.h" +#include "../kselftest.h" #define PAGE_COMPOUND_HEAD (1UL << 15) #define PAGE_COMPOUND_TAIL (1UL << 16) @@ -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,18 +107,17 @@ int main(int argc, char **argv) void *addr; unsigned long pfn; + ksft_print_header(); + ksft_set_plan(1); + pagesize = psize(); maplength = default_huge_page_size(); - if (!maplength) { - printf("Unable to determine huge page size\n"); - exit(1); - } + if (!maplength) + ksft_exit_fail_msg("Unable to determine huge page size\n"); addr = mmap(MAP_ADDR, maplength, 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, maplength); @@ -125,23 +125,16 @@ int main(int argc, char **argv) pfn = virt_to_pfn(addr); if (pfn == -1UL) { munmap(addr, maplength); - perror("virt_to_pfn"); - exit(1); + ksft_exit_fail_msg("virt_to_pfn: %s\n", strerror(errno)); } - 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, maplength); - 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, maplength)) { - perror("munmap"); - exit(1); - } + if (munmap(addr, maplength)) + ksft_exit_fail_msg("munmap: %s\n", strerror(errno)); - return 0; + ksft_finished(); }