From patchwork Tue Jan 2 05:32:22 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: 13508831 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 1537AC46CD2 for ; Tue, 2 Jan 2024 05:32:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 486A36B027C; Tue, 2 Jan 2024 00:32:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 437046B027D; Tue, 2 Jan 2024 00:32:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 325816B027E; Tue, 2 Jan 2024 00:32:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1EAF46B027C for ; Tue, 2 Jan 2024 00:32:45 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CC9531606A3 for ; Tue, 2 Jan 2024 05:32:44 +0000 (UTC) X-FDA: 81633251448.17.70B9424 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf09.hostedemail.com (Postfix) with ESMTP id 27E7F140011 for ; Tue, 2 Jan 2024 05:32:42 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b="Y/L8t0BE"; spf=pass (imf09.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=1704173563; a=rsa-sha256; cv=none; b=gR70vy3pxiL/Y4RpOZa8LmTSwKEB2T6SPSv3sYbC17ItEZLFz4ohac0d3QfB+aognUz4FQ PtM/Dc8tZgETJDzdpuNEJj71QbH3ghlCW/yVJOAeftByOtGbHxrL4ue32OjrKIRmqGBZgp /BPZbEGmMe2KMCHiyT7GIbBZNn6QQZk= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b="Y/L8t0BE"; spf=pass (imf09.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=1704173563; 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:references:dkim-signature; bh=Nhb4I078jQXNS6IcTiCHKfr0oXD7OWZL7aLePC4KFhc=; b=pSJMwWknI3ii41kBG67FSSgLxIQvW8GU8V/IX5uf+0xF20W9/OqmqDDVy1vXgAht3350z5 aZQTQtDJLWjB4typCleuBp9XPWOChZ3bd4eBclojLYWCvik4g2hJPvHcxD36+S9udO61iI OixXUq8p0CpoaYSFZ1zv9HTLBbu2Yr4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1704173561; bh=2juRjiTk2yf2Invlzo8FhJ7DM0AxRqUdtU6w5CejRpQ=; h=From:To:Cc:Subject:Date:From; b=Y/L8t0BEZ/W9E4wQ8+eUXmBSexrMU4m1q++W2phLH2hRmo0DZWlI5Qf+7t8C4VQs/ cB46jRgqbHaxXyB6cD0szhIWV7M+ejNMHkwCCNSl8OCgCQhkWKUl5sCA+IqkTPLs20 9aYiyjR+vnsRaltJjDlq8uk7D3ySnNntMcEitiyU7G6sMqCae4dv+206znDCkVMiSL Qq6F5nvCdwkQx8OiF3Y613+xjK/ZZy8P9KC4QIM9lvBN1OhmDYZ75JNV1KqdFHPSyt 8wudk/47hy0pnVxwB4idNKG1Pd+m18ESUUrB9h5KebqNXAv+vQwdAeJ8XWaSEuoa7Y 8vzyTpyx6fafg== 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 9A3C83780C21; Tue, 2 Jan 2024 05:32: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] selftests: mm: hugepage-mmap: conform to TAP format output Date: Tue, 2 Jan 2024 10:32:22 +0500 Message-ID: <20240102053223.2099572-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 27E7F140011 X-Stat-Signature: dpdnu96xbh6kziwnrenia95zhazg8gnn X-Rspam-User: X-HE-Tag: 1704173562-331314 X-HE-Meta: U2FsdGVkX1/D6QX1UjN1AiEIhDjFN2fiUN7llLgnAPjh3S3NtBk2+M2FTypJFKAYOhM9hrNYl+lK4r0hLcpA1zaDDq4lW1yY3PW8zf+d2entQXLYuaGhW9Rt0fqoo2qk5mCV0YupYV/kyWgQ1n+HEi2Y/mcUF5yWQgmg/wS5fofOBht5FViID3PnUekZBSK8FRxpyHZD/tO79jRs7WlSJlEA1/LUYQRYJzNdTC7FBDjbT3BuTiTmqrFtiMTjKOrICmfIlKlKJ0+i3LNTSIlP9ffcBS5e3G3IIIwlBQJaDn0/RFPyG2n4DCfmDVT6xLgk+Joevz6eMg20JH6Bi6FMeLWvCPznciD60UeptnEJzUxahE0/yeF+o+IVxeWxhotG7/CmcZDUaUQJAFV8lpEG1IhgRmDC05P2Iv3iiLRLIKQ9MYnyAzkQ5e6VCbyMeUSoFBZHak2BycUFhUgC3vT/jz5vUCJpP9JvlQp90Xgm0/h3OErpcFEHkwXihE0rtQj3XjysP+vIcGasgNvBKjfUvCQalq+hHPi3vpsd8ZTgagnuXIuWoz0XD9fR7cIDH7aSF5bAOZVI1DWgC/Q4nXda8M0+rO/X1mIfxf46bMw+/ETB1ftOn73k2AS1HlT/UDAqCcm2c4XHOHKNzx0S8WbpPHvJ+hyuZs4fbnJSoF+9dx8B4xSjWP6iaEAIWXLi6yxdtFKWIqhb/Q58w40BP89C7LTqMwdaXtsxvKj481wPSa7mB10HD6BuDkk3H9ZnWF447PIECVO95K1ohEe2YOZ3zKUK/U2yGdWyow9Ms0B/eptPqkr5kRBKSVMBjXsKb3hLS/02jGTBrU8mJ4mdRUyg92pi0qgiEGQPUkv+l3QD5LKhIcX9eDpZ8QBlOGNGLq/80qY//ZSzgTUT+5DdW5fNBl3zaaMlB+VqI+SoSthfKCvsbS+F/0dYINLR0Us+SJoMdjPcwxwm7LapG+ss/6y MeGdjm2o PTzgVqPL1aWZalEJIL6AI/iZlGPkoMikcMQdcRDrKWLCyxtPI384YJjb7vBMMwN5AyN9K7zzd+x5sZkZC3iYC2t6r3Z4n2VV+ePjsvcVnrRZP49VszZW79TJwNYBYUXuxgjgq7kdnXjwZvpdPzHisg3Vfzq3dn6RaREw9WQgacPg3kcaJXaWhZ5gRbDQAsrGrdbnN7FgDOS9NKeGNcCtaYT449nwLJWBRmmlGvQ8qe1ttzCEf++9xDbKOIg== 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-mmap.c | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/mm/hugepage-mmap.c b/tools/testing/selftests/mm/hugepage-mmap.c index 955ef87f382c..267eea2e0e0b 100644 --- a/tools/testing/selftests/mm/hugepage-mmap.c +++ b/tools/testing/selftests/mm/hugepage-mmap.c @@ -22,6 +22,7 @@ #include #include #include +#include "../kselftest.h" #define LENGTH (256UL*1024*1024) #define PROTECTION (PROT_READ | PROT_WRITE) @@ -37,7 +38,7 @@ static void check_bytes(char *addr) { - printf("First hex is %x\n", *((unsigned int *)addr)); + ksft_print_msg("First hex is %x\n", *((unsigned int *)addr)); } static void write_bytes(char *addr) @@ -55,7 +56,7 @@ static int read_bytes(char *addr) check_bytes(addr); for (i = 0; i < LENGTH; i++) if (*(addr + i) != (char)i) { - printf("Mismatch at %lu\n", i); + ksft_print_msg("Error: Mismatch at %lu\n", i); return 1; } return 0; @@ -66,20 +67,20 @@ int main(void) void *addr; int fd, ret; + ksft_print_header(); + ksft_set_plan(1); + fd = memfd_create("hugepage-mmap", MFD_HUGETLB); - if (fd < 0) { - perror("memfd_create() failed"); - exit(1); - } + if (fd < 0) + ksft_exit_fail_msg("memfd_create() failed: %s\n", strerror(errno)); addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, fd, 0); if (addr == MAP_FAILED) { - perror("mmap"); close(fd); - exit(1); + ksft_exit_fail_msg("mmap(): %s\n", strerror(errno)); } - printf("Returned address is %p\n", addr); + ksft_print_msg("Returned address is %p\n", addr); check_bytes(addr); write_bytes(addr); ret = read_bytes(addr); @@ -87,5 +88,7 @@ int main(void) munmap(addr, LENGTH); close(fd); - return ret; + ksft_test_result(!ret, "Read same data\n"); + + ksft_exit(!ret); }