From patchwork Wed Jan 31 14:05:13 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: 13539491 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 EAFA2C47DDF for ; Wed, 31 Jan 2024 14:05:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7867A6B008C; Wed, 31 Jan 2024 09:05:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 671686B0092; Wed, 31 Jan 2024 09:05:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44CB06B0093; Wed, 31 Jan 2024 09:05:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2C0596B008C for ; Wed, 31 Jan 2024 09:05:24 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C9E2E160D66 for ; Wed, 31 Jan 2024 14:05:23 +0000 (UTC) X-FDA: 81739778526.04.299402D Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf19.hostedemail.com (Postfix) with ESMTP id E51741A001B for ; Wed, 31 Jan 2024 14:05:21 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=TydsDK21; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf19.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=1706709922; 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=wTJHNbNNuZU9yzkNFtgw/kC1FsKjxHF0kk1Dqavy8AM=; b=K9NDyoXAo9J+1CYXUfXzYn7tlyWQx1aPknKVuDX31xPnd94tXtr4IWQgVkMOLuuxFf9sMD jV2Ist9ZxGH/+rKbgRiCdK2DGm+J+4fDn+HtzZAVBgq7BhTwZkZm3h6GRlGpprFm3P2+C7 L6bhTwlnQkMHHhdIu53V565F8tTjpX4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=TydsDK21; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf19.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=1706709922; a=rsa-sha256; cv=none; b=UDluisjbhaS0Bw15yzwtl6mG4Lb+hdmua5JMVTq35ZSxYeKl0YdhQ1onYJ4rhEFIJNnMGF t+OnBCKrnaQGZqW4/fAkWM6Mp6Md3SY1+JhrDKIplUaA6lt+q5g5T9VeFXZvZbQgqo7/C0 wFj2nxfCaQ/7wCms+kNS3zvgEcTExa8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706709920; bh=y0GUUHT+6utzfuC41fyJPiGU8siNhU+amnQRcBTcLQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TydsDK21IR1M/HEfLjaeAwPydIwVfgkYpQrRlisH5h7CKSnNqUrb8yLIaTLRtOGA3 vVDlayJJdepGiAI3j+/jmvU6bDTp56gAypnE6+MOb0uHymoOqGeqmeuorjZ/2PQ+O8 RLHJSPQsUIo7/+DEtNeY4tS5C85g/3dj1rFS+tFPgRRTwHrP+kXUQIFR3/0n8ZPIsu duAdQ2xfWrtvfokjkM6j3YKfBuNV2AeMsEWurRO8JP5roaHDHMmLVGT+/0mKgJ8GeT Rzo6OC9pHLIs7wyO+9vXJsSgR60MmkF7EongLPHeimgLfDBJnQ8bYZqku8/S64keYD RKMnARJQo/C1w== 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 431C53782079; Wed, 31 Jan 2024 14:05:19 +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 03/12] selftests/mm: map_populate: conform test to TAP format output Date: Wed, 31 Jan 2024 19:05:13 +0500 Message-ID: <20240131140528.320252-3-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: E51741A001B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: uy7w8ywr4p4wumqx65j93tux3imq8rq8 X-HE-Tag: 1706709921-989931 X-HE-Meta: U2FsdGVkX1+KwtL7/lQpvr1Up/3vcDYlv6os7wD2HJVhHkRZmpCSP8qNJHG+rFbVQ1/mD6Ru7azeJhYjrJM6EbkoK9K7ysFsKRjxafcxYk9vj6kzp/1fll+5Sud2dEONHUiEgIq2DUc8BL16IAb8UTD41pQj9z9ePrhyJq+mqDpquTPKcFk7yVSWE4YxXrJ6OE4rrxBYXlExXAjsS+Z1FrWI4Ncsf8pUxE0obn3n7OUgFwB2aEnVLuUAn38ElnNCWwLTCuBr142xPxXLY7d0iJPKyp9o8XwqvveqZ3cfH4fm/H2r+Z9BoY+pA9VuDyT1UCFybjllUaBb30holU+krykrCNubGYcBgjvEjYuNNMQNOtb08A4a1hYfuA/1JTJJH+X7IQlvQY8Dmvg+yRIpgYXyzrNeKAPi8nneHkA209Oy0DnixXjOt7DjHtU9Sb523GjbV07mG1EPuBodiW3saouYNsztKRjSHHFAKs3XfP7/8ZnbtLG0kUS4x2U4IClb7SqaJ8WACFiave2MF8U9OK+cg1hXvNBCKdjk159WySMR73pS8Qfuz6QFP8L7eJGa9fTC9NEe7kwwejU9NRDrBVL1PGctEYhat8rpgql0Cx+kDzPO/bacd4siWZBn5+ckFcjWmW7k031VOoL/wf3jwTCXEtXhQIqo2gbNUGsw0g6E66bKFTeunyu3N5l6YTqchxedI2381/KPeiO0Eh9J5607UtTWeNSHLJBcAV7Tl5KUXC+s2lvhW8nY1wwwE8yh/V1BozS9ixDtcqlIVm4Z6T23FdH5uChqodDnb58FQguMDPF/FcjajjldG114tzTzFm4T3tL5pUfxzBDSivPfe2pEStosEdcYatHF5kqB2I7wLUVnCg/390XP9mUefKago6uZNInO4FsX+2AKL9/f6yMM0E+qE+Yr3yaHWv9ZIwFO/OhNZuUcx4ZTOyf00LjCl9hyVgUTvJLjlyUpl61 tGXlrtUZ xwmGKeMvuyiqBUBK8NNRo3rALQ6GJc15lLG0u2x62MUP+9IYCVhbx4dC8u0rtZgK4ymZHjm79AevsGlbryRDXW3V/f6jScvrKUA76U6yG6+QMsIrBcwOwzRdBaJcFgyphgE2p0s7Edo6QztDHKk0iaJWjxCkD5V/Ab3LV0k3fX0zJkAYdTQ7dTVqPFh2lqUEFoQaKadKRbhtyJHP25cGDIxUMJSa9PIKCtiHv+HtAg20GKQhufgf271XeWl892etr/lxSOtNZ/mb6Of9sT3ZwLpyNqvMQpDYqZMiU1aT0fAGCbb8= 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. Minor cleanups have also been included. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/map_populate.c | 37 ++++++++++++++--------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/mm/map_populate.c b/tools/testing/selftests/mm/map_populate.c index 7945d07548751..5c8a53869b1bd 100644 --- a/tools/testing/selftests/mm/map_populate.c +++ b/tools/testing/selftests/mm/map_populate.c @@ -16,19 +16,21 @@ #include #include #include +#include "../kselftest.h" #define MMAP_SZ 4096 -#define BUG_ON(condition, description) \ - do { \ - if (condition) { \ - fprintf(stderr, "[FAIL]\t%s:%d\t%s:%s\n", __func__, \ - __LINE__, (description), strerror(errno)); \ - exit(1); \ - } \ +#define BUG_ON(condition, description) \ + do { \ + if (condition) \ + ksft_exit_fail_msg("[FAIL]\t%s:%d\t%s:%s\n", \ + __func__, __LINE__, (description), \ + strerror(errno)); \ } while (0) -static int parent_f(int sock, unsigned long *smap, int child) +#define TESTS_IN_CHILD 2 + +static void parent_f(int sock, unsigned long *smap, int child) { int status, ret; @@ -43,9 +45,10 @@ static int parent_f(int sock, unsigned long *smap, int child) BUG_ON(ret <= 0, "write(sock)"); waitpid(child, &status, 0); - BUG_ON(!WIFEXITED(status), "child in unexpected state"); - return WEXITSTATUS(status); + /* The ksft macros don't keep counters between processes */ + ksft_cnt.ksft_pass = WEXITSTATUS(status); + ksft_cnt.ksft_fail = TESTS_IN_CHILD - WEXITSTATUS(status); } static int child_f(int sock, unsigned long *smap, int fd) @@ -64,10 +67,11 @@ static int child_f(int sock, unsigned long *smap, int fd) ret = read(sock, &buf, sizeof(int)); BUG_ON(ret <= 0, "read(sock)"); - BUG_ON(*smap == 0x22222BAD, "MAP_POPULATE didn't COW private page"); - BUG_ON(*smap != 0xdeadbabe, "mapping was corrupted"); + ksft_test_result(*smap != 0x22222BAD, "MAP_POPULATE COW private page\n"); + ksft_test_result(*smap == 0xdeadbabe, "The mapping state\n"); - return 0; + /* The ksft macros don't keep counters between processes */ + return ksft_cnt.ksft_pass; } int main(int argc, char **argv) @@ -76,6 +80,9 @@ int main(int argc, char **argv) FILE *ftmp; unsigned long *smap; + ksft_print_header(); + ksft_set_plan(TESTS_IN_CHILD); + ftmp = tmpfile(); BUG_ON(!ftmp, "tmpfile()"); @@ -101,7 +108,9 @@ int main(int argc, char **argv) ret = close(sock[0]); BUG_ON(ret, "close()"); - return parent_f(sock[1], smap, child); + parent_f(sock[1], smap, child); + + ksft_finished(); } ret = close(sock[1]);