From patchwork Wed Jan 31 14:05:12 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: 13539490 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 C48D0C47DB3 for ; Wed, 31 Jan 2024 14:05:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AFCF6B0075; Wed, 31 Jan 2024 09:05:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5106A6B0089; Wed, 31 Jan 2024 09:05:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B0776B008A; Wed, 31 Jan 2024 09:05:22 -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 29ED66B0075 for ; Wed, 31 Jan 2024 09:05:22 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B26A2140D3A for ; Wed, 31 Jan 2024 14:05:21 +0000 (UTC) X-FDA: 81739778442.12.AEE8A3D Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf05.hostedemail.com (Postfix) with ESMTP id BF46510002E for ; Wed, 31 Jan 2024 14:05:19 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=h5UcZbpz; spf=pass (imf05.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=1706709920; 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=FUJjFRsxZtoV0TJs1XWVM73qLuJ0XkK/GMGOZYBkEtc=; b=xuKgxH7pc9HSel8SIXF2SKdiHKWQYFr28hLIX4Ao/Q+XOnMk44ZdUN4r2rBwGyXxfl7CDp NDMWCKDWz7Vg0+c3B8YYsyKKQnrIxT13Ro0XHuq9FJGgr6SgL7FfT5tBiDEk7M0mYzZ9Xw ctIukx9Uy9Q4fFAWRuIgt4d6Q6xaFio= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706709920; a=rsa-sha256; cv=none; b=edn3hSpvmE5qnB/hcDYx5c/C/E0CaV//eAk0xXSPOmB2gudl+MA5kw6VEUSZ9Rp0o1yBq9 QyOr4UDZBkM4B+wYawgiVGj6zIQ0RZls7sTMcXuyss/gGfypSE4QnhVe71+5wJunSggtv1 m4/hEuOOZPHDm8UY8J45RgSK+vgSqp4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=h5UcZbpz; spf=pass (imf05.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706709918; bh=svTlCA3lz9tOssty2sVCUQ4b7cMa6+0k/VLIT1J7+9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h5UcZbpzz5WlVb6jsielorPLdi7v9/5hx+xUipMprgD+tt9/1YkFLdd7AoC6TPQD2 NcHFBo3gJQVxh7DMj5VVABkH8bWv78M2C/pj4/9cYseG2EGjirR5Ge6NtKUmIO+Lk1 HJDbWdNJx/ipBXngFurJcHtqlDx+MnfotdHuxskbV+P5KCqGTnzjfR2vaV2sqXjP2s XkvGMKGKGgioz+Yto7G22wbUCJKIJ629n4HIFURwALHAb7kBdlNkoMlOwxXwwixab4 mqjs6T3SNxuWD0Xuz5r8aX3sdSIZmlPHXu+180DZ14ycRcfzHfHHRyh18Rw+hDbzYD gmQBMl4TqlH1Q== 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 D3794378200E; Wed, 31 Jan 2024 14:05:16 +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 02/12] selftests/mm: map_hugetlb: conform test to TAP format output Date: Wed, 31 Jan 2024 19:05:12 +0500 Message-ID: <20240131140528.320252-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240131140528.320252-1-usama.anjum@collabora.com> References: <20240131140528.320252-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: BF46510002E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5u6wrgxogiy1w6fdqwrmuagooi4419bp X-HE-Tag: 1706709919-531527 X-HE-Meta: U2FsdGVkX18OdIxi5sQDu5Wh53REuvRDIyQRsMKu5fT7SSqgeaIUKt1CR1Mvfo3Wl2pUGyI2F7+aLS7ZiaTxasmCTaSNipnF68zd1qmyS3P491pP3PgJzVytvB1FFp4YnYI6qZF2xWQYhQ6NiwOw5HnwY38mz/FHPSGy1h6gnxXYXBncOiMvF0SaMdPEc2MDU8PVfXtwOb9yVy6XwzT82tECqy3+BzFp9mAhA/ecHAMTsAm8E1e1L8tH2b/BfJh7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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/map_hugetlb.c | 42 +++++++++++------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/mm/map_hugetlb.c b/tools/testing/selftests/mm/map_hugetlb.c index 86e8f2048a409..a1f005a90a4f0 100644 --- a/tools/testing/selftests/mm/map_hugetlb.c +++ b/tools/testing/selftests/mm/map_hugetlb.c @@ -16,6 +16,7 @@ #include #include #include "vm_util.h" +#include "../kselftest.h" #define LENGTH (256UL*1024*1024) #define PROTECTION (PROT_READ | PROT_WRITE) @@ -31,7 +32,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, size_t length) @@ -42,23 +43,21 @@ static void write_bytes(char *addr, size_t length) *(addr + i) = (char)i; } -static int read_bytes(char *addr, size_t length) +static void read_bytes(char *addr, size_t length) { unsigned long i; check_bytes(addr); for (i = 0; i < length; i++) - if (*(addr + i) != (char)i) { - printf("Mismatch at %lu\n", i); - return 1; - } - return 0; + if (*(addr + i) != (char)i) + ksft_exit_fail_msg("Mismatch at %lu\n", i); + + ksft_test_result_pass("Read correct data\n"); } int main(int argc, char **argv) { void *addr; - int ret; size_t hugepage_size; size_t length = LENGTH; int flags = FLAGS; @@ -69,6 +68,9 @@ int main(int argc, char **argv) if (hugepage_size > length) length = hugepage_size; + ksft_print_header(); + ksft_set_plan(1); + if (argc > 1) length = atol(argv[1]) << 20; if (argc > 2) { @@ -78,27 +80,23 @@ int main(int argc, char **argv) } if (shift) - printf("%u kB hugepages\n", 1 << (shift - 10)); + ksft_print_msg("%u kB hugepages\n", 1 << (shift - 10)); else - printf("Default size hugepages\n"); - printf("Mapping %lu Mbytes\n", (unsigned long)length >> 20); + ksft_print_msg("Default size hugepages\n"); + ksft_print_msg("Mapping %lu Mbytes\n", (unsigned long)length >> 20); addr = mmap(ADDR, length, PROTECTION, flags, -1, 0); - if (addr == MAP_FAILED) { - perror("mmap"); - exit(1); - } + if (addr == MAP_FAILED) + 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, length); - ret = read_bytes(addr, length); + read_bytes(addr, length); /* munmap() length of MAP_HUGETLB memory must be hugepage aligned */ - if (munmap(addr, length)) { - perror("munmap"); - exit(1); - } + if (munmap(addr, length)) + ksft_exit_fail_msg("munmap: %s\n", strerror(errno)); - return ret; + ksft_finished(); }