From patchwork Wed Jan 31 14:05:11 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: 13539489 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 144AFC47258 for ; Wed, 31 Jan 2024 14:05:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97DFE6B0088; Wed, 31 Jan 2024 09:05:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92DA66B0089; Wed, 31 Jan 2024 09:05:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CEFB6B008A; Wed, 31 Jan 2024 09:05:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6F3026B0088 for ; Wed, 31 Jan 2024 09:05:20 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 498BBA0D6C for ; Wed, 31 Jan 2024 14:05:20 +0000 (UTC) X-FDA: 81739778400.03.DD7BB7E Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf21.hostedemail.com (Postfix) with ESMTP id 8CF811C000F for ; Wed, 31 Jan 2024 14:05:17 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=hVRTdRod; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf21.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=1706709917; a=rsa-sha256; cv=none; b=v35yFxxXgfON7o9vgVWuB6AD/8v6gqNdZaCrPQidDMaBwCT/ZBxIvBquGGpwchqGx6HcBb 6P1v5IDIUETHEcLy4wb7o1iyKDEySOMYnwZnJ6YrxSYw/QAI7ANw5Wksq20NUfFjKG2akn 9d9dpgFQ8aNCmi81DFGORoIqI23PB4g= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=hVRTdRod; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf21.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=1706709917; 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=rs3JITGukBvqtMUpSjOqaaofsqqmPPqDr32jEpjdRB4=; b=t3QEgCiv5jBFYVRR/o0WOAq6INESMGEYuDRS/Td6q21nW+UCttIqbGzB0svWnaFKp0J3zh yHizOhZ8CiT2CfQxAz9GYD9S/+YGs8USHKRRJvnIB1shP2SkjbVAzgXsLIsDt0QTbwPRg/ 0l7Gkiqrc6Zd7hHGfR9jT90FZrcpbFs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706709916; bh=C1jyyNN3WoASzPdbjbyMPpmrKLB566vijGdtqZFTW+0=; h=From:To:Cc:Subject:Date:From; b=hVRTdRodufiiXRyUTw9piPgw/oM92aLsJkDJGNDDTsunq7gJopZrnj+e3uqM09Ifw k0w0zc9ThSlxrYjasOBccPbbcGyeFCFKGuOcVC5KieK9Sp4aGF33D6MfyXTLlTrZyb dhTHrGWeb4FM7XQNVxruHPijt+Fkg/nEm98o5ebb8XFF8Qt/cXkO4XSlC3ndGxv0S2 oqaGai6ttvc6I60U/yqwE/TZ0j0LPMR46ap6XGlfAdWeChx84aXANCMFs6mYsw70DT FjeAPcOuZmZ8KNZfI5GISi+BwMX4fEXehcftq/U7JIgfeAVesXIjXx8CTEtZ+dnC9a BsGRGSxhSpIMg== 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 8243E3781FCF; Wed, 31 Jan 2024 14:05:14 +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 01/12] selftests/mm: map_fixed_noreplace: conform test to TAP format output Date: Wed, 31 Jan 2024 19:05:11 +0500 Message-ID: <20240131140528.320252-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8CF811C000F X-Stat-Signature: ytdxp7euotbrdrdfwir6eaita8xd9saw X-HE-Tag: 1706709917-257162 X-HE-Meta: U2FsdGVkX1+kmeCJcFK5ZphPj72Fj/brSKscrs4KOfnVi26uyLI1rgCkUFNt1JWhSHBbdUbtuzfb4J6Yf5OzH/ZMqR0wAaqha0qT5WHMDbFAZBArXQcso3bGdduefoOHUS0jE6AybRFRk2IEOwv9WFpOi59fuMaLmzonvjsXK8tW5v7rgwJ3WtHiHaIZpvbpdjHrhiZqrQS5WsA2kOk3ajjmlnkqJKfEkEcF2PEHw/qcJz+C0TnA21Y6xe8j5tJKyZnmr+FLqEJOMLXysB4V4BhOxSo24WFUsD80zMHcc4L6GfUwnryhaH7zS0E1HTZzyTz2tEZ0qrLGiuXKlYi4CLwIjP8J8qr1VbE841w1MQhjl2gQvTPLqpAo7mIRJj+njLlq7qNsP08KJEHBRd9oqonZZ8XaMGXP7dGf5B5zQypYNTpxSWubts8rKG5yGNjrtBL4ZEvhiEe+GhXfV7klYmYfZpa2j1l6jOQRF54gxK3GynwqZ/lroQ9ahnRTsU/pjo0LW3A3stj5A3QIVQEfju5XzX4PK79ucslat1tGEsbHgIy9400exq0p9reSshyUta9qxi4cc0Eokp/PJaZlJQN2s6BeyRLFHa3vqIdDqcwDMQETeioaH4/pbgksbnFLHmuTMBi/9L9kvNRxGf86LZdaB1POFaY1lyBg6g0HuQ0pgVrpWd3EewpB8w/ZYzCf3FdetqL5QHRYl3b4BeE5mkY2Yw3SowGJUpYAY6B9ddTHJOoffujAQa2P/2EKN8fe3wyynKSDl32WvjbeWRlW7A41N//sThYaZpIhb+HfcIhaX7ZZmIKMjAuMqF4fRh0ZlGMH2qVK89zDuFGqDieCh2aglMfkeaC0hiT5YK6CPspsOjlyggZXflRBJ05fhGWa8Adz26/cT1qLEcB281h0W5jMCRESTEeAZhHTktq7K5pyt68EC6GEqinaF1oIKmy1u7OpjZzqeRReQ7HlM6B bOjpXCtJ G67pzqMXzcsmyuo8/8aoEUy/VbO4M7Q8Kecdxt0oZibpQNUSyp2jDGxNTB9KM7eQ7fRrxYXxomxUpOTLjzWXDuwxMD/NmMaUARVRnEJ/ULOylKlxxc+xxeSjTOyQbEpT6LnENQax+6JY5oJh45TO3X4vsv/RinAkfb+CkGgwkP/LrTbXNCIwUdvqEo1heB9iyxUoC43D8I/c/Hen6zri1p0m4+V0ds+3wibFWbMCbpe2daQClMuir5kGX7eKhsy1fkkrzS4EZdsf6DbQYUljKy3BHMYeRVdqYmwj6pUhGhYfT5tk= 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. While at it, convert commenting style from // to /**/. Signed-off-by: Muhammad Usama Anjum --- .../selftests/mm/map_fixed_noreplace.c | 96 ++++++------------- 1 file changed, 31 insertions(+), 65 deletions(-) diff --git a/tools/testing/selftests/mm/map_fixed_noreplace.c b/tools/testing/selftests/mm/map_fixed_noreplace.c index 598159f3df1f2..b74813fdc9514 100644 --- a/tools/testing/selftests/mm/map_fixed_noreplace.c +++ b/tools/testing/selftests/mm/map_fixed_noreplace.c @@ -12,6 +12,7 @@ #include #include #include +#include "../kselftest.h" static void dump_maps(void) { @@ -28,15 +29,12 @@ static unsigned long find_base_addr(unsigned long size) flags = MAP_PRIVATE | MAP_ANONYMOUS; addr = mmap(NULL, size, PROT_NONE, flags, -1, 0); - if (addr == MAP_FAILED) { - printf("Error: couldn't map the space we need for the test\n"); - return 0; - } + if (addr == MAP_FAILED) + ksft_exit_fail_msg("Error: couldn't map the space we need for the test\n"); + + if (munmap(addr, size) != 0) + ksft_exit_fail_msg("Error: munmap failed\n"); - if (munmap(addr, size) != 0) { - printf("Error: couldn't map the space we need for the test\n"); - return 0; - } return (unsigned long)addr; } @@ -46,51 +44,39 @@ int main(void) unsigned long flags, addr, size, page_size; char *p; + ksft_print_header(); + ksft_set_plan(9); + page_size = sysconf(_SC_PAGE_SIZE); - //let's find a base addr that is free before we start the tests + /* let's find a base addr that is free before we start the tests */ size = 5 * page_size; base_addr = find_base_addr(size); - if (!base_addr) { - printf("Error: couldn't map the space we need for the test\n"); - return 1; - } flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE; - // Check we can map all the areas we need below - errno = 0; + /* Check we can map all the areas we need below */ addr = base_addr; size = 5 * page_size; p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0); - - printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - if (p == MAP_FAILED) { dump_maps(); - printf("Error: couldn't map the space we need for the test\n"); - return 1; + ksft_exit_fail_msg("Error: couldn't map the space we need for the test\n"); } - - errno = 0; if (munmap((void *)addr, 5 * page_size) != 0) { dump_maps(); - printf("Error: munmap failed!?\n"); - return 1; + ksft_exit_fail_msg("Error: munmap failed!?\n"); } - printf("unmap() successful\n"); + ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - errno = 0; addr = base_addr + page_size; size = 3 * page_size; p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0); - printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - if (p == MAP_FAILED) { dump_maps(); - printf("Error: first mmap() failed unexpectedly\n"); - return 1; + ksft_exit_fail_msg("Error: first mmap() failed unexpectedly\n"); } + ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); /* * Exact same mapping again: @@ -100,17 +86,14 @@ int main(void) * +3 | mapped | new * +4 | free | new */ - errno = 0; addr = base_addr; size = 5 * page_size; p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0); - printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - if (p != MAP_FAILED) { dump_maps(); - printf("Error:1: mmap() succeeded when it shouldn't have\n"); - return 1; + ksft_exit_fail_msg("Error:1: mmap() succeeded when it shouldn't have\n"); } + ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); /* * Second mapping contained within first: @@ -121,17 +104,14 @@ int main(void) * +3 | mapped | * +4 | free | */ - errno = 0; addr = base_addr + (2 * page_size); size = page_size; p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0); - printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - if (p != MAP_FAILED) { dump_maps(); - printf("Error:2: mmap() succeeded when it shouldn't have\n"); - return 1; + ksft_exit_fail_msg("Error:2: mmap() succeeded when it shouldn't have\n"); } + ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); /* * Overlap end of existing mapping: @@ -141,17 +121,14 @@ int main(void) * +3 | mapped | new * +4 | free | new */ - errno = 0; addr = base_addr + (3 * page_size); size = 2 * page_size; p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0); - printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - if (p != MAP_FAILED) { dump_maps(); - printf("Error:3: mmap() succeeded when it shouldn't have\n"); - return 1; + ksft_exit_fail_msg("Error:3: mmap() succeeded when it shouldn't have\n"); } + ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); /* * Overlap start of existing mapping: @@ -161,17 +138,14 @@ int main(void) * +3 | mapped | * +4 | free | */ - errno = 0; addr = base_addr; size = 2 * page_size; p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0); - printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - if (p != MAP_FAILED) { dump_maps(); - printf("Error:4: mmap() succeeded when it shouldn't have\n"); - return 1; + ksft_exit_fail_msg("Error:4: mmap() succeeded when it shouldn't have\n"); } + ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); /* * Adjacent to start of existing mapping: @@ -181,17 +155,14 @@ int main(void) * +3 | mapped | * +4 | free | */ - errno = 0; addr = base_addr; size = page_size; p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0); - printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - if (p == MAP_FAILED) { dump_maps(); - printf("Error:5: mmap() failed when it shouldn't have\n"); - return 1; + ksft_exit_fail_msg("Error:5: mmap() failed when it shouldn't have\n"); } + ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); /* * Adjacent to end of existing mapping: @@ -201,27 +172,22 @@ int main(void) * +3 | mapped | * +4 | free | new */ - errno = 0; addr = base_addr + (4 * page_size); size = page_size; p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0); - printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); - if (p == MAP_FAILED) { dump_maps(); - printf("Error:6: mmap() failed when it shouldn't have\n"); - return 1; + ksft_exit_fail_msg("Error:6: mmap() failed when it shouldn't have\n"); } + ksft_test_result_pass("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p); addr = base_addr; size = 5 * page_size; if (munmap((void *)addr, size) != 0) { dump_maps(); - printf("Error: munmap failed!?\n"); - return 1; + ksft_exit_fail_msg("Error: munmap failed!?\n"); } - printf("unmap() successful\n"); + ksft_test_result_pass("Base Address unmap() successful\n"); - printf("OK\n"); - return 0; + ksft_finished(); }