MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

common/test/run-htable.c:152–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152int main(int argc, char *argv[])
153{
154 struct example *arr[3500];
155 struct example_htable *htable;
156 size_t i;
157
158 common_setup(argv[0]);
159
160 seed = *siphash_seed();
161 if (argc > 1)
162 seed.u.u64[0] = atoll(argv[1]);
163 if (argc > 2)
164 seed.u.u64[1] = atoll(argv[2]);
165
166 printf("Seed = %"PRIu64"/%"PRIu64"\n",
167 seed.u.u64[0], seed.u.u64[1]);
168
169
170 /* Randomly add or delete, check itegrity */
171 i = 0;
172 while (i < 10000) {
173 htable = tal(tmpctx, struct example_htable);
174 example_htable_init(htable);
175 memset(arr, 0, sizeof(arr));
176 check_htable(htable, arr, ARRAY_SIZE(arr));
177
178 while (example_htable_count(htable) < 900) {
179 size_t rand = siphash24(&seed, &i, sizeof(i)) % ARRAY_SIZE(arr);
180 if (arr[rand]) {
181 example_htable_del(htable, arr[rand]);
182 arr[rand] = NULL;
183 } else {
184 arr[rand] = new_example(htable, rand);
185 example_htable_add(htable, arr[rand]);
186 }
187 check_htable(htable, arr, ARRAY_SIZE(arr));
188 i++;
189 }
190 printf("%zu - %zu\n", i, example_htable_count(htable));
191 htable_check(&htable->raw, "check");
192 }
193 common_shutdown();
194 return 0;
195}

Callers

nothing calls this directly

Calls 7

common_setupFunction · 0.85
check_htableFunction · 0.85
siphash24Function · 0.85
new_exampleFunction · 0.85
htable_checkFunction · 0.85
common_shutdownFunction · 0.85
siphash_seedClass · 0.70

Tested by

no test coverage detected