Re: [PATCH 1/1] of: unittest: add program to process EXPECT messages

From: Frank Rowand
Date: Tue Feb 01 2022 - 13:27:30 EST


On 2/1/22 12:14 PM, frowand.list@xxxxxxxxx wrote:
> From: Frank Rowand <frank.rowand@xxxxxxxx>
>

< snip >

> I will reply to this message with the usage message from
> 'scripts/dtc/of_unittest_expect --help'.

< snip >

$ scripts/dtc/of_unittest_expect --help

usage:

of_unittest_expect CONSOLE_LOG

-h print program usage
--help print program usage
--hide-expect suppress output of EXPECTed lines
--line-num report line number of CONSOLE_LOG
--no-expect-stats do not report EXPECT statistics
--no-strip-ts do not strip leading console timestamps
--verbose do not suppress EXPECT begin and end lines
--version print program version and exit


Process a console log for EXPECTed test related messages to either
highlight expected devicetree unittest related messages or suppress
the messages. Leading console timestamps will be stripped.

Various unittests may trigger kernel messages from outside the
unittest code. The unittest annotates that it expects the message
to occur with an 'EXPECT \ : text' (begin) before triggering the
message, and an 'EXPECT / : text' (end) after triggering the message.

If an expected message does not occur, that will be reported.

For each expected message, the 'EXPECT \ : text' (begin) and
'EXPECT / : text' (end), 'text' will contain the message text.

If 'EXPECT \' (begin) and 'EXPECT /' (end) lines do not contain
matching 'text', that will be reported.

If EXPECT lines are nested, 'EXPECT /' (end) lines must be in the
reverse order of the corresponding 'EXPECT \' (begin) lines.

'EXPECT \ : text' (begin) and 'EXPECT / : text' (end) lines can
contain special patterns in 'text':

<<int>> matches: [+-]*[0-9]+
<<hex>> matches: (0x)*[0-9a-f]+

'EXPECT \' (begin) and 'EXPECT /' (end) lines are suppressed.

A prefix is added to every line of output:

'ok ' Line matches an enclosing EXPECT begin/end pair

'** ' Line reports of_unittest_expect warning or error

'-> ' Line reports start or end of the unittests

'>> ' Line reports a unittest test FAIL

' ' Lines that are not otherwise prefixed

Issues detected in CONSOLE_LOG are reported to STDOUT, not to STDERR.

Known Issues:

--line-num causes the CONSOLE_LOG line number to be printed in 4 columns.
If CONSOLE_LOG contains more than 9999 lines then more columns will be
used to report the line number for lines greater than 9999 (eg for
lines 10000 - 99999, 5 columns will be used).