From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796414517; b=i2LioTlsLsN6uBMOmk4loaDOHxZEhM4T/e44iuS+7uzMxe8KSo67+s/P2I7vX60NcaBR +VRy4NCbwiJ3s0LgQpGTh0n3dSAS6xZnIUMLFBBbUQ1zGVZ2deMNOvZXtMh6bkuNm0W4L LQWvji2dr5HyL85+KUyPW+Kb5De7rvVHBMobu2YvbqqDaRAkpX80upQyCDOhojHfFnNeB vZW5cTXvF/YVnJP2F64V+bMiXzNmMaK7WQ+YMpi4KA4XZHv4rLwyjOBd3MgZupeKBYRh8 +IZnQaszGU29Zj8HRMjlclq5gmE07ujs8vXK5f+uRdQqCFtRrUNZxrEDSDaqhCicQCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796414517; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:Message-ID:In-Reply-To:References:From:Subject:To:Cc: MIME-Version:Content-Type:Content-Disposition:User-Agent; bh=L16YMyPRYX9sbsVYPrbJgB9DzHpnOvSQ9jU9Af8dk+g=; b=sy/0VkEmROFlXnaYE8tS7d5er6wOQ2vptO1j/4bNguk0mvv7JbhGw954ZJUf0gzyrMCO EUokFgAv/JZJBkj4rs5MlYt64Ua6LOPJYtFgTK9GgjmeixKsQeWRAYGwD6SBb9tM/EmiZ Z0l0Uj+3dgjwzJSQmp6J3FgWfE8+afA87/1Fj13i4V9H/BMr28HDuRE2vlDpTgqEjrCCj /1CB02UIOctXEYo9YCDpsL13Iwd3hRyTDUg2GLENEHvJ9DY4Pp2SDa1mojK6DEwWIQuuC UPHK1DxdpffDhvAWTbd+i78oHnHQfiIsYBP1EmXC4oie4JMsMPtC1j7M5UNNznw+mTQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=ZEnIzGjs; arc=none smtp.remote-ip=209.85.128.180 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9EA0606A680 for ; Fri, 4 Dec 2026 20:01:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B9EA0606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=ZEnIzGjs Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-8b4d86f5328so10129137b3.0 for ; Fri, 04 Dec 2026 12:01:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1796414516; x=1797019316; darn=vger.kernel.org; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:references:in-reply-to:message-id:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=L16YMyPRYX9sbsVYPrbJgB9DzHpnOvSQ9jU9Af8dk+g=; b=ZEnIzGjsH/pGvdiAKlpXrJ6ShZazVXTwWMV0Qq4fPBIlIpASNBi8J0YrMnq1SJth/O 7js3a32lH6u9oMEnYmOFkMheqplShM4zeUDFbAzUqixpk0+PUJB+DPPb0YFCD15jn57l QJb3EmBAKRuqOjXMBqVFw8QI9C48bgz7pyqUI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796414516; x=1797019316; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:references:in-reply-to:message-id:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=L16YMyPRYX9sbsVYPrbJgB9DzHpnOvSQ9jU9Af8dk+g=; b=1RHT8NENRt3NzTz2tNrXgachEWoCS4qbSlDwno6f+RdWeVxBDXeV0je+jymZa3w/bC cqhqs1ZpR7Sbf+PYWFl4Ley392exuOUcGIU+J1/tQU54kiP1+GZ2GUvlfNtyn67t9i5e DkzHsRvjeo8IvU0rL/y6nsBCxg2wyit1bNtu1oxhMvzUO6tQ2CDdhuD6/F/CXdm/ytNk Uvzgb1qJUIvFjukZB54eBzr/jB/TUJW/P5NBC2COK+CQKMlOQAyvhbwTvEYU64tnpDtE i66baSh+aEVN1OHihCOhJL9AkYnsuwdgSKqWyxl0IiYh5WVNByDb3CFOd/In3CxcdVPM M9IA== X-Forwarded-Encrypted: i=1; AL+hErGz0lDiB6aUQwJ6sUIdT/jyKYv2wNERRJVOanRH40qcAQ0MG1sJtameAwGAqt+PZOm1PAGzo/YtH96HpZE=@vger.kernel.org X-Gm-Message-State: AB4q+uGYxMKkkpai4ycLud4N0j7EG64aKiRDDLgdJLbq1ps10KytiZVU cnvRdOArkzXx2Vw8wp72SIiSVq8VlKm70W4EWGAGvs+KqZ2RRuBuIQraGo630EaXDLY= X-Gm-Gg: AZFdTZcRRzbJrZf7+sUBvHwV5xC26VAPC6tffd+vh0dahGaoXXU1Ahd/uK1991pgNFU nNcBQgcQTrAcFT1Kjjd4Dy5SxTPYdckY+cB1QEzHNfh12yYm3vnOClMia8F4vegnq1IQ+AYPnlH LkhdM9ADnuDhF3hiUQP+s4ljoLUKdcO6j+k2kk0+u9w+btoh0HA3FHVS8261XI5bErXZ3xhMELD 6Y98uaJ1g50wk7MW2AoLQ3bqE3r3ohiJmdB0cjy4y20h+/EpSFO1bqHyqup5fE23HuxrCi5Wbzk X7E4ELzI9OGYA+7qGAymnChDJ/RLdbwpAM0j+t/5ub+521y1+WWKtGkzCVnQG1PVHuqKuQRFzG9 Fhst6edaZ6jKZqgQR83wYCCtmDxQm70+4dgUDocWkdX58SzRimBZ7K1E6WAMEIAJoMNaWV4SHjn /TBSxGda5cnXCPeqZ1dGjcMhn5pJ1u9xkezttyZB/bfIpFm5c+EdQZan2KnrcS+lYq/KtOFCdLr E6/G8vXnZdqfGtbkW7O8ug2gmWHJGWfGhI7xfyuxmUxVuCWxwAcQOoAqMYuUX9I8pxYtcqx+QUP TzktJTSgT5qXGh74Nj6tin+P5bpRPgdikGgQM4U5rOFd7zE2BaBWXY7UDqh7qyyzQETkkJiZN+w 40E1R1h3a8H3p3Q5HZt2HADN6zj36F6PLZbUmMuecSS9w5cRtHUktog9ljNf3Owy8qwPvlk1our yBSVWHHaZWgWJ7hPh1SVik/edIisV5BtViJ9tODyIBTHGvzYGXPKCl2z5MwyevGbRD6OavNxYj4 isrIjcf485rvxRDzo/DeTI= X-Received: by 2002:a05:690c:3008:b0:8b2:edd2:453c with SMTP id 00721157ae682-8b660d6bde1mr17147787b3.32.1796414515830; Fri, 04 Dec 2026 12:01:55 -0800 (PST) Received: from [172.18.0.2] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b660d567b0sm14346517b3.20.2026.12.04.12.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:01:55 -0800 (PST) Date: Fri, 04 Dec 2026 12:01:53 -0800 Message-ID: <7fd87b4bfe8ce69ba01365405ab9fec80753ad11.1796410817.git.chris@chrisdown.name> In-Reply-To: References: From: Chris Down Subject: [PATCH 2/2] selftests: netconsole: check that targets get distinct console names To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Shuah Khan , Shuah Khan , Gustavo Luiz Duarte , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pmladek@suse.com, john.ogness@linutronix.de, printk@lists.linux.dev, kernel-team@meta.com X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) Add a test which creates two targets whose names start with the same seven characters, so that netcons_ is cut to the same console name for both, and checks that /proc/consoles lists a different console for each of them. It fails without the previous patch: # ./netcons_console_name.sh FAIL: targets 9gqXFYF_alpha 9gqXFYF_beta share a console name in /proc/consoles: netcons_9gqXFYF0 netcons_9gqXFYF0 Signed-off-by: Chris Down --- .../selftests/drivers/net/netconsole/Makefile | 1 + .../net/netconsole/netcons_console_name.sh | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/netconsole/netcons_console_name.sh diff --git a/tools/testing/selftests/drivers/net/netconsole/Makefile b/tools/testing/selftests/drivers/net/netconsole/Makefile index c7972a40babf..0a689d75aed4 100644 --- a/tools/testing/selftests/drivers/net/netconsole/Makefile +++ b/tools/testing/selftests/drivers/net/netconsole/Makefile @@ -9,6 +9,7 @@ TEST_INCLUDES := \ TEST_PROGS := \ netcons_basic.sh \ netcons_cmdline.sh \ + netcons_console_name.sh \ netcons_fragmented_msg.sh \ netcons_overflow.sh \ netcons_resume.sh \ diff --git a/tools/testing/selftests/drivers/net/netconsole/netcons_console_name.sh b/tools/testing/selftests/drivers/net/netconsole/netcons_console_name.sh new file mode 100755 index 000000000000..28a3f17f560d --- /dev/null +++ b/tools/testing/selftests/drivers/net/netconsole/netcons_console_name.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0 + +# This test creates two netconsole targets whose names start with the same +# seven characters. The console of a target is called netcons_, +# cut to the 15 characters that fit in the name of a console, so the consoles +# of these two targets get the same name and only the index that follows it +# can tell them apart. +# +# The test checks that /proc/consoles lists a different console for each of +# the two targets. +# +# Author: Chris Down + +set -euo pipefail + +SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") + +source "${SCRIPTDIR}"/../lib/sh/lib_netcons.sh + +# The seven characters that both target names start with +PREFIX=$(mktemp -u XXXXXXX) +CONSOLE="netcons_${PREFIX}" +TARGETS=("${PREFIX}_alpha" "${PREFIX}_beta") + +function cleanup() { + local T + + for T in "${TARGETS[@]}" + do + cleanup_netcons "${NETCONS_CONFIGFS}/${T}" + done + do_cleanup +} + +modprobe netdevsim 2> /dev/null || true +modprobe netconsole 2> /dev/null || true + +# Check for basic system dependency and exit if not found +check_for_dependencies +# Remove the namespace, interfaces and netconsole targets on exit +trap cleanup EXIT +# Create one namespace and two interfaces +set_network + +for T in "${TARGETS[@]}" +do + create_dynamic_target "extended" "${NETCONS_CONFIGFS}/${T}" +done + +# /proc/consoles starts each line with the name and the index of a console +NAMES=$(awk -v con="${CONSOLE}" 'index($1, con) == 1 { print $1 }' \ + /proc/consoles) +NR_CONSOLES=$(echo "${NAMES}" | grep -c . || true) +NR_NAMES=$(echo "${NAMES}" | sort -u | grep -c . || true) + +if [ "${NR_CONSOLES}" -ne "${#TARGETS[@]}" ] +then + echo "FAIL: found ${NR_CONSOLES} consoles called ${CONSOLE}, not ${#TARGETS[@]}" >&2 + exit "${ksft_fail}" +fi + +if [ "${NR_NAMES}" -ne "${NR_CONSOLES}" ] +then + echo "FAIL: targets ${TARGETS[*]} share a console name in /proc/consoles:" >&2 + echo "${NAMES}" >&2 + exit "${ksft_fail}" +fi + +exit "${ksft_pass}" -- 2.56.1