diff options
Diffstat (limited to 'src/util/test_common_logging.c')
-rw-r--r-- | src/util/test_common_logging.c | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/src/util/test_common_logging.c b/src/util/test_common_logging.c deleted file mode 100644 index 7d7656ed8..000000000 --- a/src/util/test_common_logging.c +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2008 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
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/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file util/test_common_logging.c | ||
23 | * @brief testcase for the logging module | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | |||
29 | static void | ||
30 | my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component, | ||
31 | const char *date, const char *msg) | ||
32 | { | ||
33 | unsigned int *c = ctx; | ||
34 | |||
35 | (*c)++; | ||
36 | } | ||
37 | |||
38 | |||
39 | int | ||
40 | main (int argc, char *argv[]) | ||
41 | { | ||
42 | unsigned int failureCount = 0; | ||
43 | unsigned int logs = 0; | ||
44 | |||
45 | if (0 != putenv ("GNUNET_FORCE_LOG=")) | ||
46 | fprintf (stderr, "Failed to putenv: %s\n", strerror (errno)); | ||
47 | GNUNET_log_setup ("test-common-logging", "DEBUG", "/dev/null"); | ||
48 | GNUNET_logger_add (&my_log, &logs); | ||
49 | GNUNET_logger_add (&my_log, &logs); | ||
50 | 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"); | ||
53 | 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"); | ||
56 | GNUNET_logger_remove (&my_log, &logs); | ||
57 | GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Flusher...\n"); | ||
58 | /* the last 6 calls should be merged (repated bulk messages!) */ | ||
59 | GNUNET_logger_remove (&my_log, &logs); | ||
60 | if (logs != 4) | ||
61 | { | ||
62 | fprintf (stdout, "Expected 4 log calls, got %u\n", logs); | ||
63 | failureCount++; | ||
64 | } | ||
65 | GNUNET_break (0 == | ||
66 | strcmp (_ ("ERROR"), | ||
67 | GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_ERROR))); | ||
68 | GNUNET_break (0 == | ||
69 | strcmp (_ ("WARNING"), | ||
70 | GNUNET_error_type_to_string | ||
71 | (GNUNET_ERROR_TYPE_WARNING))); | ||
72 | GNUNET_break (0 == | ||
73 | strcmp (_ ("INFO"), | ||
74 | GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_INFO))); | ||
75 | GNUNET_break (0 == | ||
76 | strcmp (_ ("DEBUG"), | ||
77 | GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG))); | ||
78 | GNUNET_log_setup ("test_common_logging", "WARNING", "/dev/null"); | ||
79 | logs = 0; | ||
80 | GNUNET_logger_add (&my_log, &logs); | ||
81 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Checker...\n"); | ||
82 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Drop me...\n"); | ||
83 | GNUNET_logger_remove (&my_log, &logs); | ||
84 | if (logs != 1) | ||
85 | { | ||
86 | fprintf (stdout, "Expected 1 log call, got %u\n", logs); | ||
87 | failureCount++; | ||
88 | } | ||
89 | |||
90 | if (failureCount != 0) | ||
91 | { | ||
92 | fprintf (stdout, "%u TESTS FAILED!\n", failureCount); | ||
93 | return -1; | ||
94 | } | ||
95 | return 0; | ||
96 | } /* end of main */ | ||
97 | |||
98 | |||
99 | /* end of test_common_logging.c */ | ||