test: specify non-negative log verbosity for the siglogging test
Less noise in the test output
This commit is contained in:
parent
3c5eaedaf9
commit
d178978ce2
|
@ -148,6 +148,8 @@ number_formatting(void)
|
||||||
-0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */
|
-0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
LogSetParameter(XLOG_VERBOSITY, -1);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(unsigned_tests); i++)
|
for (i = 0; i < ARRAY_SIZE(unsigned_tests); i++)
|
||||||
assert(check_number_format_test(unsigned_tests[i]));
|
assert(check_number_format_test(unsigned_tests[i]));
|
||||||
|
|
||||||
|
@ -178,6 +180,8 @@ static void logging_format(void)
|
||||||
uintptr_t ptr;
|
uintptr_t ptr;
|
||||||
char *fname = NULL;
|
char *fname = NULL;
|
||||||
|
|
||||||
|
LogSetParameter(XLOG_VERBOSITY, -1);
|
||||||
|
|
||||||
/* set up buf to contain ".....end" */
|
/* set up buf to contain ".....end" */
|
||||||
memset(buf, '.', sizeof(buf));
|
memset(buf, '.', sizeof(buf));
|
||||||
strcpy(&buf[sizeof(buf) - 4], "end");
|
strcpy(&buf[sizeof(buf) - 4], "end");
|
||||||
|
@ -197,59 +201,59 @@ static void logging_format(void)
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* boring test message */
|
/* boring test message */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "test message\n");
|
LogMessageVerbSigSafe(X_ERROR, 1, "test message\n");
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, "(EE) test message\n") == 0);
|
assert(strcmp(logmsg, "(EE) test message\n") == 0);
|
||||||
|
|
||||||
/* long buf is truncated to "....en\n" */
|
/* long buf is truncated to "....en\n" */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, buf);
|
LogMessageVerbSigSafe(X_ERROR, 1, buf);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
|
assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
|
||||||
|
|
||||||
/* same thing, this time as string substitution */
|
/* same thing, this time as string substitution */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%s", buf);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%s", buf);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
|
assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
|
||||||
|
|
||||||
/* strings containing placeholders should just work */
|
/* strings containing placeholders should just work */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", str);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%s\n", str);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, "(EE) %s %d %u %% %p %i\n") == 0);
|
assert(strcmp(logmsg, "(EE) %s %d %u %% %p %i\n") == 0);
|
||||||
|
|
||||||
/* literal % */
|
/* literal % */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "test %%\n");
|
LogMessageVerbSigSafe(X_ERROR, 1, "test %%\n");
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, "(EE) test %\n") == 0);
|
assert(strcmp(logmsg, "(EE) test %\n") == 0);
|
||||||
|
|
||||||
/* character */
|
/* character */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "test %c\n", 'a');
|
LogMessageVerbSigSafe(X_ERROR, 1, "test %c\n", 'a');
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, "(EE) test a\n") == 0);
|
assert(strcmp(logmsg, "(EE) test a\n") == 0);
|
||||||
|
|
||||||
/* something unsupported % */
|
/* something unsupported % */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "test %Q\n");
|
LogMessageVerbSigSafe(X_ERROR, 1, "test %Q\n");
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strstr(logmsg, "BUG") != NULL);
|
assert(strstr(logmsg, "BUG") != NULL);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "\n");
|
LogMessageVerbSigSafe(X_ERROR, 1, "\n");
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
|
|
||||||
/* string substitution */
|
/* string substitution */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
|
LogMessageVerbSigSafe(X_ERROR, 1, "%s\n", "substituted string");
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, "(EE) substituted string\n") == 0);
|
assert(strcmp(logmsg, "(EE) substituted string\n") == 0);
|
||||||
|
|
||||||
/* Invalid format */
|
/* Invalid format */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%4", 4);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%4", 4);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, "(EE) ") == 0);
|
assert(strcmp(logmsg, "(EE) ") == 0);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "\n");
|
LogMessageVerbSigSafe(X_ERROR, 1, "\n");
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
|
|
||||||
/* %hld is bogus */
|
/* %hld is bogus */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%hld\n", 4);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%hld\n", 4);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strstr(logmsg, "BUG") != NULL);
|
assert(strstr(logmsg, "BUG") != NULL);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "\n");
|
LogMessageVerbSigSafe(X_ERROR, 1, "\n");
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
|
|
||||||
/* number substitution */
|
/* number substitution */
|
||||||
|
@ -257,12 +261,12 @@ static void logging_format(void)
|
||||||
do {
|
do {
|
||||||
char expected[30];
|
char expected[30];
|
||||||
sprintf(expected, "(EE) %u\n", ui);
|
sprintf(expected, "(EE) %u\n", ui);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%u\n", ui);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%u\n", ui);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
sprintf(expected, "(EE) %x\n", ui);
|
sprintf(expected, "(EE) %x\n", ui);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%x\n", ui);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%x\n", ui);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
|
@ -276,22 +280,21 @@ static void logging_format(void)
|
||||||
do {
|
do {
|
||||||
char expected[30];
|
char expected[30];
|
||||||
sprintf(expected, "(EE) %lu\n", lui);
|
sprintf(expected, "(EE) %lu\n", lui);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%lu\n", lui);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%lu\n", lui);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
|
|
||||||
sprintf(expected, "(EE) %lld\n", (unsigned long long)ui);
|
sprintf(expected, "(EE) %lld\n", (unsigned long long)ui);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (unsigned long long)ui);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%lld\n", (unsigned long long)ui);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
sprintf(expected, "(EE) %lx\n", lui);
|
sprintf(expected, "(EE) %lx\n", lui);
|
||||||
printf("%s\n", expected);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%lx\n", lui);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%lx\n", lui);
|
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
sprintf(expected, "(EE) %llx\n", (unsigned long long)ui);
|
sprintf(expected, "(EE) %llx\n", (unsigned long long)ui);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%llx\n", (unsigned long long)ui);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%llx\n", (unsigned long long)ui);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
|
@ -306,12 +309,12 @@ static void logging_format(void)
|
||||||
do {
|
do {
|
||||||
char expected[30];
|
char expected[30];
|
||||||
sprintf(expected, "(EE) %d\n", i);
|
sprintf(expected, "(EE) %d\n", i);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%d\n", i);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%d\n", i);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
sprintf(expected, "(EE) %d\n", i | INT_MIN);
|
sprintf(expected, "(EE) %d\n", i | INT_MIN);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%d\n", i | INT_MIN);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%d\n", i | INT_MIN);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
|
@ -325,22 +328,22 @@ static void logging_format(void)
|
||||||
do {
|
do {
|
||||||
char expected[30];
|
char expected[30];
|
||||||
sprintf(expected, "(EE) %ld\n", li);
|
sprintf(expected, "(EE) %ld\n", li);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%ld\n", li);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
sprintf(expected, "(EE) %ld\n", li | LONG_MIN);
|
sprintf(expected, "(EE) %ld\n", li | LONG_MIN);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li | LONG_MIN);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%ld\n", li | LONG_MIN);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
sprintf(expected, "(EE) %lld\n", (long long)li);
|
sprintf(expected, "(EE) %lld\n", (long long)li);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (long long)li);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%lld\n", (long long)li);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
sprintf(expected, "(EE) %lld\n", (long long)(li | LONG_MIN));
|
sprintf(expected, "(EE) %lld\n", (long long)(li | LONG_MIN));
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (long long)(li | LONG_MIN));
|
LogMessageVerbSigSafe(X_ERROR, 1, "%lld\n", (long long)(li | LONG_MIN));
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
|
@ -353,7 +356,7 @@ static void logging_format(void)
|
||||||
|
|
||||||
/* pointer substitution */
|
/* pointer substitution */
|
||||||
/* we print a null-pointer differently to printf */
|
/* we print a null-pointer differently to printf */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%p\n", NULL);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%p\n", NULL);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, "(EE) 0x0\n") == 0);
|
assert(strcmp(logmsg, "(EE) 0x0\n") == 0);
|
||||||
|
|
||||||
|
@ -365,7 +368,7 @@ static void logging_format(void)
|
||||||
#else
|
#else
|
||||||
sprintf(expected, "(EE) %p\n", (void*)ptr);
|
sprintf(expected, "(EE) %p\n", (void*)ptr);
|
||||||
#endif
|
#endif
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%p\n", (void*)ptr);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%p\n", (void*)ptr);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
ptr <<= 1;
|
ptr <<= 1;
|
||||||
|
@ -376,20 +379,20 @@ static void logging_format(void)
|
||||||
double d = float_tests[i];
|
double d = float_tests[i];
|
||||||
char expected[30];
|
char expected[30];
|
||||||
sprintf(expected, "(EE) %.2f\n", d);
|
sprintf(expected, "(EE) %.2f\n", d);
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%f\n", d);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%f\n", d);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
/* test for length modifiers, we just ignore them atm */
|
/* test for length modifiers, we just ignore them atm */
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%.3f\n", d);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%.3f\n", d);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%3f\n", d);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%3f\n", d);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
|
|
||||||
LogMessageVerbSigSafe(X_ERROR, -1, "%.0f\n", d);
|
LogMessageVerbSigSafe(X_ERROR, 1, "%.0f\n", d);
|
||||||
read_log_msg(logmsg);
|
read_log_msg(logmsg);
|
||||||
assert(strcmp(logmsg, expected) == 0);
|
assert(strcmp(logmsg, expected) == 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue