From patchwork Fri Dec 15 13:21:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Nao X-Patchwork-Id: 179287 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9270669dys; Fri, 15 Dec 2023 05:25:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5H+KZ096Mjxi2WPtvXFZdGo5phGrZsd8eRQxQ8S9FJnt1jrWWUOkEPGTcLoP2zT1sBWxm X-Received: by 2002:a05:6102:512c:b0:464:77f2:556 with SMTP id bm44-20020a056102512c00b0046477f20556mr10363093vsb.40.1702646706728; Fri, 15 Dec 2023 05:25:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702646706; cv=none; d=google.com; s=arc-20160816; b=cBp1012ucW6Nq96UxFLt8A2lvuibBXGAM2u9na1h8QsBTlLE8omaO5fMz3d5umlowd U0EMKjB9gHJ0i18tHg46pEBLzAolMYwcrcx7bRlF49AexHvLwPFhLdDUl3Y6I6IQmttz N0wa3MXX/GruHxUmOFmmUZETp/NCNq8+WNLnLxjydR5L4WqWsr1HnLZfZsyioU+bauZ9 yDmgIEHUrF0HY52tPMpZTZa8zxQW8azzzgJEo3Ug1rcqtkPkYs+dBuZ/15PxkKGkcNTZ bmewA4VpXJOptSOd8Spg2NPCspWudwI6jJxfXQhcsa6mkioxoT9B1Qw2r+dM0GK5CAtX Bl4Q== ARC-Message-Signature: i=1; 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=ZhU/ijR0prRQiVEhNMp0mVa213WLBVleAKmW9N9wF8o=; fh=LCw0BDFZVr/7GBjT0XhrDRQeO+VMZn7cYKyjxJv/UuI=; b=yBsSDYUjvF6XEcH4DYCRDS4zlcumkr7OExKrmCgwjKhu5V55kBSlMqhH3rXqjORIod IZfB5FJo7cHyF1Q8Rp/8nRRCw4y5laA+nFmAif4zmmIrD0ryxxJG8+dfFFY8c3GY/tjP S///2zbdan87IqLqq2kgtKUF1X8V3wT1ux6gYWtNxC4dwOAjLj/2Sc1qvMbAGORtHS8+ dosMAIZiqHxiutpnRil1hTvPLYCQtHVWoT4iSeuM/BnEesjd5PZ4JnVI+XdGv+9L1hqD 31QE21RB+8uffthm5/O/yGWo/DrNr0AJVJcTKYGTLyxjJ4WLFx2sSvt2jiGeG5FYKufX W55A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YnPDEDkr; spf=pass (google.com: domain of linux-kernel+bounces-1005-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1005-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h9-20020a67cfc9000000b00464814964c6si3222463vsm.667.2023.12.15.05.25.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 05:25:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1005-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YnPDEDkr; spf=pass (google.com: domain of linux-kernel+bounces-1005-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1005-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 81AC11C23240 for ; Fri, 15 Dec 2023 13:25:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5405364A4; Fri, 15 Dec 2023 13:21:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="YnPDEDkr" 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 271A12DF9F; Fri, 15 Dec 2023 13:21:45 +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=1702646504; bh=4G/ylAHrmIAiXwxQVYFSIowpnOIBt/Wfr3j3WfEtRUU=; h=From:To:Cc:Subject:Date:From; b=YnPDEDkrlJK7uYBS/6sBOX9Sq6M4kPspArbh3gJ1DCzE5snGquYyg8kL2N0wPJTIw fiTSc1auL6Mrn8O2QSBOPSrPMlWxBPf3jPNuJbUHnsdPH5LR5bJkAMKTJj98edmWX9 EQqNJ96HR/xd+mS1metDTIAz8ApaO54MSSCWRBUMHLACpKU6Iw9zbEmgX/C2M2uUD6 Ka2QLagjNJUVVWlZdvyNKeYZbdyvMuTDpoOCOe+h8LDAWuMSvS3ZfdInZv9Fra5DMT DWv23iNxo1LIz1bliPL+B02uMNNhgwFwrVGJGcpUs6RFo72wEdK1GJ2QEpL+Wta5w7 KxPiiRV5qPhPg== 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 1AC1D3781FB2; Fri, 15 Dec 2023 13:21:43 +0000 (UTC) From: Laura Nao To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Shuah Khan Cc: 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, Laura Nao Subject: [PATCH] kselftest: Add basic test for probing the rust sample modules Date: Fri, 15 Dec 2023 14:21:32 +0100 Message-Id: <20231215132132.169628-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: 1785354473275636537 X-GMAIL-MSGID: 1785354473275636537 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 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}"