Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1588552rdd; Thu, 11 Jan 2024 03:57:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGBo/u2t4QJbpe9NaExHR/LD4ZD43Stj1kuUiOxjefm68MmdTDyZVZjUuqXzrhZft/yGh8 X-Received: by 2002:a05:6a21:2792:b0:19a:2bda:7273 with SMTP id rn18-20020a056a21279200b0019a2bda7273mr706857pzb.84.1704974269925; Thu, 11 Jan 2024 03:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704974269; cv=none; d=google.com; s=arc-20160816; b=BV1wcsFpV3ct59oPLZEXQvF9pvIoS7Y5snvoWh+eKBb7QShJ8z/iIcmRZse7DtQZiS h3gOwaZH2v4W5RIYp7WSgwJHn2nD09QuqktK7M7JaSb6vKDAwdQQLnQg0LUajEVA8eHc 4nczIx8mrUswWTBHRASQgmzlSNDCIctfaMYP1N67EN0LCxLhW3kUXQyrzVAD4xx8nJmI qTeYerSeqQfK8RPtndm2wEEGt+rw2aYGqwpIXmYAj9iCsGQpgdV5PFtECCiTSEjta9Zo 4BvdPiJjk1NlsLzdEOR1KaD99HblsUcjtug3DEtA2HjUCMvMmQC6WkD4Y4hrngiZ8+bZ nMJQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=KEdkNivyIg3PurhJ3VjHntzXTr+Tal6Xval7en+bt2s=; fh=mVBrUHkdhr4FdAuGFuDLONjpBFXQ76Q1/p1ghTG2QxI=; b=07cyJVcTBdKl9SAlqWjRhAW3rz/mRzFiHTC/XPGrm4VXDZI3jrgRmtjKhX3QGucsQd elfmAXDy5i3yWL4w1Pje9izvGw5dh0y5uAxWgpZD/yLpJLxgJOpboR7q/Lb+G1iOCH8F 9oK6VcFrm25WXKbXHdBAKAw0qlkfWMLJR/e+orfcwodaoLNgGLNSZqSJT6tmpqMnhw1/ SK6zyTYf+hntRzBv+Pg2Od6l3j+AwnnCHzX8AAgsjwdgb69yBKrNnJr3cYPWoyR8o1/W /D7yUKQNgSSZ6hmlkr1fpdXgdnXUtZG7pBxFxZ3f5aT+bsHuoTvE8++uMX9DaRyFFAz7 YyQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZSa9qy7T; spf=pass (google.com: domain of linux-kernel+bounces-23527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b5-20020a17090a9bc500b0028cbf77fc55si936807pjw.104.2024.01.11.03.57.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:57:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZSa9qy7T; spf=pass (google.com: domain of linux-kernel+bounces-23527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23527-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 020C8B21850 for ; Thu, 11 Jan 2024 11:57:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92182156CD; Thu, 11 Jan 2024 11:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="ZSa9qy7T" 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 24C9F154AC; Thu, 11 Jan 2024 11:57:36 +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=1704974255; bh=rRQZLwAtR4o/VCOAcxTzVSxdZ70bLgI9faWJJSJCsAc=; h=From:To:Cc:Subject:Date:From; b=ZSa9qy7Tl9zR64Qk9SDK6NPPOQBrzuuwsbhm3ASkRxLSEX697ewBw5gAVzlmlRKPT GOysylcxC/VF0/iodKdVsdSwxKl10VbKYgjyh95ntez4wUTALdQgndOCTgoo8MX2Wy 7mEHqSeuw59iX+8bFLDK6Meh50irC3QYn5AaPZVbMXs5Ey1+/LWwHQ66snbhCZgLA5 VBzcW08jGuJFn0SjoUXr/T3OMXil63gF9e0K2dNOg7LgLs8ik2OBVww6D/G+Mnn3XC figD78k9CAo2SC4FXRj5LNOotc1bojTHrP5AutXeI2mLokdmkKD2xWyTo5zIpOWylE wCDITlgc9Bp6w== 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 A519A3781182; Thu, 11 Jan 2024 11:57:32 +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 1/7] selftests/mm: hugepage-shm: conform test to TAP format output Date: Thu, 11 Jan 2024 16:56:30 +0500 Message-ID: <20240111115639.3981970-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 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. The "." was being printed inside for loop to indicate the writes progress. This was extraneous and hence removed in the patch. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/hugepage-shm.c | 47 +++++++++++------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/mm/hugepage-shm.c b/tools/testing/selftests/mm/hugepage-shm.c index 478bb1e989e9..f949dbbc3454 100644 --- a/tools/testing/selftests/mm/hugepage-shm.c +++ b/tools/testing/selftests/mm/hugepage-shm.c @@ -34,11 +34,10 @@ #include #include #include +#include "../kselftest.h" #define LENGTH (256UL*1024*1024) -#define dprintf(x) printf(x) - /* Only ia64 requires this */ #ifdef __ia64__ #define ADDR (void *)(0x8000000000000000UL) @@ -54,44 +53,42 @@ int main(void) unsigned long i; char *shmaddr; + ksft_print_header(); + ksft_set_plan(1); + shmid = shmget(2, LENGTH, SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W); - if (shmid < 0) { - perror("shmget"); - exit(1); - } - printf("shmid: 0x%x\n", shmid); + if (shmid < 0) + ksft_exit_fail_msg("shmget: %s\n", strerror(errno)); + + ksft_print_msg("shmid: 0x%x\n", shmid); shmaddr = shmat(shmid, ADDR, SHMAT_FLAGS); if (shmaddr == (char *)-1) { - perror("Shared memory attach failure"); shmctl(shmid, IPC_RMID, NULL); - exit(2); + ksft_exit_fail_msg("Shared memory attach failure: %s\n", strerror(errno)); } - printf("shmaddr: %p\n", shmaddr); - dprintf("Starting the writes:\n"); - for (i = 0; i < LENGTH; i++) { + ksft_print_msg("shmaddr: %p\n", shmaddr); + + ksft_print_msg("Starting the writes:"); + for (i = 0; i < LENGTH; i++) shmaddr[i] = (char)(i); - if (!(i % (1024 * 1024))) - dprintf("."); - } - dprintf("\n"); + ksft_print_msg("Done.\n"); - dprintf("Starting the Check..."); + ksft_print_msg("Starting the Check..."); for (i = 0; i < LENGTH; i++) - if (shmaddr[i] != (char)i) { - printf("\nIndex %lu mismatched\n", i); - exit(3); - } - dprintf("Done.\n"); + if (shmaddr[i] != (char)i) + ksft_exit_fail_msg("\nIndex %lu mismatched\n", i); + ksft_print_msg("Done.\n"); if (shmdt((const void *)shmaddr) != 0) { - perror("Detach failure"); shmctl(shmid, IPC_RMID, NULL); - exit(4); + ksft_exit_fail_msg("Detach failure: %s\n", strerror(errno)); } shmctl(shmid, IPC_RMID, NULL); - return 0; + ksft_test_result_pass("Completed test\n"); + + ksft_finished(); } -- 2.42.0