From patchwork Mon Mar 4 15:59:23 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: 13580821 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 1C25CC54E4A for ; Mon, 4 Mar 2024 15:59:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48FE86B0080; Mon, 4 Mar 2024 10:59:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4400D6B0081; Mon, 4 Mar 2024 10:59:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32EC56B0082; Mon, 4 Mar 2024 10:59:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 243EB6B0080 for ; Mon, 4 Mar 2024 10:59:20 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D00ABA103B for ; Mon, 4 Mar 2024 15:59:19 +0000 (UTC) X-FDA: 81859816038.26.5B3E059 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf11.hostedemail.com (Postfix) with ESMTP id 2E0304000A for ; Mon, 4 Mar 2024 15:59:17 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=Ic2QKeqC; 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=1709567958; 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:references:dkim-signature; bh=uHeCw6yfcJYTOU9ieSZ5STUfFs4EL/lIE8x96JBswcM=; b=zdeJ+YiKPzpYlfgMn1JsGxG6g710dNfpEo3VHrwnn2tivz0ZQU4ETGm9RFuM1H414U0Rru xB26vE44x526ni1CTNEil7N04nePvGpR/GDr9eJj2xNStj0KEgvYKui31DGH+CYmc2ZJpQ xOs8795/M2Zn0447L8KwcYHUxrAbFJs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=Ic2QKeqC; 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=1709567958; a=rsa-sha256; cv=none; b=ATHhs5OvUuzS8nxTTYuc9jhMHBrUI9i7Fq/QSBjVHHKV8gK+kfYkS/KZVLqrV8lKHG5fLv jJM/gIoEWEakMn9A43ce2qDYU9v2mWWoMa4XXmYsAF5qa9OBzbmPjQbL/MK8IIR5/7Zq39 P2m7ff0NydZYds234AH1Vb9LtYdI8vQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1709567956; bh=ZjZh6MK4cK0nPO2xkcbSCU48Cy25SeM0mup4wcmCJx0=; h=From:To:Cc:Subject:Date:From; b=Ic2QKeqCWnv2YCtCbqdlmm6TQXqw+vJJ4o9Y/hkzs526iD/Xg6sjTT2v2rfRalK5r E9RIMd9iBKWZlKh4PJXTDUWMAoOt6qrAJvjk+qpQi4TE0Cc/IN3ifJvt38WogftARr cTyMSY/7nqGn60ybvTZgWfZdsjT5qBpMJk/69S9M5JUHwmvOdGH9GkTCVdBmLDfB4E cOIrZCquDjSTNw5Vm6cVjXuOVrJ+/YbfrjHo8bMEvb/itiKb6+LgALQqcypmQ7AfwF FOiYdUEOiwrnOjX9t8VcCWwgPbUcuLCw0ArSnkoj66tIqoAJ2f38jAs8jvzCgpSm7g kxkM1qltBck7g== 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 04BA037820D7; Mon, 4 Mar 2024 15:59:13 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Eric Biederman , Kees Cook , Muhammad Usama Anjum Cc: kernel@collabora.com, kernel-janitors@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] selftests/exec: Add the overall result line accourding to TAP Date: Mon, 4 Mar 2024 20:59:23 +0500 Message-Id: <20240304155928.1818928-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2E0304000A X-Stat-Signature: be8aw9nxctt8izne93cfgwadddfswaak X-HE-Tag: 1709567957-670728 X-HE-Meta: U2FsdGVkX1+hOBQTBR31ypCbyeILY1m4UAAkUS8eSDZe0kvskWKw1QqbEKt6Tisl8YSvUUuCECeLbq4rZgi7aF7YoSnjeqIWRielqT6kkZDVM/K1go8/Bfi3qaGjqwpD4Y8OH1MCVjKfXk/c0Zo5sbjkZ/9+PplLiZXYCIxwn4BZqK/DNExspzR1+z8d+vMmf8M0eC+biBCenx2EYFLsRSQq1qh5I23YpCh0J+2kq0pwfYyp9UxFwPs1/RvtB/EpN4NwwFB8Z3Qrq0sLL2FlPXBKZ0oekeMAlUt74jQf3bkRjWrtj8PfYJ0NW2Q/501D/8tWw9xejmv5kxuBS27I7icgx9bXRw6xr/1m145GJ3esFPJ/Upd6VJ3fmuzKH3PHM9Dh9B5m8sj/sALvcmt7JusL9ge6yJLnup9sGFv82/+LorWgmqlIetvaxjouwnx4lbSxBU339QyQPkaM90j7RZyAwq/WZlbkfdMYDZqrdrI2HEsVWWvq1QRB4CCCIQfAcvFCaBLgquoaze2Qo/1cz/MlitJ6LRDzg4k9l4UYlBI0wAb3QSLFwB0LGFWgHAroWyByygIkpXGHKwTi26TVN/Mhw0q7VR5Bln8z7svHCtcZuwvRlfYgXd62teeI6pbFyabl4sgEJDIvUlYDzWarxuE2bkCxIiL+f0SjMG8RBEeXHu0zsviXsDrC05GY3lM+ZqKDCaf5XD+Sxo2arAe286vb5JKgckQqpbv/RLvlnZ2JuRJc+g7ovl+O/uTwFuskKp2diR50f5An5aCuAnK5O8PWCmTrk2YDEitOpz9kpWx7Jj7Itfi9jGDOwFpUfeeUbvZPo01gvmvJaAnwJPe/OilkuAz/o8bH5ItCNpxJCHzeZ9qGmD1TqeG4SfD307JFUa/F7yL6hcMRf4uQ2hBgFlazr7SvrZrcVUVyGR7Qt/tPN0REyHGCRx491W6tWP+X X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The following line is missing from the test's execution. Add it to make it fully TAP conformant: # Totals: pass:27 fail:0 xfail:0 xpass:0 skip:0 error:0 Signed-off-by: Muhammad Usama Anjum Reviewed-by: Kees Cook --- tools/testing/selftests/exec/binfmt_script.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/exec/binfmt_script.py b/tools/testing/selftests/exec/binfmt_script.py index 05f94a741c7aa..2c575a2c0eab4 100755 --- a/tools/testing/selftests/exec/binfmt_script.py +++ b/tools/testing/selftests/exec/binfmt_script.py @@ -16,6 +16,8 @@ SIZE=256 NAME_MAX=int(subprocess.check_output(["getconf", "NAME_MAX", "."])) test_num=0 +pass_num=0 +fail_num=0 code='''#!/usr/bin/perl print "Executed interpreter! Args:\n"; @@ -42,7 +44,7 @@ foreach my $a (@ARGV) { # ... def test(name, size, good=True, leading="", root="./", target="/perl", fill="A", arg="", newline="\n", hashbang="#!"): - global test_num, tests, NAME_MAX + global test_num, pass_num, fail_num, tests, NAME_MAX test_num += 1 if test_num > tests: raise ValueError("more binfmt_script tests than expected! (want %d, expected %d)" @@ -80,16 +82,20 @@ def test(name, size, good=True, leading="", root="./", target="/perl", if good: print("ok %d - binfmt_script %s (successful good exec)" % (test_num, name)) + pass_num += 1 else: print("not ok %d - binfmt_script %s succeeded when it should have failed" % (test_num, name)) + fail_num = 1 else: if good: print("not ok %d - binfmt_script %s failed when it should have succeeded (rc:%d)" % (test_num, name, proc.returncode)) + fail_num = 1 else: print("ok %d - binfmt_script %s (correctly failed bad exec)" % (test_num, name)) + pass_num += 1 # Clean up crazy binaries os.unlink(script) @@ -166,6 +172,8 @@ test(name="two-under-trunc-arg", size=int(SIZE/2), arg=" ") test(name="two-under-leading", size=int(SIZE/2), leading=" ") test(name="two-under-lead-trunc-arg", size=int(SIZE/2), leading=" ", arg=" ") +print("# Totals: pass:%d fail:%d xfail:0 xpass:0 skip:0 error:0" % (pass_num, fail_num)) + if test_num != tests: raise ValueError("fewer binfmt_script tests than expected! (ran %d, expected %d" % (test_num, tests)) From patchwork Mon Mar 4 15:59:24 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: 13580822 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 F38ECC5478C for ; Mon, 4 Mar 2024 15:59:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52D436B0082; Mon, 4 Mar 2024 10:59:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DD816B0085; Mon, 4 Mar 2024 10:59:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B0DE6B0082; Mon, 4 Mar 2024 10:59:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2709B6B0082 for ; Mon, 4 Mar 2024 10:59:27 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EAD8B40CED for ; Mon, 4 Mar 2024 15:59:26 +0000 (UTC) X-FDA: 81859816332.26.09932A3 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf18.hostedemail.com (Postfix) with ESMTP id 5F8141C0012 for ; Mon, 4 Mar 2024 15:59:25 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b="V/ymKtbU"; spf=pass (imf18.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709567965; a=rsa-sha256; cv=none; b=GF/2dHVLEnKLCDpk7skfBBOYvNRY1PWTzzfkIJ+ivh97HFaKNWodEWiUN5JiOY7Fv9vJDV B55t+W+++/BpxHBZ4U6fv3YCY6cI87FxWiqmyPLQ6Ca4MDEP4W5NzOwExty2PrvSFef/UV cVnmZLKktUlEsk/HdXswA69usFakbFs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b="V/ymKtbU"; spf=pass (imf18.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709567965; 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=QlAYY2DWT18yifXEUSrja72p7Ld+z3uDQmu3W7C2rk8=; b=STkGlXwWG0agNZ7zqeWylO5NumDFynjUN2A5NJvHnbvIWNr38PERRl2t+fd06EzWtBKkLY 8K1Wdc0TpMgdtQliliIymMJ9Vs1J2+oU9DnKaN3yv0K5KoguY+EAp+oZYUehSOS8bqf4H0 pEME2GmegPCUsFIPBTIkWO83Ve06rmI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1709567964; bh=hDJ+1B+zZE31bqNelWnsX1xAb8MS/M4MyzfsBFhvn0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V/ymKtbUVUuWevduols2PiqD0visrQxCth/3JhrOkjWaLAuxTr5rxoPzc3FBvSxZp zZHjXYn4gPIAxXkAZ4z3X8GvHlVCUut1SeVVLiXMsxfaNyK5xD81+dcd/LYDCPkk5S soBoo+MYi2+OG5twAke5IaDJFVqvc7p02lisrN4W9HWC4IPV7iX071RMrdUWEDTYWn bwwgA3V8a4RBfVc6O7lcgJztC4PrQ1VjJqiR/Frlniw2jHhdekeGHKkZjOKwuS3aRy Z31/kE+ikR8kxkOqG0sUPQ04iIXeV+4Gml/X3rEUn2PC2avw9wsu7uqrlH5pdUjFlO nU2PAjOIIiVoA== 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 8644C37820CB; Mon, 4 Mar 2024 15:59:19 +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 2/3] selftest/exec: conform test to TAP format output Date: Mon, 4 Mar 2024 20:59:24 +0500 Message-Id: <20240304155928.1818928-2-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-Server: rspam08 X-Rspamd-Queue-Id: 5F8141C0012 X-Stat-Signature: sbaqfaycsjt6no33eggtphd5izh7snx4 X-Rspam-User: X-HE-Tag: 1709567965-401118 X-HE-Meta: U2FsdGVkX185s/MsAD1hhme58L2AgOOiDaW+VAUNjL0ZEK/LJfYno4kpAf+Uk4QT3GPmEHeIZnQlytv9twiwqQntWIm/qZSPSVfcegCBTjw/Ti+U8AZWzIBoleV25E/PKS95erqNesRf2q8+EDKdzT9jcCOZRlOq3+rwNzyt70EE8YIGzuzcHww3GxdTLbIcOJdNi+8Xzdn7Pv9bLNz+jpY3YtOp5yqDfSt3mesAubPlqqAO/Ysr7l/94IIedsF8i0xN+rbUlH48OPUXqyRgtQ+YU/pj6epz/nDL3bOMw14tExGOl7ED1ank5o8ATdPpEGWkC7l5YZh2T6ck9gX25L9UJSpBaKXr4rDyUnS/hRsdCpVwrxyFUcxonMI19ayhy6bch48FKBMp7ccCie0i1WFBxgRsQ/3WQvH5gwbBVfBtRsRK2yqP+EoJw7CMwgAWcquh11q226SQaUzvpiNJdkB5ruwSGsPbZgLHJdNXrQ4DPllYXuztfYPzqNNdx48iRKchQla6Ai51+CtNhgO4CGNs6Om/sAxq8VtU2SmFnLofEsTogwVHiDUVTU6SJ4QwuY0w5coIV/g3bzPCUUwPylLsnvlBHb4VlslsoEEuw0ewzDcd2unblx3QYBbEcngNpttze3Pvz4R/JMSwpDqZptCWl+CVLrSPvzWKkrjQrZ29reeru0dN7In0lPTYfjrLoZD8H/BPAsGXW1zrdAvAzWZHUOZlj/jY8xEejfJxCMTZEUmNdkI6SU3lywkOF0lYjSqgSDvsZcudIIiXyPo0aFUr+hvREeIOXKb1svtv42aD3Eo4feMAElRRiKIo7mnyJCjxLy2UAyP3SwmtW4/OMGfXlCkzcbQpdwcX8+cbGvrpjrQzs7Vma7KvbY6/PSA9YJinbm6fP1R1bcSqdOgZJXRynxNZeUa2TLooV1XkalQLN9HIzQThxQ== 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. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/exec/load_address.c | 34 +++++++++------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/exec/load_address.c b/tools/testing/selftests/exec/load_address.c index d487c2f6a6150..17e3207d34ae7 100644 --- a/tools/testing/selftests/exec/load_address.c +++ b/tools/testing/selftests/exec/load_address.c @@ -5,6 +5,7 @@ #include #include #include +#include "../kselftest.h" struct Statistics { unsigned long long load_address; @@ -41,28 +42,23 @@ int main(int argc, char **argv) unsigned long long misalign; int ret; + ksft_print_header(); + ksft_set_plan(1); + ret = dl_iterate_phdr(ExtractStatistics, &extracted); - if (ret != 1) { - fprintf(stderr, "FAILED\n"); - return 1; - } + if (ret != 1) + ksft_exit_fail_msg("FAILED: dl_iterate_phdr\n"); - if (extracted.alignment == 0) { - fprintf(stderr, "No alignment found\n"); - return 1; - } else if (extracted.alignment & (extracted.alignment - 1)) { - fprintf(stderr, "Alignment is not a power of 2\n"); - return 1; - } + if (extracted.alignment == 0) + ksft_exit_fail_msg("FAILED: No alignment found\n"); + else if (extracted.alignment & (extracted.alignment - 1)) + ksft_exit_fail_msg("FAILED: Alignment is not a power of 2\n"); misalign = extracted.load_address & (extracted.alignment - 1); - if (misalign) { - printf("alignment = %llu, load_address = %llu\n", - extracted.alignment, extracted.load_address); - fprintf(stderr, "FAILED\n"); - return 1; - } + if (misalign) + ksft_exit_fail_msg("FAILED: alignment = %llu, load_address = %llu\n", + extracted.alignment, extracted.load_address); - fprintf(stderr, "PASS\n"); - return 0; + ksft_test_result_pass("Completed\n"); + ksft_finished(); } 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(); }