Received: by 2002:a05:7412:361b:b0:f9:2edb:3e4d with SMTP id ie27csp73212rdb; Sun, 17 Dec 2023 15:23:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQH7XDCQ/La+iPOu3r+N1EEg5kSEIomzPnjIjav2upjodzGTlSyE48w1annmQ8M6WCHVbd X-Received: by 2002:a17:907:1ca0:b0:a0c:fe2f:c445 with SMTP id nb32-20020a1709071ca000b00a0cfe2fc445mr7704812ejc.69.1702855400717; Sun, 17 Dec 2023 15:23:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702855400; cv=none; d=google.com; s=arc-20160816; b=Bv9AX4m0bGKWW+dYj2Y+oGw3uZ34NMEolNgeEwVKDgFBr23JhJxR6XEUT+CsEFApw+ +V04TBpRXI7QKG9LtOGgWmfvVFpugbm84gHB9pj+H/l6hPR/bg91kQlDgpjh6tPS8oS7 wFSinRUW8x1FtcUSIZAZ0IIc9wksyOj+aRaWwjYhfCNCu5A77KSfwR0xWDeuTQbcOvp+ M0K6JpMdu7FJZmA9cHMTru43RnkiBkb3w5LRwY3K9k71SVZK0fGloFTYO5cJkyYGDNkD up17dOP7bU/ASbbNpeFz0QHjFnlHiI7noXiGXoTtvgbTbp1duG09D+EX5BMEi7cJyKtq DYPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=GFKLHnzI1MkQMFN4aygtqwkY70T4csRqR2mODluuL4g=; fh=xB6ysHahC4bFZk4GUg/2MrKGfXCTibG4ZfWMb6j+tQs=; b=gHiWKPfWvW0RSIymWtbrIccoN2UNOeTLwc2fXROk8AnrEmDRuZb5Hop4z0FOZThhD0 fQ5EuTdf3xP0uTnrvSpVyjiCOZxx6tDAijZo5nL+p3pFiOP8+v7hqAn5vYBs3Yd2x7ft +CQmXxHC7ofWHQ8Sy8bMrszlCgziWo6mMaZUYgTVkrFNe/R+yP1IdaPqyztu9IWKErI6 gFIQu9AhnVKJCKkFJljSiY5nK/v2CN9XU3ZmnGxJX5ZhO53KL61oONReHpbfaAL44r61 9Kzc/Ash4eG7HVJ93SwbWvMCHZ+8hi4KfYWrLhY2Dvkm0jZ5TWg1yjaJgwfRqPXjCXwP BZIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gVE6QyMA; spf=pass (google.com: domain of linux-kernel+bounces-2862-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2862-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f13-20020a170906390d00b00a23458970e7si934188eje.576.2023.12.17.15.23.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 15:23:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2862-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gVE6QyMA; spf=pass (google.com: domain of linux-kernel+bounces-2862-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2862-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 49E221F21A3E for ; Sun, 17 Dec 2023 23:23:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D35464A9BE; Sun, 17 Dec 2023 23:23:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gVE6QyMA" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 561BD49F8D; Sun, 17 Dec 2023 23:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-553338313a0so644129a12.2; Sun, 17 Dec 2023 15:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702855386; x=1703460186; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GFKLHnzI1MkQMFN4aygtqwkY70T4csRqR2mODluuL4g=; b=gVE6QyMAhBi0KMKfBWeqoDDY3SclvTQ7IRulluPIVybfMUbjuFR1jphoG5cMzlFGaG njUG29+KEATkt9JPNIFJelw1BVtsSIRogk4LvyNm2tlLIRI0t6o1rTt4/PAM4TP1bTKC agmAMYovR/Ylkvo9sQICc7tUL3msuIQx/uYBoPDR7FHaxtXCdC7ASIaOw+hmV/2xrtF3 DHkU9+5KS6nYJBKo3+O2zblhse4uTrqKqy3AM5agPIeOsOff2bj17J1ncTuzMqRCi9p5 tTF3xvogHCc2AorvAd2EyQZ0Qns0l0l4ZdL4IR/FLNI9War1u6eRcPGQ0zahrV/v+5JG Jqbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702855386; x=1703460186; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GFKLHnzI1MkQMFN4aygtqwkY70T4csRqR2mODluuL4g=; b=rbm0JU4CLGqM2ipVB6d8PONM1mAiFw9XYjfa161WFNQjohY1xSiKdYekCDYsx+3tY7 rcnpa3efkO4vXXhOT1IL2JRY6Wes/a9MBmDEud1f7cWZMsl43rdouj1IKW+ubYHJGM6c PoJ6N3pcwj5yUDvLZwazkaJWY31OFPsMEYgW9r9VAOi93HEfZf5yPKkXnNMe0sk//Jna BO/9lwDbcYI3ze9xbntb7e5S4KLDrHL+PQsTAn3+rdmPzCqOonJvWxCpRfaftsW5ecSW xLLKg/1IeSoLxAOjNMm0UV3SQmhpK0kiq1SitbQfLUtoincLwL0o+SgyR1C38c1FIbRy ey4w== X-Gm-Message-State: AOJu0YxZE5+NjEPgBBCh24OFprSBzpvcgzQJTIaVxlJa9C2kwI2OxCYf eln1PIUQFkWFpJsRu0azHFCalk9Zg26dd2p7D5s= X-Received: by 2002:a50:d78b:0:b0:54b:687f:446c with SMTP id w11-20020a50d78b000000b0054b687f446cmr8075776edi.31.1702855386340; Sun, 17 Dec 2023 15:23:06 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231215132132.169628-1-laura.nao@collabora.com> In-Reply-To: <20231215132132.169628-1-laura.nao@collabora.com> From: =?UTF-8?Q?Sergio_Gonz=C3=A1lez_Collado?= Date: Mon, 18 Dec 2023 00:22:30 +0100 Message-ID: Subject: Re: [PATCH] kselftest: Add basic test for probing the rust sample modules To: Laura Nao Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Shuah Khan , 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 Content-Type: text/plain; charset="UTF-8" On Fri, 15 Dec 2023 at 14:25, 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 > --- > 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}" > -- > 2.30.2 > > Reviewed-by: Sergio Gonzalez Collado