From patchwork Mon Mar 4 15:59:25 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: 209625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp289204rwb; Mon, 4 Mar 2024 08:09:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQF/tBGp+7UHTY0kkAwqrYxlGcuDoueGQdEbJJV9d128+NnHcnoYNyyaEH6IVUUu/6ckd3awAVMp+p3YPWUnxBdWJKbQ== X-Google-Smtp-Source: AGHT+IHkKmHZ63MmeGUjYr1cDuc6kW6cSnqF6epH/on56a4Xj3XseccwXb41aC2V9oDb7TgfrRGQ X-Received: by 2002:a17:906:2c0a:b0:a45:4d62:7805 with SMTP id e10-20020a1709062c0a00b00a454d627805mr2002361ejh.50.1709568466814; Mon, 04 Mar 2024 08:07:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709568466; cv=pass; d=google.com; s=arc-20160816; b=EvjMIURFbaCHuwmFhAALx5ejTAeAEuF+4rz85fXHam48mBDjlRdJKhCJo4j1HuSCSD x1WBVXjAboSETHrGs/mf0r/HQ0ZIzu1qD2eBh5ia6vqYpzy9/osB+T7P0vsjwTO2xv43 tydCBFf9DTvEPnSbXTis0BmgDV0GiwmrJe4ku7phXSWwdXfN4vj164ufskNYR4aFGOnb pGy6KG7TVp9vHtt3oyoO9TW2ihP5cik/uA8mxHmzwxu7WEXuqTwLTaZ6Xp9+AlQMGz4B BaF/wx+e4ineo2mqTCf0rz3ZqilrQJCHvH5+iO48djfhilo/kZrHqxTSFgdQJ4WLk+Om ZAeg== 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=7c7o/Wu06wTnWl7K+nmSgnzNtSgOafrm4EubGl9SSrg=; fh=1Jfmq3vZr7PtBvoeUFB4e3RsVLj7M6kTr4UK8fn0TwA=; b=LISZIwHJsMv3WwEnbQnl2br9c1r8RnvoOMf026dl95MjrP6ZwGwXj/t0fMtQm1EScM EcgyexJSHiva7Lcv6BWr78hRUBWUkUYvb3p1FvwpWsxpf/z5ePpXgBZWhkNr03e5IQvI 1jqeRe6iFNLP7Ebqf2D+jZPD55nKtcs1F0AXrA/dzAKSRwwNwUiXTllUibhrzgbHuhmL TcEC5HQygnVBIuU6ETD2OGMbEGE43mRypOTZYYbNN9rjmJhvsSCcdjsx2nIuRQ5WTC3w wyIlVVrVhqF9ypD8BmSnnFntqRPpaMhseBO8R1G2ODgVCdI1aDmixDi/NZ+8RfWB6ZPH gtoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="rIV/+q9Q"; 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-90886-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90886-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ec14-20020a170906b6ce00b00a455711ad06si798132ejb.170.2024.03.04.08.07.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:07:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90886-ouuuleilei=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="rIV/+q9Q"; 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-90886-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90886-ouuuleilei=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 CB5ED1F269B9 for ; Mon, 4 Mar 2024 16:00:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77CDF4CB36; Mon, 4 Mar 2024 15:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="rIV/+q9Q" 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 65AA44C630; Mon, 4 Mar 2024 15:59:34 +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=1709567976; cv=none; b=KDIMecZKBdOFCoH1tB1LoI9vrkgbYMZ8laR/8ZWSY7o4vgULV6C+XcQMANP4t41Kat3nFCXlnINO/VkAn0A+9A3CvsuAgORAezDIdMwOhLywRy0m5W0roFixdvU3+QnmS1QGGw9SXnP01Yc+1L5X6tk8mpKLzWuEGL34p/7uuec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709567976; c=relaxed/simple; bh=kWwhagXSgzGBOzzHe1+SkKphXDZuQxr2VZJ2zSGNr7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N+Zdr5zBUr09DO/N7jyS/HWKl7MIsp8EXMgDjN0htqlsC5Wq4dcdiW/tQT7eLE5OM6G4an9mq2tx0P2Y7Eix5LALjv/zh3HJ7YTRtB0GeEB4V9qfXtlFvq7O7Kwnme17t3LFnDrJGrJZ6ev6V8MRTX+JaV5dS3lZdA9IiLhd1HM= 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=rIV/+q9Q; 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=1709567972; bh=kWwhagXSgzGBOzzHe1+SkKphXDZuQxr2VZJ2zSGNr7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIV/+q9QuURjC8AzXzjygtQmgYWce2d1gTJp7ei1RAGregxwsWFdzbRILE0UdcLKd 88Fqq5uusnT7lSkf6ryw8INw7HHA1mwyhgUapWWjRdrAdQYvXUtjERJlv0G/xJ6JvB 2cUcXz36Xy9fhPAQohalbcgem08UdrxH1P1J952O4sDtQUeE+6ieiSTOi52sgsFFoQ 7dWTaFlRKTdqgv3EztYRiQvkQvBaADzN/5zYlOCkto0W3cBw7LCA1XfE2HSASXsFyL d6E4HHMjmVh/00QERi/PY4PfMBcHzNe+joUirI1yK8TnHMkufKlNi8GnEzqrtXlzh1 yaYxLDe6g+asA== Received: from localhost.localdomain (broslavsky.collaboradmins.com [68.183.210.73]) (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 3D72237820CC; Mon, 4 Mar 2024 15:59:26 +0000 (UTC) From: Muhammad Usama Anjum To: Eric Biederman , Kees Cook , Shuah Khan , Muhammad Usama Anjum Cc: kernel@collabora.com, kernel-janitors@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] selftests/exec: conform test to TAP format output Date: Mon, 4 Mar 2024 20:59:25 +0500 Message-Id: <20240304155928.1818928-3-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240304155928.1818928-1-usama.anjum@collabora.com> References: <20240304155928.1818928-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792612464382777726 X-GMAIL-MSGID: 1792612464382777726 Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. While at it, do minor cleanups like move the declarations of the variables on top of the function. Signed-off-by: Muhammad Usama Anjum --- .../testing/selftests/exec/recursion-depth.c | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/tools/testing/selftests/exec/recursion-depth.c b/tools/testing/selftests/exec/recursion-depth.c index 2dbd5bc45b3ed..b2f37d86a5f62 100644 --- a/tools/testing/selftests/exec/recursion-depth.c +++ b/tools/testing/selftests/exec/recursion-depth.c @@ -23,45 +23,44 @@ #include #include #include +#include "../kselftest.h" int main(void) { + int fd, rv; + + ksft_print_header(); + ksft_set_plan(1); + if (unshare(CLONE_NEWNS) == -1) { if (errno == ENOSYS || errno == EPERM) { - fprintf(stderr, "error: unshare, errno %d\n", errno); - return 4; + ksft_test_result_skip("error: unshare, errno %d\n", errno); + ksft_finished(); } - fprintf(stderr, "error: unshare, errno %d\n", errno); - return 1; - } - if (mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL) == -1) { - fprintf(stderr, "error: mount '/', errno %d\n", errno); - return 1; + ksft_exit_fail_msg("error: unshare, errno %d\n", errno); } + + if (mount(NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL) == -1) + ksft_exit_fail_msg("error: mount '/', errno %d\n", errno); + /* Require "exec" filesystem. */ - if (mount(NULL, "/tmp", "ramfs", 0, NULL) == -1) { - fprintf(stderr, "error: mount ramfs, errno %d\n", errno); - return 1; - } + if (mount(NULL, "/tmp", "ramfs", 0, NULL) == -1) + ksft_exit_fail_msg("error: mount ramfs, errno %d\n", errno); #define FILENAME "/tmp/1" - int fd = creat(FILENAME, 0700); - if (fd == -1) { - fprintf(stderr, "error: creat, errno %d\n", errno); - return 1; - } + fd = creat(FILENAME, 0700); + if (fd == -1) + ksft_exit_fail_msg("error: creat, errno %d\n", errno); + #define S "#!" FILENAME "\n" - if (write(fd, S, strlen(S)) != strlen(S)) { - fprintf(stderr, "error: write, errno %d\n", errno); - return 1; - } + if (write(fd, S, strlen(S)) != strlen(S)) + ksft_exit_fail_msg("error: write, errno %d\n", errno); + close(fd); - int rv = execve(FILENAME, NULL, NULL); - if (rv == -1 && errno == ELOOP) { - return 0; - } - fprintf(stderr, "error: execve, rv %d, errno %d\n", rv, errno); - return 1; + rv = execve(FILENAME, NULL, NULL); + ksft_test_result(rv == -1 && errno == ELOOP, + "execve failed as expected (ret %d, errno %d)\n", rv, errno); + ksft_finished(); }