ztest: prints newline after failure message

Most calls to ztest_assert() contain a message with no trailing
newline. So when it fails, we get (eg:):

  starting test - test_multilib

      Assertion failed at multilib.c:19: test_multilib: (c not equal to 323)
  smoke-test failed: wrong multilib selectedFAIL - test_multilib.

when we'd like to get:

  smoke-test failed: wrong multilib selected
  FAIL - test_multilib.

among other things, because it is easier to parse for correctness.

So this patch adds a trailing newline to the message instead of going
around trying to police every call site to do it.

print[kf]() is used vs k_str_out() as we need something that is
available also for unit tests. As this is not in any hot path,
performance wise is not such a big deal.

Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
This commit is contained in:
Inaky Perez-Gonzalez 2018-05-07 16:23:03 -07:00 committed by Anas Nashif
parent 27d34926e5
commit 2a64fe666a

View file

@ -49,8 +49,10 @@ static inline void _zassert(int cond,
file, line, func, default_msg);
#if defined(CONFIG_STDOUT_CONSOLE)
vprintf(msg, vargs);
printf("\n");
#else
vprintk(msg, vargs);
printk("\n");
#endif
va_end(vargs);
ztest_test_fail();