From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796324427; b=pSJdViwUDvH9moWWNxRerExrkP0KsWOIGseoHmlSgFQy/bxF9fKaDxjvGeOK3fqEmx9A KTBD++Vjkb3mxKc6rt7ej8L9YMfR9UElGNVwigFm2dabgcNdX95/J6KVMhLFTrVT9zqZ6 ESLUUm6dCTGxuxQKNlARBSbMA+BFcPLkArPyI9kGtZZ5gGT909QT2U5L0cdO+LNsEGVSP AfMLZySmqV10SzO1WjZexZsgaAjjbjj/EhDqQkoJ7efVmJBs3Ty6MNobhcZ5XXciR1i92 w8/nN5yyiYQ9YLvoZ/qdMmOLPcoYVOzlDe7BLfjrcZ1thxgj7sb3gOPZWXThw+0qH7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796324427; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=5zRuBpmG1OGnLpTuuHRMAQo9BzLMGmTiqoYA8dK0RGI=; b=GodtTHQsWzvXoFGkARlm5S1Ie0ZU4B46kf6BG3hy9cTc7bQhKjDF/pvxGiZayDuHft/0 oSAoeavbVRNH/hZ/Nc2FxWXfIBN0CnY7G6UtwO5NqY2/gzyI8Lfd4tpdQX8B/9cpzqe7J EJ9BHDkv3IKbvVWlB/sRcSpUW32AV7wL+Ja+m5MG/kDmDdcydZqC77plo0l8BK/+R6RAQ 4m5RB+0Yvi1QtoAhlCFMDMJOQjYa2IGxjkE5wWYsJJzR6uEnFMBYYpPbHdhZeJYaOuPP0 iuoAuffiZyVGTlLrD1d7nrhDMsKW3H73t60O6OJwiu4FmFDhPS62/YQRoLxtNkda4Jg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="kT57X/yK"; arc=none smtp.remote-ip=209.85.221.69 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (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 47DC560A2634 for ; Thu, 3 Dec 2026 19:00:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 47DC560A2634 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=kT57X/yK Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-4bbc86e1eb0so145451f8f.0 for ; Thu, 03 Dec 2026 11:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796324426; x=1796929226; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5zRuBpmG1OGnLpTuuHRMAQo9BzLMGmTiqoYA8dK0RGI=; b=kT57X/yKCsrX/heU6cbIZwp2MiEibEJhEsC1fk6JSNd+6FUAAZdmG+bC/oEksEW7de abDE/9ZVO1f/U13BaD839u9lGw/GaHyhScFud3SWsgRpp4G+GQvGTtAa+dHwoR59o3wQ KHQbr9iDzvCfrg6NebB90bnrIMrPyBHZiPevuBtheeQ+gXXQSaIZ3xbV/T8wqa9Ha8jP UBBtNoGD5+QbcDBCWdnrZMwQkmmwBu3zoTHtVl+OE6sW8d7o+2O3QLV4I3PrgBK5CmBv hNWH7LVODnpdDI37c9MkHlbMGa0wWHYmRv5WLuwRbudVYnr/ds7n4Bv2h9bSfPsx6r8o Pk4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796324426; x=1796929226; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5zRuBpmG1OGnLpTuuHRMAQo9BzLMGmTiqoYA8dK0RGI=; b=ou1AiCvdYDz/AVbiafAztbkTTPv8UfcbEP5p7SbCLIkZkSXS9tyMLst2GaMuE5+yrD 0pXfkuEDWrsJK+d+0DX4INPgTBWYl3XXWBcRi97o12/jKxs11dL2ajpu+nn8Q065N6BU VQFa3VBiW/co1d37V4kpFFQaaeLpBxDamGMHEOng0FvcaVlyaAK+D/UZ5tTELQNybBcD lOq8F5gCWxjvCZ7j3saJNn3rRsaroB6z1Y2stSdQlK8W/OMk65HaEoRNVWX6FU4lW2xP qBUcoRSfDeRYZK3ryTb8XwMSwmOdzxD5uLXZmnKN6oTTnJZ9/a8K5t/ryTyvTxQA8Bqv 0LHA== X-Forwarded-Encrypted: i=1; AL+hErHWJc6V9afol0aw2fX+nrHEu0A/bP8y82PxmtDrFr6WPC8AEZ6vlaAwRMrEZLGYgxUEEPivZJQWvfRGQ3W3/YzNXFs=@vger.kernel.org X-Gm-Message-State: APuU4Z9XZms8LHyZJBEkJOA5P0qRenNRnrx3BJsEuqR3erzXpjnkji6v 8JbnB7rdnlAHhLgzRoTmKe1sk0AJkRwCoXF5tkMg1GZ7eL9CJf2fuQSVsNjnTCHiG3Nplu8YdUH IUbXgDu+KJujPbdWWexp6SA== X-Received: from wrqo8.prod.google.com ([2002:a5d:4a88:0:b0:4a5:75ca:1d95]) (user=vdonnefort job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:1a8b:b0:48d:ed0a:e064 with SMTP id ffacd0b85a97d-4abb27274dcmr84330186f8f.24.1796324424753; Thu, 03 Dec 2026 11:00:24 -0800 (PST) Date: Thu, 3 Dec 2026 18:59:57 +0000 In-Reply-To: <20261203190007.2431041-1-vdonnefort@google.com> X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261203190007.2431041-1-vdonnefort@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261203190007.2431041-10-vdonnefort@google.com> Subject: [PATCH v10 09/19] tracing/remotes: selftests: Add a test for the dmesg tracefs file From: Vincent Donnefort To: rostedt@goodmis.org, mhiramat@kernel.org, linux-trace-kernel@vger.kernel.org Cc: mathieu.desnoyers@efficios.com, kernel-team@android.com, linux-kernel@vger.kernel.org, Vincent Donnefort Content-Type: text/plain; charset="UTF-8" Exercise the newly introduced dmesg tracefs file that turns on and off the dmesg redirection. Signed-off-by: Vincent Donnefort --- .../selftests/ftrace/test.d/remotes/dmesg.tc | 91 +++++++++++++++++++ .../selftests/ftrace/test.d/remotes/functions | 1 + .../ftrace/test.d/remotes/hypervisor/dmesg.tc | 11 +++ 3 files changed, 103 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/remotes/dmesg.tc create mode 100644 tools/testing/selftests/ftrace/test.d/remotes/hypervisor/dmesg.tc diff --git a/tools/testing/selftests/ftrace/test.d/remotes/dmesg.tc b/tools/testing/selftests/ftrace/test.d/remotes/dmesg.tc new file mode 100644 index 000000000000..f667b14556b6 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/remotes/dmesg.tc @@ -0,0 +1,91 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Test trace remote dmesg redirection +# requires: remotes/test remotes/test/dmesg + +. $TEST_DIR/remotes/functions + +test_dmesg() +{ + if [ ! -f /sys/module/printk/parameters/time ] || [ "$(cat /sys/module/printk/parameters/time)" != "Y" ]; then + echo "printk timestamps are disabled - please enable CONFIG_PRINTK_TIME" + exit_unsupported + fi + + echo 0 > tracing_on + assert_unloaded + + # + # Test dmesg on/off when tracing is disabled + # + echo 1 > dmesg + test $(cat dmesg) -eq 1 + assert_loaded + + echo 0 > dmesg + test $(cat dmesg) -eq 0 + assert_unloaded + + # + # Test events are logged to dmesg + # + + echo 1 > tracing_on + assert_loaded + echo 1 > dmesg + test $(cat dmesg) -eq 1 + + # Timestamp format is '[ XXXX.YYYY]' + last_ts=$(dmesg | tail -1 | sed -n 's/^\[ *\([0-9]*.[0-9]*\)\].*/\1/p') + if [ -z "$last_ts" ]; then + last_ts=0 + fi + + # Emit events from the same CPU + for cpu in $(get_cpu_ids); do + break + done + + nr_events=128 + for i in $(seq 1 $nr_events); do + taskset -c $cpu echo $i > write_event + done + + sleep 1 + output=$(mktemp $TMPDIR/remote_test.XXXXXX) + dmesg | awk -v ts=$last_ts ' + /^\[ *[0-9]+\.[0-9]+\]/ { + t=$0; sub(/^[[ \t]*/, "", t); sub(/].*/, "", t); + if (t+0 > ts+0) print $0 + }' | grep "selftest id=" | sed 's/^.*\(\[[0-9]*\]\s*[0-9]*\.[0-9]*: \)/\1/' > $output + + check_trace 1 $nr_events $output + + rm $output + + # + # Disable dmesg and verify events were not consumed by dmesg + # + echo 0 > dmesg + test $(cat dmesg) -eq 0 + + start_id=$(($nr_events + 1)) + end_id=$(($start_id + $nr_events)) + + for i in $(seq $start_id $end_id); do + echo $i > write_event + done + + sleep 1 + + output=$(dump_trace_pipe) + check_trace $start_id $end_id $output + rm $output +} + +if [ -z "$SOURCE_REMOTE_TEST" ]; then + set -e + + setup_remote_test + test_dmesg +fi diff --git a/tools/testing/selftests/ftrace/test.d/remotes/functions b/tools/testing/selftests/ftrace/test.d/remotes/functions index 05224fac3653..c368dea2ac4e 100644 --- a/tools/testing/selftests/ftrace/test.d/remotes/functions +++ b/tools/testing/selftests/ftrace/test.d/remotes/functions @@ -8,6 +8,7 @@ setup_remote() cd remotes/$name/ echo 0 > tracing_on + [ -f dmesg ] && echo 0 > dmesg clear_trace echo 7 > buffer_size_kb echo 0 > events/enable diff --git a/tools/testing/selftests/ftrace/test.d/remotes/hypervisor/dmesg.tc b/tools/testing/selftests/ftrace/test.d/remotes/hypervisor/dmesg.tc new file mode 100644 index 000000000000..4d6ce8fed3cb --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/remotes/hypervisor/dmesg.tc @@ -0,0 +1,11 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Test hypervisor trace dmesg redirection +# requires: remotes/hypervisor/write_event remotes/hypervisor/dmesg + +SOURCE_REMOTE_TEST=1 +. $TEST_DIR/remotes/dmesg.tc + +set -e +setup_remote "hypervisor" +test_dmesg -- 2.56.1.915.g69d5ec7298-goog