Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp383292rdb; Sun, 14 Jan 2024 23:33:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHV8NX9aQvg7gNeI33kMVnGhUK7M9QiHh3RD/KWTLphrAJpAaQ3r/wQDnSZodXP9QMHplo9 X-Received: by 2002:a05:6358:5415:b0:175:5739:5048 with SMTP id u21-20020a056358541500b0017557395048mr5549944rwe.36.1705304007267; Sun, 14 Jan 2024 23:33:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705304007; cv=none; d=google.com; s=arc-20160816; b=jam00VDEdCCmQKiiAB8INP5ERZDxz0lVdYzeb9yxTvKbx3iwDBajgohvLWjPM4h8sq 7VHChnHBWrRQmbn/nxdrfTWmlSsDlVNl3XCjCKaEU+wa6KnJ2F2HwGM7val/GjMNZMWZ +R8y0XXUXZ2P0kTH6ZDlinhl4H41yoFH/Gll1w65chvgAaAmSJuJOO4w1Lo3NPSJu0A3 lf9Lk3aasT1c7YQsF+5x18no2yYD26PU38RnbMPd4l0WRsF3y4ksWoktOs/EBIwdnsYz j2R0xhD2xYMBL83TF1RLLhnli18SjNs0YWKLom9DHUeUmMdwt7ZQZGEGWHIQfKVsRxcU 1VFw== 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=zofluG3LjL4asYeKckMOglQLsLqa23LzSyWAvm0mPL8UjCH2c9puZQGhTjQLUyJwaZ iy2PcgFCOij2WUmdcrG74E3hExW6Vs5aLIq6PD0ElW1CJqq+Kt6xhPzTFg1aHAqAPs1a T7g4G4bN2JTY11IrfUtNr7sj6Mh+M/psRfXnuwovhRj0mPawpEKRVGz88N65sIF73Wl7 VgqPwP6Uv1SqrrUslmkbH9I6TIxUd26c/NLIioBrGmYck/2Fxp0Ntw+1/QYxbGCJnmRD lNYdkR+YSO9ul3Uhf73vbAIypohFMuQAudHo/HaJhq9ZmXxt3T/kxFp/bLq+X2Kd7rSb RyFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=USadmbn7; spf=pass (google.com: domain of linux-kernel+bounces-25687-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25687-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bn6-20020a056a00324600b006d9a69abf0asi7975953pfb.55.2024.01.14.23.33.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 23:33:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25687-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=USadmbn7; spf=pass (google.com: domain of linux-kernel+bounces-25687-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25687-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E3C6A281762 for ; Mon, 15 Jan 2024 07:33:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A05FD63AD; Mon, 15 Jan 2024 07:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="USadmbn7" 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 73ABF4401; Mon, 15 Jan 2024 07:33:08 +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=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> 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