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: 13580823 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 4039CC5478C for ; Mon, 4 Mar 2024 15:59:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA97D6B0085; Mon, 4 Mar 2024 10:59:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C61126B0088; Mon, 4 Mar 2024 10:59:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2CC06B0089; Mon, 4 Mar 2024 10:59:35 -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 9DAC66B0085 for ; Mon, 4 Mar 2024 10:59:35 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 74FBF1C0C9F for ; Mon, 4 Mar 2024 15:59:35 +0000 (UTC) X-FDA: 81859816710.03.C2456BB Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf28.hostedemail.com (Postfix) with ESMTP id E120BC0015 for ; Mon, 4 Mar 2024 15:59:33 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b="rIV/+q9Q"; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf28.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=1709567974; 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=7c7o/Wu06wTnWl7K+nmSgnzNtSgOafrm4EubGl9SSrg=; b=3N1F1iM/dXExj6ntupBCxzeHe1mUhnpQMw+UYqDeyDDYFDXx2gkkGFLI3b5wYZIQV3AICC a0xk85EdFb9SSdbtfUN9LpRmEHg4RedzxD7WYWEm91XeT6I6d3boLy7ZiTU2HlaMnzQnmk qQgFpk6kHPLNKMmPQ6GP7BEsJAnFR3E= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b="rIV/+q9Q"; dmarc=pass (policy=quarantine) header.from=collabora.com; spf=pass (imf28.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=1709567974; a=rsa-sha256; cv=none; b=7gNPUShxU+3smCxlksftPue9vy941y3khgg8sBb6akaksYC3CWRhXTEo7U7VyfjGOXaVVj zTEioBqQn4IBOsoZ0ag+C09f57DQCISTO8+Pm69OMUuDYWjMVtWFzp/+bBzAeOXsbbN5Fv SKgjVzwc5kg1Ouq+NDpz0pPgo4FNbLk= 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: E120BC0015 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 36i5frw8xoa7q9oxzk69ecb9n59md3nu X-HE-Tag: 1709567973-836037 X-HE-Meta: U2FsdGVkX19hzysVceSuDORQC/NVQD5gNbFG+4DoZZ1G5LvWhQSZCLQaXcQJDukLyP6sr2r/pFZDWVvpqMgEV0UlN4z32E9Mf5psyFeFtQHbj5pSmifgqe5iwFwVEohFAFBgziXUEXaERviFoF9UsKe6o1MOkshObVsDb/VQv9pwiKYH9Nh6SXXS/Vd1x/e4doUfcoFReCEzuvHEeoK/kzqlk5WfOLdDhFXF7VZXeOG2CC7e+Mx74A7t0G7O5CABBHwKM8bXo200tsdvT/Py4DNaMYhSlfUMf9nforPwyGruONTvgqrRNlTJsk6C08Xci+YBQ5VGb3QkYLS4REPppueAqomH+LMQajRuNVyYb+YJlC4SiodxvxWsQmfkJtLPNFMZEh2IXXAcCw7hiiFRTB+dLbJ4AcJ0FOBh5+9zeAyKQhQaMi1oIuk3XXagy3+9Hh8WSi2rEGpCIyu+WgfE7nWdSsLBZX/HPiyryOac1B+hrSW/vjgYMkdJstRYKOGALsoi+ZzWWbtZh4nJQm9X+H+jRw3SEJ2smiYHK9R6HEWrgx5jZsWA77CAz6xTJUnQ39Gq3+lrE4CxQiUAOMH86lwcdzBB9/7Z55Efj2unKPniyX7Mk0sw37eFmLdgKUReaKIkda+B2Pq+XD4QNGxEDjWa1AojJXhI/EWQlzolpvKzfaN/1kXORKOYOMzkptoN4vQRiliNvbcuMpamrP4dNoQ3rYzzi1/TCGf+AKKr4W46SzRHrMpH0OrGawfT19bn6SbG5oeVsWXBkgYU1Z3CzQpsN5WZ/+ZkeB+vMyasgHMruA4JzUVSeSqePzmauQuEKV1rbRes6LhKAfxZ0j51iTw560dwt7J5m+MfHfJQJmUig63H+mxZ8OZqiAdQHTtCLhzZBQol3G2g0dbP28IHCDqV4Iy4hCeYX0HffArZhL5pbIxfyAUwLy1ik+RCjrWs 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. 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(); }