Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4981455rdb; Sat, 30 Dec 2023 00:20:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQa1cB6WBljOdpOSHoXlegdv9r9ejAIKXQ3BK4xi5VTucp8TBI534ut7khIS3J4PTL1hAQ X-Received: by 2002:ac8:5986:0:b0:418:2268:992b with SMTP id e6-20020ac85986000000b004182268992bmr17807185qte.14.1703924406314; Sat, 30 Dec 2023 00:20:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703924406; cv=none; d=google.com; s=arc-20160816; b=kYSn4GbPrEFC6rqpTwMM7BbxDqy7Zf7NnLCI0Qkx8weAopWFrVXaQFpmK4PlXZepTh kmuiFUuzG8s56xWE1aMMIntb4nv8tT8gysQTQDkOY9U1zBBaPO32prDWQ0O6iZbdp2cu LAIzzMwWXjgd1hBSztMWJudv77d5luo2K84+N+K9GerPP5Mg4d3ps7Hd1KWEeTc6y0iK B5LPjX5QGg+Gjq1jKsD97fHroYma9e0ztua9AqZoZf0kRBqRGzqKThOZvxQqcssmc2yH fky8i6Qfdm46rInbkcNHiHk4hSr86TY9XCYTq09vk9TKuIsXfS3pb5Tb/tIhBTWQtwk1 gExg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:cc:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=55xgmXNEk8QwZqFQ2OPKuGuqbM8ZPKgdic0MwN9nvyc=; fh=GN3YaH17eXFM4kAaRXgmO550NhJMqebb0wO8oo2Kgmg=; b=WlwLDu0/AZ6lYrXPLfqIsKLtUOX0+gPghYLpeUOqKHu8djVZAjsoT2EZqVvkMqZ6/u iYCLL+Jpi2d+sXixWvknEt3jysenjqjWuFKzuJwsaZJo231l1XNkM8HFOVNhkpApQQEh Jn54XgvoebBdSKAnxz/HfAPF7tqU7fNhP/nACJRob4xnQx5M3owfhxFEymOgvNp0DsFF a0BEZjnq5XkX8+brwuyLA9NL7C+s6vMG8WjW5vGWRFeeN0E9semFWGZEyhD4xOZd0F9Y KKlLqrCz45NvC6YfxX/hLEKWFJqs75OXx4vbclXlOHvAbgTNDOt9UJmALhhyY6BjhACV JkrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eTwsyt0A; spf=pass (google.com: domain of linux-kernel+bounces-13363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i14-20020ac85c0e000000b0042800c9f9b4si3912778qti.236.2023.12.30.00.20.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Dec 2023 00:20:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eTwsyt0A; spf=pass (google.com: domain of linux-kernel+bounces-13363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13363-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 12D4A1C20B89 for ; Sat, 30 Dec 2023 08:20:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61C5D23AF; Sat, 30 Dec 2023 08:19:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="eTwsyt0A" X-Original-To: linux-kernel@vger.kernel.org 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 0125C23A0; Sat, 30 Dec 2023 08:19:55 +0000 (UTC) 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=1703924394; bh=D/rmWS9VU4cYt40QweSANvOejlIuAoUvy2Du5sUf6eg=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=eTwsyt0AV6pv+3zawmmedJxOW/I2uboiAgqm2UDj8H6xlD+ysBWsNNsnonqO0I8LT XL7T3N7bJif7bd1qezdZmz68CBcTyNnantyuyujzRYgKqhguagfdarlncg0uGcu+qu QMPz8ThVtDDC1CK1inh6AP10G/EpC8kpCGRvm+0puapKf8vLpuLSNaHvaLZR/HpEFU wdOe6FBzo3O400HFWHJI8O/ATTW/q/rX18HwwDNVdFpAejP6UusElTdd6RxPhnh5Rs hywXpQYJ09RRDoEE61eSKr10ZzqW8ChtfhAJMkI7pOUufaSqp6nasoq3iuL9Tc0YvE qGFJpLdF6sFbA== Received: from [100.96.234.34] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 243F837813CF; Sat, 30 Dec 2023 08:19:48 +0000 (UTC) Message-ID: Date: Sat, 30 Dec 2023 13:19:47 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH] kselftest: Add basic test for probing the rust sample modules Content-Language: en-US To: Laura Nao , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Shuah Khan References: <20231215132132.169628-1-laura.nao@collabora.com> From: Muhammad Usama Anjum In-Reply-To: <20231215132132.169628-1-laura.nao@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/15/23 6:21 PM, Laura Nao wrote: > Add new basic kselftest that checks if the available rust sample modules > can be added and removed correctly. > > Signed-off-by: Laura Nao Reviewed-by: Muhammad Usama Anjum Tested-by: Muhammad Usama Anjum > --- > MAINTAINERS | 1 + > tools/testing/selftests/Makefile | 1 + > tools/testing/selftests/rust/.gitignore | 1 + > tools/testing/selftests/rust/Makefile | 8 ++++ > .../selftests/rust/test_probe_samples.sh | 42 +++++++++++++++++++ > 5 files changed, 53 insertions(+) > create mode 100644 tools/testing/selftests/rust/.gitignore > create mode 100644 tools/testing/selftests/rust/Makefile > create mode 100755 tools/testing/selftests/rust/test_probe_samples.sh > > diff --git a/MAINTAINERS b/MAINTAINERS > index e2c6187a3ac8..acf283a5d2c0 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -18847,6 +18847,7 @@ F: Documentation/rust/ > F: rust/ > F: samples/rust/ > F: scripts/*rust* > +F: tools/testing/selftests/rust/ > K: \b(?i:rust)\b > > RXRPC SOCKETS (AF_RXRPC) > diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile > index 3b2061d1c1a5..26140426c849 100644 > --- a/tools/testing/selftests/Makefile > +++ b/tools/testing/selftests/Makefile > @@ -74,6 +74,7 @@ TARGETS += riscv > TARGETS += rlimits > TARGETS += rseq > TARGETS += rtc > +TARGETS += rust > TARGETS += seccomp > TARGETS += sgx > TARGETS += sigaltstack > diff --git a/tools/testing/selftests/rust/.gitignore b/tools/testing/selftests/rust/.gitignore > new file mode 100644 > index 000000000000..e3c5c04d1b19 > --- /dev/null > +++ b/tools/testing/selftests/rust/.gitignore > @@ -0,0 +1 @@ > +ktap_helpers.sh > diff --git a/tools/testing/selftests/rust/Makefile b/tools/testing/selftests/rust/Makefile > new file mode 100644 > index 000000000000..ccaa50f35b5b > --- /dev/null > +++ b/tools/testing/selftests/rust/Makefile > @@ -0,0 +1,8 @@ > + > +TEST_PROGS += test_probe_samples.sh > +TEST_GEN_FILES := ktap_helpers.sh > + > +include ../lib.mk > + > +$(OUTPUT)/ktap_helpers.sh: > + cp $(top_srcdir)/tools/testing/selftests/dt/ktap_helpers.sh $@ > diff --git a/tools/testing/selftests/rust/test_probe_samples.sh b/tools/testing/selftests/rust/test_probe_samples.sh > new file mode 100755 > index 000000000000..a46550543f73 > --- /dev/null > +++ b/tools/testing/selftests/rust/test_probe_samples.sh > @@ -0,0 +1,42 @@ > +#!/bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Copyright (c) 2023 Collabora Ltd > +# > +# This script tests whether the rust sample modules can > +# be added and removed correctly. > +# > + > +DIR="$(dirname "$(readlink -f "$0")")" > + > +source "${DIR}"/ktap_helpers.sh > + > +rust_sample_modules=("rust_minimal" "rust_print") > + > +KSFT_PASS=0 > +KSFT_FAIL=1 > +KSFT_SKIP=4 > + > +ret="${KSFT_PASS}" > + > +ktap_print_header > + > +ktap_set_plan "${#rust_sample_modules[@]}" > + > +for sample in "${rust_sample_modules[@]}"; do > + if ! /sbin/modprobe -n -q "$sample"; then > + ktap_test_skip "module $sample is not found in /lib/modules/$(uname -r)" > + continue > + fi > + > + if /sbin/modprobe -q "$sample"; then > + /sbin/modprobe -q -r "$sample" > + ktap_test_pass "$sample" > + else > + ret="${KSFT_FAIL}" > + ktap_test_fail "$sample" > + fi > +done > + > +ktap_print_totals > +exit "${ret}" -- BR, Muhammad Usama Anjum