Re: [PATCH v4 07/18] tracing/remotes: selftests: Add a test for the dmesg tracefs file

Steven Rostedt <[email protected]>
Newsgroups gmane.linux.kernel
Message-ID <20260810184601.2d42dfd7@robin>
Adding Sashiko review: https://sashiko.dev/#/patchset/20260804140333.797210-2-vdonnefort%40google.com


> --- Patch [7]: [PATCH v4 07/18] tracing/remotes: selftests: Add a test for the dmesg tracefs file ---
> commit e79aa4baf215905a3bfd330e32c4f3d3b06f9a1c
> Author: Vincent Donnefort <[email protected]>
> 
> tracing/remotes: selftests: Add a test for the dmesg tracefs file
> 
> This commit adds a new ftrace selftest for the dmesg tracefs file. It
> exercises the dmesg redirection by toggling it on and off, and verifies
> that events are correctly logged to or withheld from the kernel log.
> 
> > 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
> > --- /dev/null
> > +++ b/tools/testing/selftests/ftrace/test.d/remotes/dmesg.tc
> 
> [ ... ]
> 
> > +test_dmesg()
> > +{
> > +    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
> > +    #
> > +    dmesg -c > /dev/null
> 
> Does this indiscriminately clear the system-wide kernel ring buffer?
> 
> Flushing the global log buffer destroys all previous kernel log history.
> In automated testing frameworks, this can suppress earlier warnings, oopses,
> or bug reports that occurred during the test run or kernel boot, making
> failure triage much more difficult.
> 
> Could this be adjusted to isolate the test output without permanently
> wiping the global dmesg history?

I agree, tests should not clear dmesg history.

-- Steve

> 
> > +
> > +    echo 1 > tracing_on
> > +    assert_loaded
> > +    echo 1 > dmesg
> > +    test $(cat dmesg) -eq 1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.