Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp766452rdb; Fri, 2 Feb 2024 03:32:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGv84Y4Zly4G/DAt6dLnCkPGWENYjlvsPoM65g0pHrsb5LQjek05MHSEqYglO1+RqASk+RR X-Received: by 2002:a17:906:a004:b0:a36:3b53:8f07 with SMTP id p4-20020a170906a00400b00a363b538f07mr1366624ejy.71.1706873549615; Fri, 02 Feb 2024 03:32:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706873549; cv=pass; d=google.com; s=arc-20160816; b=hQzgCRXRJWCBoIt9ZlhDPbrnWldG3ksJKCnjGnk+YwZfbbAV7f9slBmxsO473gzODZ mInKipRvjZc2JefnM7fElYC1oe8csvJMFaal3ZITRHAinV/OypHKMpJU+h0zPmMFBCyP vF41/cLoiHJRj/fYaCDEIILm0MtmXg/tHuEvdMLc4+UdKBhRu+OMIBCsQpfKsuHbBzys wxApTBJMhHv2sfLJdYAsUVd+0j9UG/jjk2/4sbKHoUJ5C1m5UWCf6xJJr8hbJt2QkO8s CtTgqecjqZwksD7DJRlsgBDGKT6HNytLO1k6fyP1Di2gpMlHassOOn3xZZ7v6FnNMwKu /taA== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wTJHNbNNuZU9yzkNFtgw/kC1FsKjxHF0kk1Dqavy8AM=; fh=s9Nc0DS2sqRJCMS2mWG1fxduNLHQ0F+/irklXqdSQAk=; b=rr6uaefkw8vBTUxHdxZgOXu1kqvvVOcjrPqUbwp+xpFTwh3fVRfHAfHg82etaS3q+P FbBCbohQlfBccaPYtRohm2xVY1yNJ/E+QvbzlSrpIROL5k9/JSSJutpvvCkKzt2RJQ8B nhQ+US4IuY/lncbp8KGk7KX3SF8KzF0hfCJnCAK1M8anDLouPm7j6tet1YctIlBFUKnQ UnQFTWXVzrTyHQQbdZ6c01D9DL4oz0JUmg/ifuu/Us6Hwj9RC5KKVJyifzKflnBZNrO4 3DSx2KHMOqXDavAV71BlRwN+Dj1lFoeuWcyB93J4Y909WwECRRl8oSedF3FpasbQoHF6 8ChQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=3bmcXcIj; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-49750-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49750-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=1; AJvYcCVDzntzrrSO35sstyuzhN9svZv6uPV9isSuZVUfVWSpqbqcZmAkAHhOuSoczEPDXca/RVxhgaVlYsn3ztFGZkh1wg30zoIMBnr/hNmscw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ko10-20020a170907986a00b00a35c3cd7b17si682318ejc.786.2024.02.02.03.32.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 03:32:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49750-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=3bmcXcIj; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-49750-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49750-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 27B9F1F26C05 for ; Fri, 2 Feb 2024 11:32:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55D8013E22E; Fri, 2 Feb 2024 11:31:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="3bmcXcIj" 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 EF1EE5FEF7; Fri, 2 Feb 2024 11:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706873498; cv=none; b=gpAhJW+E2at1Wx7JwC+6zVp40eVvuULYzfkB4M6cEdZH61XTt9eFLHxgrM+4sDtNeBdnkbip3ftwI8a3K8nP+XgRxvkvqmejmF1tT6gyXEKhfuN5p5xWorJhOYSCfyxcsRL1bHqmqEL5XqoyLwcXroBP3En0mnRNt3RI5TzwXKI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706873498; c=relaxed/simple; bh=y0GUUHT+6utzfuC41fyJPiGU8siNhU+amnQRcBTcLQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yqzgy6GBRaxyB4c6s+z8oPxyaO5Bu/BzZIfWtN3Z5hPWv/5JcQrPMF0SgHiOUCHgHJYY7h2mXgM9JrjHkNDBz4GMpZ4W8Du9JUMNrjdHRbJ6srCKdEXwnX8OsvwSVYURHa+OuwYVZwaSirmlktWKpftSFS5AiZq44EiKC9rRIMg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=3bmcXcIj; arc=none smtp.client-ip=46.235.227.194 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=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> 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. 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]); -- 2.42.0