From patchwork Fri Feb 2 11:31:10 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: 13542770 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 71936C47DB3 for ; Fri, 2 Feb 2024 11:31:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 832166B0085; Fri, 2 Feb 2024 06:31:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BA406B0087; Fri, 2 Feb 2024 06:31:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 599106B0088; Fri, 2 Feb 2024 06:31:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3DC2F6B0085 for ; Fri, 2 Feb 2024 06:31:38 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1D0621401C5 for ; Fri, 2 Feb 2024 11:31:38 +0000 (UTC) X-FDA: 81746648676.25.66DAD78 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf11.hostedemail.com (Postfix) with ESMTP id 5BBB44000C for ; Fri, 2 Feb 2024 11:31:36 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=3bmcXcIj; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf11.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=1706873496; 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=qLwX+Il0v+VLNzSxHvGFt0qFHVxo2RclorwPQuTZt9wmH2ddClgL7v8FH1EiF/WMEgI0wb /GPS7/WMmEi8LkJDZt2UtvnKfidU4OUrBDgN2yN0AjzzSE4urZ5uGqgVumxW0GTcBb2aJd tpYf5wUztNNWPcHcXl8Q+QQbVVjIk1M= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=3bmcXcIj; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf11.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=1706873496; a=rsa-sha256; cv=none; b=F+bfWAi2jOXd9/2sMRx2Lu+XjI/AjbaolMiWZkZr9y4i3n8bKP6hQXsRi/JAooiD0Xv2mb au59kiZlrtoO6pRv2Lthqm/3cF5cNGpM1GTiYI6Bry3QKAHRz0cVnhb1ebDGWr6Wul2APh 0lBCCdhJaOzQshkQfLj+zd0jjlGAp3A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706873495; bh=y0GUUHT+6utzfuC41fyJPiGU8siNhU+amnQRcBTcLQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=3bmcXcIj30VRmeCmmY+Ym86LbvMLxAmsZ1+9WkprrVt3iQzevJY56wjJIWdJqBXdj 20wNXjG+lGd+mG2USfLDIr1VOhLsdnxXkAJ38OVsd6KMXNK20c36Afs6+L33edOobQ nzVnXBuVi60lDHc9VM0avrt1afmEzshkvl0htyC4cTzsQEYMF2IwSQqjBAsY32EEDN mEwE+U9lR0Ndq508JuKGGS4x0FV/4nXwlPAFU5s7pYU/LOO/tSuUmI6mzcc8mulNRy FYoEjZju5Nlf45G9RTR9Fo9Ckesjkg9pchTtJi0W8TpLpDf0F1ztxnJ7lxoDU4sBH7 0w4i1eOJv+LCA== 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 C238237811CF; Fri, 2 Feb 2024 11:31:33 +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 v2 03/12] selftests/mm: map_populate: conform test to TAP format output Date: Fri, 2 Feb 2024 16:31:10 +0500 Message-ID: <20240202113119.2047740-4-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240202113119.2047740-1-usama.anjum@collabora.com> References: <20240202113119.2047740-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: ree561ot99odjy4mf8o16n7mqk1cowbk X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5BBB44000C X-HE-Tag: 1706873496-910030 X-HE-Meta: U2FsdGVkX1/n2rAUlG4s/gIXnkIhC1fnVmVSzkKEoVIc0+5ixyOMMHP9ovwn+2Z6/bJv/LV3/6Uft41nh5WMZNwBBm6Tv056bM+3QH503tevnnqui+l4Sh9R6lZm6KYYV9kOhde6Uso8Z37vWW2Z9rFRwNe6SkE7M8y+qvqHBsHO0ZEeGO1joeQPRY7HFJMzMFVlwwmE7K5cqJoEApqWGMbRwcdJ5oRwgqOL44KzFBubXPzxRRwhUllcMX4Zqi6lsYaMC3f4ImKGPvvAOxhwSFw3+sECOeZXsjdevd3umfw0hDqmi7/Xw/joaJD0gDafuxjUijWrBDvwpsxxWIba4SfgP163EcLY26s1ekeLdjaICYAbkytyo8+ykptVkno4D7U0uQtaESxiufjbVbtforL6YNM7jNKl9UtiKBeeOtRfUnftPmv5MjAt8NjjcUYLyI7d33Ei8rFH6LgDutilu6fCCAGuRknX6J0YjARHU34ygHzp5h9kbmLAJiEuClstwzhu79z+85XPl7sRKNLLkLGGFuEjGuus9JEdISekiZjSB8IWW7HneA8QRSF3dv3Y8eM9IcEQtLIY9JZjkNRRqwdAyZWzcrJME2gGkLCqdQbHZ3yX5smmDLY/VLScrAoFII1jhSqakfsZvVcdO8i6Mtr8a/h7Q3o3PVdKLaf86M7fN/5THhGzwqQtEqjsDo+rRZv3STlUuUSaOy8SF4skX/8aqPBJqra7r8lvZAOsLDRkT+eTZ1ZXp+hAq1s0hzI9/agXD4fHU2iCE6H5I4JPsnrL4bJI0v8zoQZ02w3B4cS5fB4r72UW4vaMUtoHxcHeBA5qlr4tTZYp3evQYK+J44sD861kOfu73zKBclQXzHeyZhdj10qjnBBk3yOpEmzJtB0ODbjVzzNhNHz4Kpugay/Gk3aL4aB0y2bbpgk1K8vzgGZA2rEg85AyZxzowqhEnOSZr4rHPIZXo3/F9zV lSU2MY4k JL14QLnIbTklxqExHJTFOVkFl7glHF4cMOtuylReSnZdxZZthhnCWVdUYItHBUADhRa+DcCCmAXtlNGZpFDMTGsof+eoBvccE4y5pskjkyK72g88uHtYZKf/dgDBrou/vw55jk6bxIXKcTZPvAMiwIA4/b/4c0UHWTOAzr1EXC+I+aQ79bhl7qgWy+K9y/eaZojjfJ1gOj0rLafrxdVL3Ar8f8BGOxdAW1hF3NO1oH34CsrxWr5W9Rxvz5fDixmCRZ06eDzr3JPsme2mC5WwzKZR5v+CYWCnsbaDcK/1Y2T+egVE= 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]);