]> www.infradead.org Git - users/hch/xfstests-dev.git/commit
common: make helpers for ttyprintk usage
authorDarrick J. Wong <djwong@kernel.org>
Mon, 13 Nov 2023 17:08:24 +0000 (09:08 -0800)
committerZorro Lang <zlang@kernel.org>
Thu, 16 Nov 2023 14:45:37 +0000 (22:45 +0800)
commit59bf56a1a56e8b588d18c4c39757b439342cd24d
tree0118d78b68b858028078829d0b0180ef09aa551a
parent848c6a882a6faab9d2545a26ad5070a62f7a7bd1
common: make helpers for ttyprintk usage

A handful of tests write things to /dev/ttyprintk to make it easier to
pinpoint where in a test something went wrong.  This isn't entirely
robust, however, because ttyprintk is an optional feature.  In the grand
tradition of kernel design there's also a /dev/kmsg that does nearly the
same thing, is also optional, and there's no documentation spelling out
when one is supposed to use one or the other.

So.

Create a pair of helpers to append messages to the kernel log.  One
simply writes its arguments to the kernel log, and the other writes
stdin to the kernel log, stdout, and any other files specified as
arguments.

Underneath the covers, both functions will send the message to
/dev/ttyprintk if available.  If it isn't but /dev/kmsg is, they'll
send the messages there, prepending a "[U]" to emulate the only
discernable difference between ttyprintk and kmsg.

If neither are available, then either /dev or the kernel aren't allowing
us to write to the kernel log, and the messages are not logged.  The
second helper will still write the messages to stdout.

If this seems like overengineered nonsense, then yes it is.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/fuzzy
common/rc
tests/xfs/329
tests/xfs/434
tests/xfs/435
tests/xfs/436
tests/xfs/444
tests/xfs/516