diff options
Diffstat (limited to 'src/util/test_common_logging.c')
-rw-r--r-- | src/util/test_common_logging.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/src/util/test_common_logging.c b/src/util/test_common_logging.c index a940d3c07..cf291161e 100644 --- a/src/util/test_common_logging.c +++ b/src/util/test_common_logging.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | static void | 29 | static void |
30 | my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component, | 30 | my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component, |
31 | const char *date, const char *msg) | 31 | const char *date, const char *msg) |
32 | { | 32 | { |
33 | unsigned int *c = ctx; | 33 | unsigned int *c = ctx; |
34 | 34 | ||
@@ -44,9 +44,7 @@ main (int argc, char *argv[]) | |||
44 | unsigned int logs = 0; | 44 | unsigned int logs = 0; |
45 | 45 | ||
46 | if (0 != setenv ("GNUNET_FORCE_LOG", "", 1)) | 46 | if (0 != setenv ("GNUNET_FORCE_LOG", "", 1)) |
47 | fprintf (stderr, | 47 | fprintf (stderr, "Failed to setenv: %s\n", strerror (errno)); |
48 | "Failed to setenv: %s\n", | ||
49 | strerror (errno)); | ||
50 | GNUNET_log_setup ("test-common-logging", "DEBUG", "/dev/null"); | 48 | GNUNET_log_setup ("test-common-logging", "DEBUG", "/dev/null"); |
51 | GNUNET_logger_add (&my_log, &logs); | 49 | GNUNET_logger_add (&my_log, &logs); |
52 | GNUNET_logger_add (&my_log, &logs); | 50 | GNUNET_logger_add (&my_log, &logs); |
@@ -61,26 +59,23 @@ main (int argc, char *argv[]) | |||
61 | /* the last 6 calls should be merged (repated bulk messages!) */ | 59 | /* the last 6 calls should be merged (repated bulk messages!) */ |
62 | GNUNET_logger_remove (&my_log, &logs); | 60 | GNUNET_logger_remove (&my_log, &logs); |
63 | if (logs != 4) | 61 | if (logs != 4) |
64 | { | 62 | { |
65 | fprintf (stdout, "Expected 4 log calls, got %u\n", logs); | 63 | fprintf (stdout, "Expected 4 log calls, got %u\n", logs); |
66 | failureCount++; | 64 | failureCount++; |
67 | } | 65 | } |
68 | GNUNET_break (0 == | 66 | GNUNET_break (0 == |
69 | strcmp (_("ERROR"), | 67 | strcmp (_("ERROR"), |
70 | GNUNET_error_type_to_string | 68 | GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_ERROR))); |
71 | (GNUNET_ERROR_TYPE_ERROR))); | ||
72 | GNUNET_break (0 == | 69 | GNUNET_break (0 == |
73 | strcmp (_("WARNING"), | 70 | strcmp (_("WARNING"), |
74 | GNUNET_error_type_to_string | 71 | GNUNET_error_type_to_string |
75 | (GNUNET_ERROR_TYPE_WARNING))); | 72 | (GNUNET_ERROR_TYPE_WARNING))); |
76 | GNUNET_break (0 == | 73 | GNUNET_break (0 == |
77 | strcmp (_("INFO"), | 74 | strcmp (_("INFO"), |
78 | GNUNET_error_type_to_string | 75 | GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_INFO))); |
79 | (GNUNET_ERROR_TYPE_INFO))); | ||
80 | GNUNET_break (0 == | 76 | GNUNET_break (0 == |
81 | strcmp (_("DEBUG"), | 77 | strcmp (_("DEBUG"), |
82 | GNUNET_error_type_to_string | 78 | GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG))); |
83 | (GNUNET_ERROR_TYPE_DEBUG))); | ||
84 | GNUNET_log_setup ("test_common_logging", "WARNING", "/dev/null"); | 79 | GNUNET_log_setup ("test_common_logging", "WARNING", "/dev/null"); |
85 | logs = 0; | 80 | logs = 0; |
86 | GNUNET_logger_add (&my_log, &logs); | 81 | GNUNET_logger_add (&my_log, &logs); |
@@ -88,17 +83,17 @@ main (int argc, char *argv[]) | |||
88 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Drop me...\n"); | 83 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Drop me...\n"); |
89 | GNUNET_logger_remove (&my_log, &logs); | 84 | GNUNET_logger_remove (&my_log, &logs); |
90 | if (logs != 1) | 85 | if (logs != 1) |
91 | { | 86 | { |
92 | fprintf (stdout, "Expected 1 log call, got %u\n", logs); | 87 | fprintf (stdout, "Expected 1 log call, got %u\n", logs); |
93 | failureCount++; | 88 | failureCount++; |
94 | } | 89 | } |
95 | 90 | ||
96 | if (failureCount != 0) | 91 | if (failureCount != 0) |
97 | { | 92 | { |
98 | fprintf (stdout, "%u TESTS FAILED!\n", failureCount); | 93 | fprintf (stdout, "%u TESTS FAILED!\n", failureCount); |
99 | return -1; | 94 | return -1; |
100 | } | 95 | } |
101 | return 0; | 96 | return 0; |
102 | } /* end of main */ | 97 | } /* end of main */ |
103 | 98 | ||
104 | /* end of test_common_logging.c */ | 99 | /* end of test_common_logging.c */ |