diff options
Diffstat (limited to 'src/util/test_common_logging_dummy.c')
-rw-r--r-- | src/util/test_common_logging_dummy.c | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/src/util/test_common_logging_dummy.c b/src/util/test_common_logging_dummy.c deleted file mode 100644 index c6c6411da..000000000 --- a/src/util/test_common_logging_dummy.c +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2008-2013 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_dummy.c | ||
23 | * @brief dummy labrat for the testcase for the logging module (runtime | ||
24 | * log level adjustment) | ||
25 | * @author LRN | ||
26 | */ | ||
27 | #include "platform.h" | ||
28 | #undef GNUNET_EXTRA_LOGGING | ||
29 | #define GNUNET_EXTRA_LOGGING GNUNET_YES | ||
30 | |||
31 | #include "gnunet_util_lib.h" | ||
32 | |||
33 | /** | ||
34 | * Artificial delay attached to each log call that is not skipped out. | ||
35 | * This must be long enough for us to not to mistake skipped log call | ||
36 | * on a slow machine for a non-skipped one. | ||
37 | */ | ||
38 | #define OUTPUT_DELAY \ | ||
39 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 1000) | ||
40 | |||
41 | static void | ||
42 | my_log (void *ctx, | ||
43 | enum GNUNET_ErrorType kind, | ||
44 | const char *component, | ||
45 | const char *date, | ||
46 | const char *msg) | ||
47 | { | ||
48 | (void) ctx; | ||
49 | (void) kind; | ||
50 | (void) component; | ||
51 | (void) date; | ||
52 | if (strncmp ("test-common-logging-dummy", component, 25) != 0) | ||
53 | return; | ||
54 | fprintf (stdout, "%s", msg); | ||
55 | fflush (stdout); | ||
56 | } | ||
57 | |||
58 | |||
59 | #if ! defined(GNUNET_CULL_LOGGING) | ||
60 | static int | ||
61 | expensive_func () | ||
62 | { | ||
63 | return GNUNET_NETWORK_socket_select (NULL, NULL, NULL, OUTPUT_DELAY); | ||
64 | } | ||
65 | |||
66 | |||
67 | #endif | ||
68 | |||
69 | |||
70 | #define pr(kind, lvl) \ | ||
71 | { \ | ||
72 | struct GNUNET_TIME_Absolute t1, t2; \ | ||
73 | t1 = GNUNET_TIME_absolute_get (); \ | ||
74 | GNUNET_log (kind, "L%s %d\n", lvl, expensive_func ()); \ | ||
75 | t2 = GNUNET_TIME_absolute_get (); \ | ||
76 | printf ("1%s %llu\n", \ | ||
77 | lvl, \ | ||
78 | (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2) \ | ||
79 | .rel_value_us); \ | ||
80 | } | ||
81 | |||
82 | #define pr2(kind, lvl) \ | ||
83 | { \ | ||
84 | struct GNUNET_TIME_Absolute t1, t2; \ | ||
85 | t1 = GNUNET_TIME_absolute_get (); \ | ||
86 | GNUNET_log (kind, "L%s %d\n", lvl, expensive_func ()); \ | ||
87 | t2 = GNUNET_TIME_absolute_get (); \ | ||
88 | printf ("2%s %llu\n", \ | ||
89 | lvl, \ | ||
90 | (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2) \ | ||
91 | .rel_value_us); \ | ||
92 | } | ||
93 | |||
94 | |||
95 | int | ||
96 | main (int argc, char *argv[]) | ||
97 | { | ||
98 | (void) argc; | ||
99 | (void) argv; | ||
100 | /* We set up logging with NULL level - will be overridden by | ||
101 | * GNUNET_LOG or GNUNET_FORCE_LOG at runtime. | ||
102 | */ | ||
103 | GNUNET_log_setup ("test-common-logging-dummy", NULL, "/dev/null"); | ||
104 | GNUNET_logger_add (&my_log, NULL); | ||
105 | pr (GNUNET_ERROR_TYPE_ERROR, "ERROR"); | ||
106 | pr (GNUNET_ERROR_TYPE_WARNING, "WARNING"); | ||
107 | pr (GNUNET_ERROR_TYPE_INFO, "INFO"); | ||
108 | pr (GNUNET_ERROR_TYPE_DEBUG, "DEBUG"); | ||
109 | |||
110 | /* We set up logging with WARNING level - will onle be overridden by | ||
111 | * GNUNET_FORCE_LOG at runtime. | ||
112 | */ | ||
113 | GNUNET_log_setup ("test-common-logging-dummy", "WARNING", "/dev/null"); | ||
114 | pr2 (GNUNET_ERROR_TYPE_ERROR, "ERROR"); | ||
115 | pr2 (GNUNET_ERROR_TYPE_WARNING, "WARNING"); | ||
116 | pr2 (GNUNET_ERROR_TYPE_INFO, "INFO"); | ||
117 | pr2 (GNUNET_ERROR_TYPE_DEBUG, "DEBUG"); | ||
118 | return 0; | ||
119 | } /* end of main */ | ||
120 | |||
121 | |||
122 | /* end of test_common_logging_dummy.c */ | ||