Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1588608rdd; Thu, 11 Jan 2024 03:57:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnQMzJpejENUhAC/GJ2qKPb4XC9bdJAqsR53OuayU+OrSM8s3dWlaTPqSEdcto/B+/atRM X-Received: by 2002:a81:6c94:0:b0:5e7:bbdf:2eb4 with SMTP id h142-20020a816c94000000b005e7bbdf2eb4mr345125ywc.103.1704974278236; Thu, 11 Jan 2024 03:57:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704974278; cv=none; d=google.com; s=arc-20160816; b=lkihi1zVPsQtELtNYgQBsOiltxVgGtCcFMcW32yg4Lc2yfqy5dtq6Hl5nNEh5vLGFj SQ7WYljcQVzEmeUh8+BpUcp6mklIm8dlxH4dB8qKdwsHqxTcYJzRDAA8WD9gopMJ3mRB yVuWfEEnyrZsqGRMfr5pOerl3wIiY3ik7zargnE8RYPWC9WUU2+83GjEucvCiYGgCXyO lxzL2dS3ftGoENO11yObc70j4Ch8oCydS+/5QroUIZ5uEmT0e8gHTRdIHsVHbhIY9IjN +CbsAu7sHhHsCxR3nnHV7Fd+pAAMzePORoJpXgJu5KY2p2I4IQTMWb2ZLyI/qTAwG1Ku OgJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=s2SklXwDrfN2CthrOooNixZyo9tqgugJGAtaQibUEUA=; fh=mVBrUHkdhr4FdAuGFuDLONjpBFXQ76Q1/p1ghTG2QxI=; b=dI452rHWVoNtvoehpd2wusR3CVI/aNXC6QEBHX/vbX26fcj8hcZcyBrARHvpk1MPd8 Ed/SzkW1p/2SqcQOWF2AKxTjesfg68eSfBgswh9pS9fxljjwiJVxdIfAvqX4MB2qOCJU dE4XhHeiAj2UDkliO1U9HAq6MNDfKzjrHBQdopQsqYI3BR7JNGz5yd75soyM05SqUlnb y/uIDs34aTsoaDkcfekyMGQkrcHS2oyUBDLRhrfaVPe/1QjJ43PZSk8V9zvylGVcxlms RDiSAtp44CbNLcu8rMOAoV/Rb+W8Uyx26bzltgCZNb/Xfrwb1o/J904C5giE5ez2bmUl 8Hww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YyH92dge; spf=pass (google.com: domain of linux-kernel+bounces-23528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g2-20020ac87d02000000b00429b7c7199esi767063qtb.708.2024.01.11.03.57.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:57:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YyH92dge; spf=pass (google.com: domain of linux-kernel+bounces-23528-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 02A321C2322C for ; Thu, 11 Jan 2024 11:57:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9FE3156F9; Thu, 11 Jan 2024 11:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="YyH92dge" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D7F4156DD; Thu, 11 Jan 2024 11:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(); } -- 2.42.0