Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1949827lqg; Mon, 4 Mar 2024 08:25:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXGD9TEBtctxwUumRBOwsnpoun3QuAxArq/jTM0+in1B8Z4GBCci17C7ofSKlFDAf5zQgoIC5V2YOiObXOJ1jNwntW5JA17CWEs5u8L1w== X-Google-Smtp-Source: AGHT+IF1OugSplvAOdDIhQYkmciq8i9W0zrDXyOyH758Zv6fWJ6KGChSth8RJO0b2pp9gZveR64C X-Received: by 2002:a05:6a00:1912:b0:6e6:1712:c543 with SMTP id y18-20020a056a00191200b006e61712c543mr5021062pfi.12.1709569546083; Mon, 04 Mar 2024 08:25:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709569546; cv=pass; d=google.com; s=arc-20160816; b=AUsf12qS/9jGkkq4XdmLQAgWEkGMKZUAY26cLn/KqAXnn2d0/ajyuQng09rIeOy3RH sCE9kgo0iOXXO8Mc96x/4/nqE2qMMUNvjS4JkrrM4nQ8wZTe84FDy/0c0NHxoU72z/s6 9lEw2kvto6H0mTxHUNXWbBokyfN8Lu/n3B8cVCVpeVhzZQ1mr/ibjrK8e/XGfALnQkAL 6BhmKgjiyOwb0oAe4vGwuS6WEiRVMZBpPm68fd3nmPVSiOh3b8WluYX0WC5uOcmNQUXM 76LVp55kBQxRaSrR5YvkDvr2WvfYUWmsrxjOJOOLn/NH2ynhdwgb1QNHhCwJGBDC4DuZ 4KxA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d10-20020a63990a000000b005dcbb75b1fdsi8216304pge.218.2024.03.04.08.25.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:25:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90886-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5C8EBB23A37 for ; Mon, 4 Mar 2024 15:59:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C575F487BC; Mon, 4 Mar 2024 15:59:36 +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 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. 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(); } -- 2.39.2