tests: sprintf: cleanup to work with newlib
newlib doesn't implement the internal buffer the same way that minimal libc does, so only run that check with min libc (ie !CONFIG_NEWLIB_LIBC). Also, reported the length we did get if the buffer is to big. Finally include <stdarg.h> since we are dealing with va_lists and such. Change-Id: I6b23e448e5785df978ac8c2757099e2b8aaace54 Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
e60af3be66
commit
7fb0e36060
1 changed files with 5 additions and 2 deletions
|
@ -13,6 +13,7 @@ This module contains the code for testing sprintf() functionality.
|
||||||
|
|
||||||
#include <tc_util.h>
|
#include <tc_util.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#define DEADBEEF 0xdeadbeef
|
#define DEADBEEF 0xdeadbeef
|
||||||
|
|
||||||
|
@ -619,11 +620,13 @@ int sprintfStringTest(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = sprintf(buffer, "%s", REALLY_LONG_STRING);
|
len = sprintf(buffer, "%s", REALLY_LONG_STRING);
|
||||||
|
#ifndef CONFIG_NEWLIB_LIBC
|
||||||
if (len != PRINTF_MAX_STRING_LENGTH) {
|
if (len != PRINTF_MAX_STRING_LENGTH) {
|
||||||
TC_ERROR("Internals changed. Max string length no longer %d\n",
|
TC_ERROR("Internals changed. Max string length no longer %d got %d\n",
|
||||||
PRINTF_MAX_STRING_LENGTH);
|
PRINTF_MAX_STRING_LENGTH, len);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (strncmp(buffer, REALLY_LONG_STRING, PRINTF_MAX_STRING_LENGTH) != 0) {
|
if (strncmp(buffer, REALLY_LONG_STRING, PRINTF_MAX_STRING_LENGTH) != 0) {
|
||||||
TC_ERROR("First %d characters of REALLY_LONG_STRING not printed!\n",
|
TC_ERROR("First %d characters of REALLY_LONG_STRING not printed!\n",
|
||||||
PRINTF_MAX_STRING_LENGTH);
|
PRINTF_MAX_STRING_LENGTH);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue