diff options
Diffstat (limited to 'src/util/test_time.c')
-rw-r--r-- | src/util/test_time.c | 260 |
1 files changed, 130 insertions, 130 deletions
diff --git a/src/util/test_time.c b/src/util/test_time.c index 6f4a6332b..b46cac34d 100644 --- a/src/util/test_time.c +++ b/src/util/test_time.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 | * @file util/test_time.c | 21 | * @file util/test_time.c |
22 | * @brief testcase for time.c | 22 | * @brief testcase for time.c |
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | 27 | ||
28 | int | 28 | int |
29 | main (int argc, char *argv[]) | 29 | main(int argc, char *argv[]) |
30 | { | 30 | { |
31 | struct GNUNET_TIME_Absolute now; | 31 | struct GNUNET_TIME_Absolute now; |
32 | struct GNUNET_TIME_AbsoluteNBO nown; | 32 | struct GNUNET_TIME_AbsoluteNBO nown; |
@@ -41,212 +41,212 @@ main (int argc, char *argv[]) | |||
41 | struct GNUNET_TIME_RelativeNBO reln; | 41 | struct GNUNET_TIME_RelativeNBO reln; |
42 | unsigned int i; | 42 | unsigned int i; |
43 | 43 | ||
44 | GNUNET_log_setup ("test-time", "WARNING", NULL); | 44 | GNUNET_log_setup("test-time", "WARNING", NULL); |
45 | forever = GNUNET_TIME_UNIT_FOREVER_ABS; | 45 | forever = GNUNET_TIME_UNIT_FOREVER_ABS; |
46 | relForever = GNUNET_TIME_UNIT_FOREVER_REL; | 46 | relForever = GNUNET_TIME_UNIT_FOREVER_REL; |
47 | relUnit = GNUNET_TIME_UNIT_MILLISECONDS; | 47 | relUnit = GNUNET_TIME_UNIT_MILLISECONDS; |
48 | zero.abs_value_us = 0; | 48 | zero.abs_value_us = 0; |
49 | 49 | ||
50 | last = now = GNUNET_TIME_absolute_get (); | 50 | last = now = GNUNET_TIME_absolute_get(); |
51 | while (now.abs_value_us == last.abs_value_us) | 51 | while (now.abs_value_us == last.abs_value_us) |
52 | now = GNUNET_TIME_absolute_get (); | 52 | now = GNUNET_TIME_absolute_get(); |
53 | GNUNET_assert (now.abs_value_us > last.abs_value_us); | 53 | GNUNET_assert(now.abs_value_us > last.abs_value_us); |
54 | 54 | ||
55 | /* test overflow checking in multiply */ | 55 | /* test overflow checking in multiply */ |
56 | rel = GNUNET_TIME_UNIT_MILLISECONDS; | 56 | rel = GNUNET_TIME_UNIT_MILLISECONDS; |
57 | GNUNET_log_skip (1, GNUNET_NO); | 57 | GNUNET_log_skip(1, GNUNET_NO); |
58 | for (i = 0; i < 55; i++) | 58 | for (i = 0; i < 55; i++) |
59 | rel = GNUNET_TIME_relative_multiply (rel, 2); | 59 | rel = GNUNET_TIME_relative_multiply(rel, 2); |
60 | GNUNET_log_skip (0, GNUNET_NO); | 60 | GNUNET_log_skip(0, GNUNET_NO); |
61 | GNUNET_assert (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us); | 61 | GNUNET_assert(rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us); |
62 | /*check zero */ | 62 | /*check zero */ |
63 | rel.rel_value_us = (UINT64_MAX) - 1024; | 63 | rel.rel_value_us = (UINT64_MAX)-1024; |
64 | GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us == | 64 | GNUNET_assert(GNUNET_TIME_UNIT_ZERO.rel_value_us == |
65 | GNUNET_TIME_relative_multiply (rel, 0).rel_value_us); | 65 | GNUNET_TIME_relative_multiply(rel, 0).rel_value_us); |
66 | 66 | ||
67 | /* test infinity-check for relative to absolute */ | 67 | /* test infinity-check for relative to absolute */ |
68 | GNUNET_log_skip (1, GNUNET_NO); | 68 | GNUNET_log_skip(1, GNUNET_NO); |
69 | last = GNUNET_TIME_relative_to_absolute (rel); | 69 | last = GNUNET_TIME_relative_to_absolute(rel); |
70 | GNUNET_assert (last.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us); | 70 | GNUNET_assert(last.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us); |
71 | GNUNET_log_skip (0, GNUNET_YES); | 71 | GNUNET_log_skip(0, GNUNET_YES); |
72 | 72 | ||
73 | /* check relative to absolute */ | 73 | /* check relative to absolute */ |
74 | rel.rel_value_us = 1000000; | 74 | rel.rel_value_us = 1000000; |
75 | GNUNET_assert (GNUNET_TIME_absolute_get ().abs_value_us < | 75 | GNUNET_assert(GNUNET_TIME_absolute_get().abs_value_us < |
76 | GNUNET_TIME_relative_to_absolute (rel).abs_value_us); | 76 | GNUNET_TIME_relative_to_absolute(rel).abs_value_us); |
77 | /*check forever */ | 77 | /*check forever */ |
78 | rel.rel_value_us = UINT64_MAX; | 78 | rel.rel_value_us = UINT64_MAX; |
79 | GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == | 79 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == |
80 | GNUNET_TIME_relative_to_absolute (rel).abs_value_us); | 80 | GNUNET_TIME_relative_to_absolute(rel).abs_value_us); |
81 | /* check overflow for r2a */ | 81 | /* check overflow for r2a */ |
82 | rel.rel_value_us = (UINT64_MAX) - 1024; | 82 | rel.rel_value_us = (UINT64_MAX)-1024; |
83 | GNUNET_log_skip (1, GNUNET_NO); | 83 | GNUNET_log_skip(1, GNUNET_NO); |
84 | last = GNUNET_TIME_relative_to_absolute (rel); | 84 | last = GNUNET_TIME_relative_to_absolute(rel); |
85 | GNUNET_log_skip (0, GNUNET_NO); | 85 | GNUNET_log_skip(0, GNUNET_NO); |
86 | GNUNET_assert (last.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us); | 86 | GNUNET_assert(last.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us); |
87 | 87 | ||
88 | /* check overflow for relative add */ | 88 | /* check overflow for relative add */ |
89 | GNUNET_log_skip (1, GNUNET_NO); | 89 | GNUNET_log_skip(1, GNUNET_NO); |
90 | rel = GNUNET_TIME_relative_add (rel, rel); | 90 | rel = GNUNET_TIME_relative_add(rel, rel); |
91 | GNUNET_log_skip (0, GNUNET_NO); | 91 | GNUNET_log_skip(0, GNUNET_NO); |
92 | GNUNET_assert (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us); | 92 | GNUNET_assert(rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us); |
93 | 93 | ||
94 | GNUNET_log_skip (1, GNUNET_NO); | 94 | GNUNET_log_skip(1, GNUNET_NO); |
95 | rel = GNUNET_TIME_relative_add (relForever, relForever); | 95 | rel = GNUNET_TIME_relative_add(relForever, relForever); |
96 | GNUNET_log_skip (0, GNUNET_NO); | 96 | GNUNET_log_skip(0, GNUNET_NO); |
97 | GNUNET_assert (rel.rel_value_us == relForever.rel_value_us); | 97 | GNUNET_assert(rel.rel_value_us == relForever.rel_value_us); |
98 | 98 | ||
99 | GNUNET_log_skip (1, GNUNET_NO); | 99 | GNUNET_log_skip(1, GNUNET_NO); |
100 | rel = GNUNET_TIME_relative_add (relUnit, relUnit); | 100 | rel = GNUNET_TIME_relative_add(relUnit, relUnit); |
101 | GNUNET_assert (rel.rel_value_us == 2 * relUnit.rel_value_us); | 101 | GNUNET_assert(rel.rel_value_us == 2 * relUnit.rel_value_us); |
102 | 102 | ||
103 | /* check relation check in get_duration */ | 103 | /* check relation check in get_duration */ |
104 | future.abs_value_us = now.abs_value_us + 1000000; | 104 | future.abs_value_us = now.abs_value_us + 1000000; |
105 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).rel_value_us == | 105 | GNUNET_assert(GNUNET_TIME_absolute_get_difference(now, future).rel_value_us == |
106 | 1000000); | 106 | 1000000); |
107 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value_us == | 107 | GNUNET_assert(GNUNET_TIME_absolute_get_difference(future, now).rel_value_us == |
108 | 0); | 108 | 0); |
109 | 109 | ||
110 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).rel_value_us | 110 | GNUNET_assert(GNUNET_TIME_absolute_get_difference(zero, forever).rel_value_us |
111 | == forever.abs_value_us); | 111 | == forever.abs_value_us); |
112 | 112 | ||
113 | past.abs_value_us = now.abs_value_us - 1000000; | 113 | past.abs_value_us = now.abs_value_us - 1000000; |
114 | rel = GNUNET_TIME_absolute_get_duration (future); | 114 | rel = GNUNET_TIME_absolute_get_duration(future); |
115 | GNUNET_assert (rel.rel_value_us == 0); | 115 | GNUNET_assert(rel.rel_value_us == 0); |
116 | rel = GNUNET_TIME_absolute_get_duration (past); | 116 | rel = GNUNET_TIME_absolute_get_duration(past); |
117 | GNUNET_assert (rel.rel_value_us >= 1000000); | 117 | GNUNET_assert(rel.rel_value_us >= 1000000); |
118 | 118 | ||
119 | /* check get remaining */ | 119 | /* check get remaining */ |
120 | rel = GNUNET_TIME_absolute_get_remaining (now); | 120 | rel = GNUNET_TIME_absolute_get_remaining(now); |
121 | GNUNET_assert (rel.rel_value_us == 0); | 121 | GNUNET_assert(rel.rel_value_us == 0); |
122 | rel = GNUNET_TIME_absolute_get_remaining (past); | 122 | rel = GNUNET_TIME_absolute_get_remaining(past); |
123 | GNUNET_assert (rel.rel_value_us == 0); | 123 | GNUNET_assert(rel.rel_value_us == 0); |
124 | rel = GNUNET_TIME_absolute_get_remaining (future); | 124 | rel = GNUNET_TIME_absolute_get_remaining(future); |
125 | GNUNET_assert (rel.rel_value_us > 0); | 125 | GNUNET_assert(rel.rel_value_us > 0); |
126 | GNUNET_assert (rel.rel_value_us <= 1000000); | 126 | GNUNET_assert(rel.rel_value_us <= 1000000); |
127 | forever = GNUNET_TIME_UNIT_FOREVER_ABS; | 127 | forever = GNUNET_TIME_UNIT_FOREVER_ABS; |
128 | GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == | 128 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == |
129 | GNUNET_TIME_absolute_get_remaining (forever).rel_value_us); | 129 | GNUNET_TIME_absolute_get_remaining(forever).rel_value_us); |
130 | 130 | ||
131 | /* check endianess */ | 131 | /* check endianess */ |
132 | reln = GNUNET_TIME_relative_hton (rel); | 132 | reln = GNUNET_TIME_relative_hton(rel); |
133 | GNUNET_assert (rel.rel_value_us == GNUNET_TIME_relative_ntoh (reln).rel_value_us); | 133 | GNUNET_assert(rel.rel_value_us == GNUNET_TIME_relative_ntoh(reln).rel_value_us); |
134 | nown = GNUNET_TIME_absolute_hton (now); | 134 | nown = GNUNET_TIME_absolute_hton(now); |
135 | GNUNET_assert (now.abs_value_us == GNUNET_TIME_absolute_ntoh (nown).abs_value_us); | 135 | GNUNET_assert(now.abs_value_us == GNUNET_TIME_absolute_ntoh(nown).abs_value_us); |
136 | 136 | ||
137 | /* check absolute addition */ | 137 | /* check absolute addition */ |
138 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS); | 138 | future = GNUNET_TIME_absolute_add(now, GNUNET_TIME_UNIT_SECONDS); |
139 | GNUNET_assert (future.abs_value_us == now.abs_value_us + 1000 * 1000LL); | 139 | GNUNET_assert(future.abs_value_us == now.abs_value_us + 1000 * 1000LL); |
140 | 140 | ||
141 | future = GNUNET_TIME_absolute_add (forever, GNUNET_TIME_UNIT_ZERO); | 141 | future = GNUNET_TIME_absolute_add(forever, GNUNET_TIME_UNIT_ZERO); |
142 | GNUNET_assert (future.abs_value_us == forever.abs_value_us); | 142 | GNUNET_assert(future.abs_value_us == forever.abs_value_us); |
143 | 143 | ||
144 | rel.rel_value_us = (UINT64_MAX) - 1024; | 144 | rel.rel_value_us = (UINT64_MAX)-1024; |
145 | now.abs_value_us = rel.rel_value_us; | 145 | now.abs_value_us = rel.rel_value_us; |
146 | future = GNUNET_TIME_absolute_add (now, rel); | 146 | future = GNUNET_TIME_absolute_add(now, rel); |
147 | GNUNET_assert (future.abs_value_us == forever.abs_value_us); | 147 | GNUNET_assert(future.abs_value_us == forever.abs_value_us); |
148 | 148 | ||
149 | /* check zero */ | 149 | /* check zero */ |
150 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_ZERO); | 150 | future = GNUNET_TIME_absolute_add(now, GNUNET_TIME_UNIT_ZERO); |
151 | GNUNET_assert (future.abs_value_us == now.abs_value_us); | 151 | GNUNET_assert(future.abs_value_us == now.abs_value_us); |
152 | 152 | ||
153 | GNUNET_assert (forever.abs_value_us == | 153 | GNUNET_assert(forever.abs_value_us == |
154 | GNUNET_TIME_absolute_subtract (forever, | 154 | GNUNET_TIME_absolute_subtract(forever, |
155 | GNUNET_TIME_UNIT_MINUTES).abs_value_us); | 155 | GNUNET_TIME_UNIT_MINUTES).abs_value_us); |
156 | /*check absolute subtract */ | 156 | /*check absolute subtract */ |
157 | now.abs_value_us = 50000; | 157 | now.abs_value_us = 50000; |
158 | rel.rel_value_us = 100000; | 158 | rel.rel_value_us = 100000; |
159 | GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == | 159 | GNUNET_assert(GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == |
160 | (GNUNET_TIME_absolute_subtract (now, rel)).abs_value_us); | 160 | (GNUNET_TIME_absolute_subtract(now, rel)).abs_value_us); |
161 | rel.rel_value_us = 10000; | 161 | rel.rel_value_us = 10000; |
162 | GNUNET_assert (40000 == (GNUNET_TIME_absolute_subtract (now, rel)).abs_value_us); | 162 | GNUNET_assert(40000 == (GNUNET_TIME_absolute_subtract(now, rel)).abs_value_us); |
163 | 163 | ||
164 | /*check relative divide */ | 164 | /*check relative divide */ |
165 | GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == | 165 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == |
166 | (GNUNET_TIME_relative_divide (rel, 0)).rel_value_us); | 166 | (GNUNET_TIME_relative_divide(rel, 0)).rel_value_us); |
167 | 167 | ||
168 | rel = GNUNET_TIME_UNIT_FOREVER_REL; | 168 | rel = GNUNET_TIME_UNIT_FOREVER_REL; |
169 | GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == | 169 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == |
170 | (GNUNET_TIME_relative_divide (rel, 2)).rel_value_us); | 170 | (GNUNET_TIME_relative_divide(rel, 2)).rel_value_us); |
171 | 171 | ||
172 | rel = GNUNET_TIME_relative_divide (relUnit, 2); | 172 | rel = GNUNET_TIME_relative_divide(relUnit, 2); |
173 | GNUNET_assert (rel.rel_value_us == relUnit.rel_value_us / 2); | 173 | GNUNET_assert(rel.rel_value_us == relUnit.rel_value_us / 2); |
174 | 174 | ||
175 | 175 | ||
176 | /* check Return absolute time of 0ms */ | 176 | /* check Return absolute time of 0ms */ |
177 | zero = GNUNET_TIME_UNIT_ZERO_ABS; | 177 | zero = GNUNET_TIME_UNIT_ZERO_ABS; |
178 | 178 | ||
179 | /* check GNUNET_TIME_calculate_eta */ | 179 | /* check GNUNET_TIME_calculate_eta */ |
180 | last.abs_value_us = GNUNET_TIME_absolute_get ().abs_value_us - 1024; | 180 | last.abs_value_us = GNUNET_TIME_absolute_get().abs_value_us - 1024; |
181 | forever = GNUNET_TIME_UNIT_FOREVER_ABS; | 181 | forever = GNUNET_TIME_UNIT_FOREVER_ABS; |
182 | forever.abs_value_us = forever.abs_value_us - 1024; | 182 | forever.abs_value_us = forever.abs_value_us - 1024; |
183 | GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == | 183 | GNUNET_assert(GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == |
184 | GNUNET_TIME_calculate_eta (forever, 50000, 100000).rel_value_us); | 184 | GNUNET_TIME_calculate_eta(forever, 50000, 100000).rel_value_us); |
185 | /* check zero */ | 185 | /* check zero */ |
186 | GNUNET_log_skip (1, GNUNET_NO); | 186 | GNUNET_log_skip(1, GNUNET_NO); |
187 | GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us == | 187 | GNUNET_assert(GNUNET_TIME_UNIT_ZERO.rel_value_us == |
188 | (GNUNET_TIME_calculate_eta (last, 60000, 50000)).rel_value_us); | 188 | (GNUNET_TIME_calculate_eta(last, 60000, 50000)).rel_value_us); |
189 | GNUNET_log_skip (0, GNUNET_YES); | 189 | GNUNET_log_skip(0, GNUNET_YES); |
190 | /*check forever */ | 190 | /*check forever */ |
191 | GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == | 191 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == |
192 | (GNUNET_TIME_calculate_eta (last, 0, 50000)).rel_value_us); | 192 | (GNUNET_TIME_calculate_eta(last, 0, 50000)).rel_value_us); |
193 | 193 | ||
194 | /*check relative subtract */ | 194 | /*check relative subtract */ |
195 | now = GNUNET_TIME_absolute_get (); | 195 | now = GNUNET_TIME_absolute_get(); |
196 | rel.rel_value_us = now.abs_value_us; | 196 | rel.rel_value_us = now.abs_value_us; |
197 | relForever.rel_value_us = rel.rel_value_us + 1024; | 197 | relForever.rel_value_us = rel.rel_value_us + 1024; |
198 | GNUNET_assert (1024 == | 198 | GNUNET_assert(1024 == |
199 | GNUNET_TIME_relative_subtract (relForever, rel).rel_value_us); | 199 | GNUNET_TIME_relative_subtract(relForever, rel).rel_value_us); |
200 | /*check zero */ | 200 | /*check zero */ |
201 | GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us == | 201 | GNUNET_assert(GNUNET_TIME_UNIT_ZERO.rel_value_us == |
202 | GNUNET_TIME_relative_subtract (rel, relForever).rel_value_us); | 202 | GNUNET_TIME_relative_subtract(rel, relForever).rel_value_us); |
203 | /*check forever */ | 203 | /*check forever */ |
204 | rel.rel_value_us = UINT64_MAX; | 204 | rel.rel_value_us = UINT64_MAX; |
205 | GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == | 205 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == |
206 | GNUNET_TIME_relative_subtract (rel, relForever).rel_value_us); | 206 | GNUNET_TIME_relative_subtract(rel, relForever).rel_value_us); |
207 | 207 | ||
208 | /*check GNUNET_TIME_relative_min */ | 208 | /*check GNUNET_TIME_relative_min */ |
209 | now = GNUNET_TIME_absolute_get (); | 209 | now = GNUNET_TIME_absolute_get(); |
210 | rel.rel_value_us = now.abs_value_us; | 210 | rel.rel_value_us = now.abs_value_us; |
211 | relForever.rel_value_us = rel.rel_value_us - 1024; | 211 | relForever.rel_value_us = rel.rel_value_us - 1024; |
212 | GNUNET_assert (relForever.rel_value_us == | 212 | GNUNET_assert(relForever.rel_value_us == |
213 | GNUNET_TIME_relative_min (rel, relForever).rel_value_us); | 213 | GNUNET_TIME_relative_min(rel, relForever).rel_value_us); |
214 | 214 | ||
215 | /*check GNUNET_TIME_relative_max */ | 215 | /*check GNUNET_TIME_relative_max */ |
216 | GNUNET_assert (rel.rel_value_us == | 216 | GNUNET_assert(rel.rel_value_us == |
217 | GNUNET_TIME_relative_max (rel, relForever).rel_value_us); | 217 | GNUNET_TIME_relative_max(rel, relForever).rel_value_us); |
218 | 218 | ||
219 | /*check GNUNET_TIME_absolute_min */ | 219 | /*check GNUNET_TIME_absolute_min */ |
220 | now = GNUNET_TIME_absolute_get (); | 220 | now = GNUNET_TIME_absolute_get(); |
221 | last.abs_value_us = now.abs_value_us - 1024; | 221 | last.abs_value_us = now.abs_value_us - 1024; |
222 | GNUNET_assert (last.abs_value_us == | 222 | GNUNET_assert(last.abs_value_us == |
223 | GNUNET_TIME_absolute_min (now, last).abs_value_us); | 223 | GNUNET_TIME_absolute_min(now, last).abs_value_us); |
224 | 224 | ||
225 | /*check GNUNET_TIME_absolute_max */ | 225 | /*check GNUNET_TIME_absolute_max */ |
226 | GNUNET_assert (now.abs_value_us == | 226 | GNUNET_assert(now.abs_value_us == |
227 | GNUNET_TIME_absolute_max (now, last).abs_value_us); | 227 | GNUNET_TIME_absolute_max(now, last).abs_value_us); |
228 | for (unsigned int i=0;i<30;i++) | 228 | for (unsigned int i = 0; i < 30; i++) |
229 | { | 229 | { |
230 | struct GNUNET_CONFIGURATION_Handle *cfg; | 230 | struct GNUNET_CONFIGURATION_Handle *cfg; |
231 | 231 | ||
232 | cfg = GNUNET_CONFIGURATION_create (); | 232 | cfg = GNUNET_CONFIGURATION_create(); |
233 | last = GNUNET_TIME_absolute_get_monotonic (cfg); | 233 | last = GNUNET_TIME_absolute_get_monotonic(cfg); |
234 | now = GNUNET_TIME_absolute_get_monotonic (cfg); | 234 | now = GNUNET_TIME_absolute_get_monotonic(cfg); |
235 | GNUNET_assert (now.abs_value_us > last.abs_value_us); | 235 | GNUNET_assert(now.abs_value_us > last.abs_value_us); |
236 | (void) GNUNET_TIME_absolute_get_monotonic (NULL); | 236 | (void)GNUNET_TIME_absolute_get_monotonic(NULL); |
237 | GNUNET_CONFIGURATION_set_value_string (cfg, | 237 | GNUNET_CONFIGURATION_set_value_string(cfg, |
238 | "util", | 238 | "util", |
239 | "MONOTONIC_TIME_FILENAME", | 239 | "MONOTONIC_TIME_FILENAME", |
240 | "monotonic-time.dat"); | 240 | "monotonic-time.dat"); |
241 | last = GNUNET_TIME_absolute_get_monotonic (cfg); | 241 | last = GNUNET_TIME_absolute_get_monotonic(cfg); |
242 | now = GNUNET_TIME_absolute_get_monotonic (cfg); | 242 | now = GNUNET_TIME_absolute_get_monotonic(cfg); |
243 | (void) GNUNET_TIME_absolute_get_monotonic (NULL); | 243 | (void)GNUNET_TIME_absolute_get_monotonic(NULL); |
244 | GNUNET_assert (now.abs_value_us > last.abs_value_us); | 244 | GNUNET_assert(now.abs_value_us > last.abs_value_us); |
245 | GNUNET_CONFIGURATION_destroy (cfg); | 245 | GNUNET_CONFIGURATION_destroy(cfg); |
246 | } | 246 | } |
247 | GNUNET_break (GNUNET_OK == | 247 | GNUNET_break(GNUNET_OK == |
248 | GNUNET_DISK_directory_remove ("monotonic-time.dat")); | 248 | GNUNET_DISK_directory_remove("monotonic-time.dat")); |
249 | 249 | ||
250 | return 0; | 250 | return 0; |
251 | } | 251 | } |
252 | 252 | ||