aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_common_logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_common_logging.c')
-rw-r--r--src/util/test_common_logging.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/util/test_common_logging.c b/src/util/test_common_logging.c
index 6ae50b36b..8492d3c35 100644
--- a/src/util/test_common_logging.c
+++ b/src/util/test_common_logging.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file util/test_common_logging.c 22 * @file util/test_common_logging.c
@@ -27,8 +27,8 @@
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28 28
29static void 29static void
30my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component, 30my_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
@@ -38,61 +38,61 @@ my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component,
38 38
39 39
40int 40int
41main (int argc, char *argv[]) 41main(int argc, char *argv[])
42{ 42{
43 unsigned int failureCount = 0; 43 unsigned int failureCount = 0;
44 unsigned int logs = 0; 44 unsigned int logs = 0;
45 45
46 if (0 != putenv ("GNUNET_FORCE_LOG=")) 46 if (0 != putenv("GNUNET_FORCE_LOG="))
47 fprintf (stderr, "Failed to putenv: %s\n", strerror (errno)); 47 fprintf(stderr, "Failed to putenv: %s\n", strerror(errno));
48 GNUNET_log_setup ("test-common-logging", "DEBUG", "/dev/null"); 48 GNUNET_log_setup("test-common-logging", "DEBUG", "/dev/null");
49 GNUNET_logger_add (&my_log, &logs); 49 GNUNET_logger_add(&my_log, &logs);
50 GNUNET_logger_add (&my_log, &logs); 50 GNUNET_logger_add(&my_log, &logs);
51 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Testing...\n"); 51 GNUNET_log(GNUNET_ERROR_TYPE_BULK, "Testing...\n");
52 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Testing...\n"); 52 GNUNET_log(GNUNET_ERROR_TYPE_BULK, "Testing...\n");
53 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Testing...\n"); 53 GNUNET_log(GNUNET_ERROR_TYPE_BULK, "Testing...\n");
54 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Testing...\n"); 54 GNUNET_log(GNUNET_ERROR_TYPE_BULK, "Testing...\n");
55 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Testing...\n"); 55 GNUNET_log(GNUNET_ERROR_TYPE_BULK, "Testing...\n");
56 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Testing...\n"); 56 GNUNET_log(GNUNET_ERROR_TYPE_BULK, "Testing...\n");
57 GNUNET_logger_remove (&my_log, &logs); 57 GNUNET_logger_remove(&my_log, &logs);
58 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Flusher...\n"); 58 GNUNET_log(GNUNET_ERROR_TYPE_BULK, "Flusher...\n");
59 /* the last 6 calls should be merged (repated bulk messages!) */ 59 /* the last 6 calls should be merged (repated bulk messages!) */
60 GNUNET_logger_remove (&my_log, &logs); 60 GNUNET_logger_remove(&my_log, &logs);
61 if (logs != 4) 61 if (logs != 4)
62 { 62 {
63 fprintf (stdout, "Expected 4 log calls, got %u\n", logs); 63 fprintf(stdout, "Expected 4 log calls, got %u\n", logs);
64 failureCount++; 64 failureCount++;
65 } 65 }
66 GNUNET_break (0 == 66 GNUNET_break(0 ==
67 strcmp (_("ERROR"), 67 strcmp(_("ERROR"),
68 GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_ERROR))); 68 GNUNET_error_type_to_string(GNUNET_ERROR_TYPE_ERROR)));
69 GNUNET_break (0 == 69 GNUNET_break(0 ==
70 strcmp (_("WARNING"), 70 strcmp(_("WARNING"),
71 GNUNET_error_type_to_string 71 GNUNET_error_type_to_string
72 (GNUNET_ERROR_TYPE_WARNING))); 72 (GNUNET_ERROR_TYPE_WARNING)));
73 GNUNET_break (0 == 73 GNUNET_break(0 ==
74 strcmp (_("INFO"), 74 strcmp(_("INFO"),
75 GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_INFO))); 75 GNUNET_error_type_to_string(GNUNET_ERROR_TYPE_INFO)));
76 GNUNET_break (0 == 76 GNUNET_break(0 ==
77 strcmp (_("DEBUG"), 77 strcmp(_("DEBUG"),
78 GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG))); 78 GNUNET_error_type_to_string(GNUNET_ERROR_TYPE_DEBUG)));
79 GNUNET_log_setup ("test_common_logging", "WARNING", "/dev/null"); 79 GNUNET_log_setup("test_common_logging", "WARNING", "/dev/null");
80 logs = 0; 80 logs = 0;
81 GNUNET_logger_add (&my_log, &logs); 81 GNUNET_logger_add(&my_log, &logs);
82 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Checker...\n"); 82 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Checker...\n");
83 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Drop me...\n"); 83 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Drop me...\n");
84 GNUNET_logger_remove (&my_log, &logs); 84 GNUNET_logger_remove(&my_log, &logs);
85 if (logs != 1) 85 if (logs != 1)
86 { 86 {
87 fprintf (stdout, "Expected 1 log call, got %u\n", logs); 87 fprintf(stdout, "Expected 1 log call, got %u\n", logs);
88 failureCount++; 88 failureCount++;
89 } 89 }
90 90
91 if (failureCount != 0) 91 if (failureCount != 0)
92 { 92 {
93 fprintf (stdout, "%u TESTS FAILED!\n", failureCount); 93 fprintf(stdout, "%u TESTS FAILED!\n", failureCount);
94 return -1; 94 return -1;
95 } 95 }
96 return 0; 96 return 0;
97} /* end of main */ 97} /* end of main */
98 98