summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/signal-logging.c67
1 files changed, 35 insertions, 32 deletions
diff --git a/test/signal-logging.c b/test/signal-logging.c
index 1eaf96867..80d7c6f60 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -148,6 +148,8 @@ number_formatting(void)
-0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */
} ;
+ LogSetParameter(XLOG_VERBOSITY, -1);
+
for (i = 0; i < ARRAY_SIZE(unsigned_tests); i++)
assert(check_number_format_test(unsigned_tests[i]));
@@ -178,6 +180,8 @@ static void logging_format(void)
uintptr_t ptr;
char *fname = NULL;
+ LogSetParameter(XLOG_VERBOSITY, -1);
+
/* set up buf to contain ".....end" */
memset(buf, '.', sizeof(buf));
strcpy(&buf[sizeof(buf) - 4], "end");
@@ -197,59 +201,59 @@ static void logging_format(void)
} while (0)
/* boring test message */
- LogMessageVerbSigSafe(X_ERROR, -1, "test message\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "test message\n");
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) test message\n") == 0);
/* long buf is truncated to "....en\n" */
- LogMessageVerbSigSafe(X_ERROR, -1, buf);
+ LogMessageVerbSigSafe(X_ERROR, 1, buf);
read_log_msg(logmsg);
assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
/* same thing, this time as string substitution */
- LogMessageVerbSigSafe(X_ERROR, -1, "%s", buf);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%s", buf);
read_log_msg(logmsg);
assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
/* strings containing placeholders should just work */
- LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", str);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%s\n", str);
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) %s %d %u %% %p %i\n") == 0);
/* literal % */
- LogMessageVerbSigSafe(X_ERROR, -1, "test %%\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "test %%\n");
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) test %\n") == 0);
/* character */
- LogMessageVerbSigSafe(X_ERROR, -1, "test %c\n", 'a');
+ LogMessageVerbSigSafe(X_ERROR, 1, "test %c\n", 'a');
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) test a\n") == 0);
/* something unsupported % */
- LogMessageVerbSigSafe(X_ERROR, -1, "test %Q\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "test %Q\n");
read_log_msg(logmsg);
assert(strstr(logmsg, "BUG") != NULL);
- LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "\n");
fseek(f, 0, SEEK_END);
/* string substitution */
- LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
+ LogMessageVerbSigSafe(X_ERROR, 1, "%s\n", "substituted string");
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) substituted string\n") == 0);
/* Invalid format */
- LogMessageVerbSigSafe(X_ERROR, -1, "%4", 4);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%4", 4);
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) ") == 0);
- LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "\n");
fseek(f, 0, SEEK_END);
/* %hld is bogus */
- LogMessageVerbSigSafe(X_ERROR, -1, "%hld\n", 4);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%hld\n", 4);
read_log_msg(logmsg);
assert(strstr(logmsg, "BUG") != NULL);
- LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+ LogMessageVerbSigSafe(X_ERROR, 1, "\n");
fseek(f, 0, SEEK_END);
/* number substitution */
@@ -257,12 +261,12 @@ static void logging_format(void)
do {
char expected[30];
sprintf(expected, "(EE) %u\n", ui);
- LogMessageVerbSigSafe(X_ERROR, -1, "%u\n", ui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%u\n", ui);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
sprintf(expected, "(EE) %x\n", ui);
- LogMessageVerbSigSafe(X_ERROR, -1, "%x\n", ui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%x\n", ui);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
@@ -276,22 +280,21 @@ static void logging_format(void)
do {
char expected[30];
sprintf(expected, "(EE) %lu\n", lui);
- LogMessageVerbSigSafe(X_ERROR, -1, "%lu\n", lui);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%lu\n", lui);
read_log_msg(logmsg);
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);
assert(strcmp(logmsg, expected) == 0);
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);
assert(strcmp(logmsg, expected) == 0);
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);
assert(strcmp(logmsg, expected) == 0);
@@ -306,12 +309,12 @@ static void logging_format(void)
do {
char expected[30];
sprintf(expected, "(EE) %d\n", i);
- LogMessageVerbSigSafe(X_ERROR, -1, "%d\n", i);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%d\n", i);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
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);
assert(strcmp(logmsg, expected) == 0);
@@ -325,22 +328,22 @@ static void logging_format(void)
do {
char expected[30];
sprintf(expected, "(EE) %ld\n", li);
- LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%ld\n", li);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
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);
assert(strcmp(logmsg, expected) == 0);
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);
assert(strcmp(logmsg, expected) == 0);
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);
assert(strcmp(logmsg, expected) == 0);
@@ -353,7 +356,7 @@ static void logging_format(void)
/* pointer substitution */
/* 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);
assert(strcmp(logmsg, "(EE) 0x0\n") == 0);
@@ -365,7 +368,7 @@ static void logging_format(void)
#else
sprintf(expected, "(EE) %p\n", (void*)ptr);
#endif
- LogMessageVerbSigSafe(X_ERROR, -1, "%p\n", (void*)ptr);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%p\n", (void*)ptr);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
ptr <<= 1;
@@ -376,20 +379,20 @@ static void logging_format(void)
double d = float_tests[i];
char expected[30];
sprintf(expected, "(EE) %.2f\n", d);
- LogMessageVerbSigSafe(X_ERROR, -1, "%f\n", d);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%f\n", d);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
/* 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);
assert(strcmp(logmsg, expected) == 0);
- LogMessageVerbSigSafe(X_ERROR, -1, "%3f\n", d);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%3f\n", d);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
- LogMessageVerbSigSafe(X_ERROR, -1, "%.0f\n", d);
+ LogMessageVerbSigSafe(X_ERROR, 1, "%.0f\n", d);
read_log_msg(logmsg);
assert(strcmp(logmsg, expected) == 0);
}