On Thu, Mar 6, 2025 at 9:25 AM Tamir Duberstein tamird@gmail.com wrote:
On Thu, Mar 6, 2025 at 7:25 AM Petr Mladek pmladek@suse.com wrote:
On Fri 2025-02-21 15:34:30, Tamir Duberstein wrote:
Convert the printf() self-test to a KUnit test.
[...]
What was the motivation to remove the trailing '\n', please?
It actually makes a difference from the printk() POV. Messages without the trailing '\n' are _not_ flushed to the console until another message is added. The reason is that they might still be appended by pr_cont(). And printk() emits only complete lines to the console.
In general, messages should include the trailing '\n' unless the code wants to append something later or the trailing '\n' is added by another layer of the code. It does not seem to be this case.
bufsize, fmt, ret, elen);
return 1;
return; }
[...]
I noticed in my testing that the trailing \n didn't change the test output, but I didn't know the details you shared about the trailing \n. I'll restore them, unless we jump straight to the KUNIT macros per the discussion above.
Ah, I forgot that `tc_fail` already delegates to KUNIT_FAIL. This was the reason I removed the trailing newlines -- there is a mix of present and absent trailing newlines in KUNIT_* macros, and it's not clear to me what the correct thing is. For instance, the examples in Documentation/dev-tools/kunit/{start,usage}.rst omit the trailing newlines.