tests/libc_newlib: fix pointers comparison for llvm

With llvm and samr21-xpro, I could not directly do 'printf == iprintf'.
But doing `(printf - iprintf) == 0` correctly checked if they are equal.

Co-authored-by: Kaspar Schleiser <kaspar@schleiser.de>
This commit is contained in:
cladmi 2018-09-21 17:57:48 +02:00
parent 028bc2a3e4
commit ba2a8dfe8a
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B

View File

@ -58,15 +58,18 @@ static void test_newlib(void)
/*
* Be sure `iprintf` and `printf` are used when `newlib` is included as
* they should be visible in the final elf file for compile time tests
*
* With llvm and samr21-xpro, I could not directly do 'printf == iprintf'.
* But doing `(printf - iprintf) == 0` correctly checked if they are equal.
*/
#ifdef MODULE_NEWLIB
#ifdef MODULE_NEWLIB_NANO
/* Nano maps iprintf to printf */
TEST_ASSERT(iprintf == printf);
TEST_ASSERT_MESSAGE((printf - iprintf) == 0, "iprintf == printf");
#else
/* Normal newlib does not */
TEST_ASSERT(iprintf != printf);
TEST_ASSERT_MESSAGE((printf - iprintf) != 0, "iprintf != printf");
#endif
#endif
}