From patchwork Mon Jan 15 07:32:37 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: 13519364 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 098B2C47258 for ; Mon, 15 Jan 2024 07:33:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 014426B0078; Mon, 15 Jan 2024 02:33:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F06376B0080; Mon, 15 Jan 2024 02:33:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF4EF6B0081; Mon, 15 Jan 2024 02:33:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D125A6B0078 for ; Mon, 15 Jan 2024 02:33:08 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 988AAC02B4 for ; Mon, 15 Jan 2024 07:33:08 +0000 (UTC) X-FDA: 81680729256.16.64876F5 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf29.hostedemail.com (Postfix) with ESMTP id 1693012000A for ; Mon, 15 Jan 2024 07:33:05 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=GXO9YEPS; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf29.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=1705303986; 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=KEdkNivyIg3PurhJ3VjHntzXTr+Tal6Xval7en+bt2s=; b=B9gORzfcBNH6c5A6FzbElCWIuY+WOi9nX68lTT8ZJz4jA7zHS2F1OofxMWFPh0sL0rjPvj xKQzKsrgALgTdFGdMRJ7FzaD9uEjMcgL7GkAwRm+1K843/DqpJSOe9k8lAbcV1J6RM5iak VOmkKGx2u0bJ2Ra5rf/Ewk8AabkZKq4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=GXO9YEPS; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf29.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=1705303986; a=rsa-sha256; cv=none; b=7DdTjFyW1CdnIyos/qL2+IIC3SPpv8cIBIcd7UU3aV4RQOgHIoIB4dLsaWoEbB0K6Y6/+F tUMXuEIIYKhTTrwOAZLTGJVqNDsanlq/ei3iL96w9c2g/52ILzxZMHKkAFq2GVgJvPABxu gAMYN4D2ZMBaffOgmHWBZvfiY9tE3y8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1705303984; bh=rRQZLwAtR4o/VCOAcxTzVSxdZ70bLgI9faWJJSJCsAc=; h=From:To:Cc:Subject:Date:From; b=GXO9YEPS9ah8KzQBBmYq2zTQ8EXx61CYFKebrzMonKYCXxDbjWZTjw7hHmB00Irk4 qG4tgLvhIH/RZlwBB/Us60q5DJWpt+EgCDQiD6mj3stX0zVEiIBZPXAXOkz1OebYVi SWvpwFyk+zxxpuufBiddr/mgfEpmFBKEhnhpB5H+LjpQm9rGth+Nqnlsem98XSw+84 edi3gQdsTxJwMcFw71BUCVdkhtPOunql0K3TLyAnOmek8pRNGhSqpvSMW9b6zyC0YA sHvs+MzaU9+NKaVOM/0ZAwvcaaygPhcB24md/WrHWhslctzLv4F51+qv6Iiq8Efqrr 8jtdxvayhgIIA== 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 DFFA737813DD; Mon, 15 Jan 2024 07:33:02 +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 1/7] selftests/mm: hugepage-shm: conform test to TAP format output Date: Mon, 15 Jan 2024 12:32:37 +0500 Message-ID: <20240115073247.1280266-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1693012000A X-Stat-Signature: gdtzqbwe4dxm6tpnazftrackixqo3py3 X-HE-Tag: 1705303985-300258 X-HE-Meta: U2FsdGVkX18Or0X5rMsAJZIoGH7rJdYw6w2WoIRHAd/syl3mYOSZmGeCnB/m9D1H5QpNDyfl6fpyVTTwcIaAn87M7FsBd0d2FbPmy/2QyJhO+1cnrs1l9GHXybmI2zY+4htNyxGDgbzYglcMYJLLjet+WcdjDUpwaedMAPjR8SjpxxydCYcXGo6/DA7E8OhjlEXODWNKTTs9cmYBMhh7d3DaQfgWsk48VQfEZ6p/01Ul+40GLE1dB//RWfn5C1tYkkSrxV31BqGt8ph6qkmhnO1MmRCHogzNGENbnNHQ1+g9xBSqv4YdRxbsYhtm7/eTysQzVA5ZZIKu5WDrGim1Vdj0vHdSf5T4VAyaBa/7B5ArzMOsdjVqfiCXGUXtP9IkRVCcWiK+EMNdEja03CR95VC1sYnC2XCdFAxA+vJDROc7A6xXJetIizPaKf5ZHZJ9yeGiAHXbqbKAmpXO6u4PzyN0D6RCLbXspWt4JOQ9lETJqcDxVRnfvTuqxNDbTgmtaGH+n3plZRJqd/SBt3WZUKh3cfiZFESAUwnTc3S3SDH+JpbK3ZbNfc4qpDF8CWFQLIO53uZSm7kprAi76nioCaE3uMWWXfbTO/fp4+r9D2jPtrqI6VYOWSN5JbafBl88m17DuMZoWHhk2nLxH/smmA4nLqR4C43cZN+55jNwMmdsIEHCZ6BBndwJfVmWG8IabJphweIpy3FHpkrOUKLC4HJAkAl/t//dinz5iSZ03uJPQJ4MxvdIlrc9xdjKmJuI7KXzSqizARlbMpN8ouiDLsKV+ucYkt7EM64ONV/j8d+NieBKYuczpG+JlQxFt+4v+RqadXXVdkX0lD8u2/ZgPvp6HPbx7mnZ1pHUtWAgU4dMGzbSm5shg+IcQSpQGoAcSHyMI+3PFJ3jG9LCeuXc8noIvtzXVaZtIMHo0/M4XvcPIOd7+vxZfg== 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. 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(); }