Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6358755rdb; Mon, 1 Jan 2024 21:32:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IENIrRxU/gi+kuYJ2p4wT9lFpwWmU4fbOjf5DtgewxhnLbY68RIFyInmHHPGPLA/oAHPfyR X-Received: by 2002:a50:9349:0:b0:54c:53a6:c49 with SMTP id n9-20020a509349000000b0054c53a60c49mr12008531eda.16.1704173574286; Mon, 01 Jan 2024 21:32:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704173574; cv=none; d=google.com; s=arc-20160816; b=TwfRYFt9wP0dt08s0cCCfDmh4axrAgtHjNjFNPAxq/GrVOx8Y+iRfMRwz4BeZlfiUa 8f6680CcDIiZXEv5KdVi+Ta81r9QoS+37nfln/xSz89tDBTGwGTulScJbTGxRjyN+3v/ XhtuDzm/lqau6oR3LwpQWrfbjKWOuGjCee12/UWjTTOlj4pqd0xRVOkWp5VqGVrnprdT 15UIViavwWimeXolyAAY3znVlJoQHT3s1/oKgOeGrgw1y4RmAf1hp3DlTSaymSSMax2p W8aKWsjAKV0NGRqmOuhsXfqS5Jp/zfFJnJbY2Ys+klWE4QwTXQZlC4KBJ9j4Sz36frjk UrXw== 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=Nhb4I078jQXNS6IcTiCHKfr0oXD7OWZL7aLePC4KFhc=; fh=mVBrUHkdhr4FdAuGFuDLONjpBFXQ76Q1/p1ghTG2QxI=; b=jkqyxwdE7eU6VUom6URpuEb9fbmdctN3d8bcWNAW2DWyZMlOVaIaWBmxPSIx/80oC0 muu/0twPGWGn1Vu4rufUlJDDFwxEYG3Q8ytQsDQFmOnjizHBHe6Cp5xe9rBJgMI/LIFs RD79KKX8IOXm4GDrr/EOb6p6wIJg30SfwUQQYSvWm6wrR3rgW2r+s80wtABSAajF3rde qrWWclO21lxb1/YDMRfE7V2N7Brwr50D4njd2YURQoK+7xBAPxFkjUS3d7A6QDNOWGwh PsrtYwaQkpYaB9sWnbh1qzXEmE3X6EeF9LEFaWjSCPNLBd/sunB3QkRXRHoie211iIQb MEoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Y/L8t0BE"; spf=pass (google.com: domain of linux-kernel+bounces-14051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14051-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m5-20020a056402430500b0055404aa7d88si11122038edc.164.2024.01.01.21.32.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 21:32:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Y/L8t0BE"; spf=pass (google.com: domain of linux-kernel+bounces-14051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14051-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0A3C31F21A6C for ; Tue, 2 Jan 2024 05:32:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7005111E; Tue, 2 Jan 2024 05:32:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="Y/L8t0BE" X-Original-To: linux-kernel@vger.kernel.org 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 8C20423C3; Tue, 2 Jan 2024 05:32:44 +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=1704173561; bh=2juRjiTk2yf2Invlzo8FhJ7DM0AxRqUdtU6w5CejRpQ=; h=From:To:Cc:Subject:Date:From; b=Y/L8t0BEZ/W9E4wQ8+eUXmBSexrMU4m1q++W2phLH2hRmo0DZWlI5Qf+7t8C4VQs/ cB46jRgqbHaxXyB6cD0szhIWV7M+ejNMHkwCCNSl8OCgCQhkWKUl5sCA+IqkTPLs20 9aYiyjR+vnsRaltJjDlq8uk7D3ySnNntMcEitiyU7G6sMqCae4dv+206znDCkVMiSL Qq6F5nvCdwkQx8OiF3Y613+xjK/ZZy8P9KC4QIM9lvBN1OhmDYZ75JNV1KqdFHPSyt 8wudk/47hy0pnVxwB4idNKG1Pd+m18ESUUrB9h5KebqNXAv+vQwdAeJ8XWaSEuoa7Y 8vzyTpyx6fafg== 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 9A3C83780C21; Tue, 2 Jan 2024 05:32:39 +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] selftests: mm: hugepage-mmap: conform to TAP format output Date: Tue, 2 Jan 2024 10:32:22 +0500 Message-ID: <20240102053223.2099572-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. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/hugepage-mmap.c | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/mm/hugepage-mmap.c b/tools/testing/selftests/mm/hugepage-mmap.c index 955ef87f382c..267eea2e0e0b 100644 --- a/tools/testing/selftests/mm/hugepage-mmap.c +++ b/tools/testing/selftests/mm/hugepage-mmap.c @@ -22,6 +22,7 @@ #include #include #include +#include "../kselftest.h" #define LENGTH (256UL*1024*1024) #define PROTECTION (PROT_READ | PROT_WRITE) @@ -37,7 +38,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) @@ -55,7 +56,7 @@ static int read_bytes(char *addr) check_bytes(addr); for (i = 0; i < LENGTH; i++) if (*(addr + i) != (char)i) { - printf("Mismatch at %lu\n", i); + ksft_print_msg("Error: Mismatch at %lu\n", i); return 1; } return 0; @@ -66,20 +67,20 @@ int main(void) void *addr; int fd, ret; + ksft_print_header(); + ksft_set_plan(1); + fd = memfd_create("hugepage-mmap", MFD_HUGETLB); - if (fd < 0) { - perror("memfd_create() failed"); - exit(1); - } + if (fd < 0) + ksft_exit_fail_msg("memfd_create() failed: %s\n", strerror(errno)); addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, fd, 0); if (addr == MAP_FAILED) { - perror("mmap"); close(fd); - exit(1); + 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); ret = read_bytes(addr); @@ -87,5 +88,7 @@ int main(void) munmap(addr, LENGTH); close(fd); - return ret; + ksft_test_result(!ret, "Read same data\n"); + + ksft_exit(!ret); } -- 2.42.0