From patchwork Mon Feb 26 10:16:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Nao X-Patchwork-Id: 206552 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1987615dyb; Mon, 26 Feb 2024 02:43:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWmPbpAyEqZFnQO9POyaechc3oXZuWnhPIunus916ljx+AnK88MO62+TVpmkKtIS5uYPQMPx5VcIoi+dfORf7XzpmZHpQ== X-Google-Smtp-Source: AGHT+IGJeGGc73u26UJvTJmZ727AdiCeK0A/GxVnBLJ7wKulbJqDRWbuCqt8PA1MiBk/o5e/Qn20 X-Received: by 2002:a17:906:3ac2:b0:a3f:5fa9:d772 with SMTP id z2-20020a1709063ac200b00a3f5fa9d772mr4274768ejd.37.1708944230605; Mon, 26 Feb 2024 02:43:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708944230; cv=pass; d=google.com; s=arc-20160816; b=CK0wK9w1s4g3NQ/mIQqVKnM5trsAwcGroUEL6q/oVgKKZx9hQnH9HJEwyK7m6eARjG Mae4SH8bSIbyfExsJDJYZsmYF2zK68h42883dmG8SCrXbXcK0KxZugj5Uq3kFFphlNYe f48afjsecSSGvO2DLOlWJUFDtZRy2aidfIdd9/r8q4TJPlLURCUVNLD1tism9HpyxRHN dWn9qDFHPZhwD8FY4mXcjurOb0WzRjhqbB24ut/RHZXsqIgoPRdViU2XDE/0UJgzGIFL 1zrv1TjlmsCr4WGtmrIcYeR9es9Ye3NWSvGO8FUyVVr5sBkKuLXqbuu5nR0/En40J0x+ ikQg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=kTRVWi26SVGs0Kn9ERHS3ojK/pXr5kBf2L+IDkwc3EQ=; fh=NvwgIaFsongcTAfieThK+P9sInrVMMrfkXpkpNUT5Uk=; b=dO2Xoo5ITxwiKGT/SueZv76AEzKbO4QCQWdk1ejKWD0wnpfgnVutJNjvLq8Dr7UDIa saVKIYsLPLJSFlNGs9o5sDJI80/43FcBiFEzZOvMY3ody5OJTN5bCzjA1qcdC0W4hI1E yOWTcP6DXD3ST6dw79YWMYSHZO+orYUo9wiXi6aD5L1Eg5EcYIasQFtKp1R1xJ2dVHST 47PC+b97XbOpPR7RmP5OTFnXdElERACpHyGboU9czCUqaDpY/6v24e1Snow7K0iT/0jl jfaDJfdB/+nk1rXXS97IQkZFr5Yt8RbFd9MXLj4mY7f9B8Qb0wHaWfTY+j1J8ADz52mF wLHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=web1J7L6; 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-81147-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81147-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z13-20020a1709063acd00b00a3e5053186dsi1963432ejd.206.2024.02.26.02.43.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 02:43:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81147-ouuuleilei=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=@collabora.com header.s=mail header.b=web1J7L6; 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-81147-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81147-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id C5B731F2D2CA for ; Mon, 26 Feb 2024 10:32:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A7CA605AC; Mon, 26 Feb 2024 10:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="web1J7L6" 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 BAE1A604D1; Mon, 26 Feb 2024 10:16:35 +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=1708942597; cv=none; b=NLxJWeewUrt3LxUdzyzFAcAAU660FxVGYyppJM0XYbF0Ly8EVWUySWISa5vdmKw7yRDTYtvuHjvra95pqzTwlgRUGO6xVWIRYUzEa1VuiZDGNE1q1WEfvLVt4rXVzw9OFMky9/XJFJs5SeAUlxHRkrfyeXz0dXLReM29y4U2WOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708942597; c=relaxed/simple; bh=emFrdpvcCAoS+2q1ynAU1dbW3BiKoMtZlIG/7BBKPts=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=lBvFHSQmmMMEKIENuWdMPGP5vfA4NoH36Y5vs8poAuOhCStTa1AuCUr8YT2Of2TYiPqm2sFjGMxWuePhxytBsQN6bfz3kozsMp8B3b7aLOifgywnEQrP7BTkW5YFAO5gNDnNKU4XxSKQIuGMcG/qbKa7P0z8i7Cty2yRF+C9uZs= 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=web1J7L6; 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=1708942592; bh=emFrdpvcCAoS+2q1ynAU1dbW3BiKoMtZlIG/7BBKPts=; h=From:To:Cc:Subject:Date:From; b=web1J7L66K1/9j61ZUQGQyHdAO/3m4PnihxmvEjPSo6xbb5xRnzmGiSDWuH36XnnW sQIHKHEMLpkvxyyHbGjhCMo5049eqTLXCYpVEZ7XZQgrssNT8JbDteqGHdLkXJGSKb HdSdlDxfVoV5a2IoW8Ti4y6dfls/Iz1og5pBcSR4Eq5cvcqKEZpk7X7IiDMF6gjxdW Nr2pa04cBYPyTqaDyeZirYVAK3zvlVn9abYxofj8E4rlLQPGJN37JRORU5BbKwqAhv HEV+wHsKbJ795zUJbdGaST+ioAQIuIdUcCFHIHuDktNEcY5LDw18+63nqf1Jiprh5O mkcWvIwJBpvnQ== Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (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: laura.nao) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 8AD6137820B9; Mon, 26 Feb 2024 10:16:31 +0000 (UTC) From: Laura Nao To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, shuah@kernel.org Cc: usama.anjum@collabora.com, a.hindborg@samsung.com, aliceryhl@google.com, benno.lossin@proton.me, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, gary@garyguo.net, kernel@collabora.com, laura.nao@collabora.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, rust-for-linux@vger.kernel.org, kernel@valentinobst.de, Sergio Gonzalez Collado Subject: [PATCH v4] kselftest: Add basic test for probing the rust sample modules Date: Mon, 26 Feb 2024 11:16:46 +0100 Message-Id: <20240226101646.291337-1-laura.nao@collabora.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791617300559484163 X-GMAIL-MSGID: 1791957905475738286 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: Sergio Gonzalez Collado Reviewed-by: Muhammad Usama Anjum --- Depends on: - https://lore.kernel.org/all/20240102141528.169947-1-laura.nao@collabora.com/T/#u - https://lore.kernel.org/all/20240131-ktap-sh-helpers-extend-v1-0-98ffb468712c@collabora.com/ Changes in v4: - Added config file Changes in v3: - Removed useless KSFT_PASS, KSFT_FAIL, KSFT_SKIP constants - Used ktap_finished to print the results summary and handle the return code Changes in v2: - Added missing SPDX line - Edited test_probe_samples.sh script to use the common KTAP helpers file --- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rust/Makefile | 4 +++ tools/testing/selftests/rust/config | 5 +++ .../selftests/rust/test_probe_samples.sh | 34 +++++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 tools/testing/selftests/rust/Makefile create mode 100644 tools/testing/selftests/rust/config create mode 100755 tools/testing/selftests/rust/test_probe_samples.sh diff --git a/MAINTAINERS b/MAINTAINERS index e1475ca38ff2..94e31dac6d2c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19231,6 +19231,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 f7255969b695..e1504833654d 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -80,6 +80,7 @@ TARGETS += riscv TARGETS += rlimits TARGETS += rseq TARGETS += rtc +TARGETS += rust TARGETS += seccomp TARGETS += sgx TARGETS += sigaltstack diff --git a/tools/testing/selftests/rust/Makefile b/tools/testing/selftests/rust/Makefile new file mode 100644 index 000000000000..fce1584d3bc0 --- /dev/null +++ b/tools/testing/selftests/rust/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 +TEST_PROGS += test_probe_samples.sh + +include ../lib.mk diff --git a/tools/testing/selftests/rust/config b/tools/testing/selftests/rust/config new file mode 100644 index 000000000000..b4002acd40bc --- /dev/null +++ b/tools/testing/selftests/rust/config @@ -0,0 +1,5 @@ +CONFIG_RUST=y +CONFIG_SAMPLES=y +CONFIG_SAMPLES_RUST=y +CONFIG_SAMPLE_RUST_MINIMAL=m +CONFIG_SAMPLE_RUST_PRINT=m \ No newline at end of file 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..389d180f14a5 --- /dev/null +++ b/tools/testing/selftests/rust/test_probe_samples.sh @@ -0,0 +1,34 @@ +#!/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}"/../kselftest/ktap_helpers.sh + +rust_sample_modules=("rust_minimal" "rust_print") + +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 + ktap_test_fail "$sample" + fi +done + +ktap_finished