From patchwork Thu Feb 22 15:10:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Nao X-Patchwork-Id: 204815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp6127dyb; Thu, 22 Feb 2024 07:11:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX/y/chcYycIz2ia3aukS+n9GLf3w1h+yaFlblp0G0jYZZs45/OjRKU013vw9j9xHD0LHGc0RkmBOlZ7HHZ70k2Pzi9yA== X-Google-Smtp-Source: AGHT+IGSqtwNPVGrB4FglZ8gluPDexSaDjo0pMoIYUy9Arnk8quW25F+6P1CZkCxSe4BuS8dvhbB X-Received: by 2002:a17:90a:ba0d:b0:299:bb1d:640 with SMTP id s13-20020a17090aba0d00b00299bb1d0640mr9848123pjr.5.1708614661203; Thu, 22 Feb 2024 07:11:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708614661; cv=pass; d=google.com; s=arc-20160816; b=DE8XP0Ya9bkntv+IeHR8GtNeenH2zoJd6v1vkH76rCLvjxYJy0jaFwvc0jKa8TxW9Y mKQv0y+2zTx++qxMsQgtJCDrmdA2jk7sYp8dOz6iVaCxPmyvw3K5ARldpi0AobeHXpqe d8i0ufDP7O3d/2cDAyOLiDdvdfbi/GgN2gIyKruseldLrjoK2KVKplI6nnkjKQYAXw4E CAiFoFcydck2X7GjNXmh1jrz/B7naN9YGVCYBT+DW5AvTPyiS+8pEv4Ue7fjaptDTLyS /IxIndgs/uwMVPG0KAqxAvE2RVjOSJEMgNB1VaYlexmzDv7KgX2G5rvFwvq5v2huZiZM kQrA== 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=2lxa+8WyckjHT2wpSg0UQpzqRDHGcdVFEEc3xWkD/NU=; fh=YIgADq80LQYKivST5QhkDIkhPwdUCDfa6SUP+uPebJE=; b=e8+vOxnzFEur5nivVMNpSHidpFSYP6A07bF4A6rHq+jMqQsnfqLNYLCFm3qF+H/Lgl m4BfkwaWk9TgLlctAiLldCEoJMCpzAu3XYRSzQHdovibJAVVcZ72r9zRKMNQR6j3P38V TF0nFYZtdyFAuQnrik3a6iwUN4wmoynSKNBS/bzOr18elLM0qaEUK0ZNJfp5OlqoE/pQ VG/vlalx/DqigDviTGRrNMA5oezH0YHUPg4cSiTUJfayUUiRV7hjmnJsXZQRnVx7YTuQ fNtsEPZnNlJacHgeCBEegOJsH0EZiH6JVAGvoXRcDN6bORSdznkkZTnnv6DZTkeV7ByR fnMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iwxjdq+w; 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-76749-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76749-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id nl13-20020a17090b384d00b0029927c58570si10811602pjb.12.2024.02.22.07.11.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:11:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76749-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iwxjdq+w; 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-76749-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76749-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0C9B02837D9 for ; Thu, 22 Feb 2024 15:11:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 425ED14A0A6; Thu, 22 Feb 2024 15:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="iwxjdq+w" 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 DEC991474C2; Thu, 22 Feb 2024 15:10:43 +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=1708614645; cv=none; b=S9lyq2AsUCx3a5ri+CJ2zmTJ7oLH0VSHTMvPdQoYb18HQHOtApfXNDpcIL0aUCTFQqtO1i2aURNopt39mrQZxxuJIJRBoLsLjiSAp10mzyBjdErQxM9nSAl0yrHewHOR/N8M//TbL6PU14yd8gtTWidz3tmD6/PRLxSdsY/gWrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708614645; c=relaxed/simple; bh=7Wt2UToczihewYYVHGzb+LT1rEJylSZasxhmqlYMo1I=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=aOh6awgEUoYbK1NFLerBRgKHheLiV6tmZXjjWj7s902MP16up6lplhlFzteENJDtOpS+UAjnhSPSAuguUt+KPJGmx7zWDe502lgXvZTq8nl/A88u5Uq/SoGIzyul9opIr5VqQliijwyUC3G+POhxONiltYxq4vKlSHDs7v0CN7o= 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=iwxjdq+w; 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=1708614641; bh=7Wt2UToczihewYYVHGzb+LT1rEJylSZasxhmqlYMo1I=; h=From:To:Cc:Subject:Date:From; b=iwxjdq+wHLTj6JK+b7v8AhdO4O5LyEMvW0za0cYyocNPBC5fRic+lY0wYF4z4DS2o 2PJoXhVMb4E0PQv7278fFRoZTT/c7328+mibPhzuD8lNyWtn8LoBOHbPPtCHcIqzJ5 rvpmq9ik7KqasSlvVgt9pkvvk+YNBF4T/d4D9YHdEKNTxGnzG1jCdbEGlJQe01mxdx gGtil0Pnyeq1ZoxFHZOgOcJF7rx0i+34320X4AWKpNic2WC+os9FYsFPOuYY5m1zYI va5t9ygDE+wU/oQ14wiXohGVxDc54jmTgAeyzD+xmKuroaviNl8QTK4p1AzSwlb+zg vKsVqS1hB/OCw== 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 C5CF637820D4; Thu, 22 Feb 2024 15:10:40 +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, Sergio Gonzalez Collado Subject: [PATCH v2] kselftest: Add basic test for probing the rust sample modules Date: Thu, 22 Feb 2024 16:10:09 +0100 Message-Id: <20240222151009.461264-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: 1791612327044403137 X-GMAIL-MSGID: 1791612327044403137 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 --- 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 ++ .../selftests/rust/test_probe_samples.sh | 42 +++++++++++++++++++ 4 files changed, 48 insertions(+) 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 c1a18af3593a..5f62904c80bd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19207,6 +19207,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/test_probe_samples.sh b/tools/testing/selftests/rust/test_probe_samples.sh new file mode 100755 index 000000000000..6fcc2cd83d89 --- /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}"/../kselftest/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}"