Commit 4707e6f
authored
core: fix linked list tests reusing
## Motivation
Currently, the tests for the linked list implementation in
`tracing_core::callsite` declare two static `Registration`s in the test
module, which are used in multiple tests. Since these tests are all run
in one binary, in separate threads, these statics are shared across all
tests. This means that --- depending on the order in which tests are run
--- these `Registration`s may already have values for their `next`
pointers. In particular, there's a potential issue where the `for_each`
in the test `linked_list_push` can loop repeatedly, if one of the
`Registration`s already had a next pointer from a previous test. See:
#1008 (comment)
## Solution
This branch declares separate `Registration` statics for each test.
These are not shared between multiple test threads.
We still reuse the same callsite statics, since their state does not
change during the tests --- only the `Registration`s change. I also
refactored the test code a little bit to use only a single type
implementing `Callsite`, rather than two separate types, since the
callsite impl is not actually used and this makes the code somewhat more
concise.
Finally, I added a new test for pushing more than two callsites.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>Registrations (#1016)1 parent 5fb114f commit 4707e6f
1 file changed
+67
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
283 | 282 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
| 283 | + | |
296 | 284 | | |
297 | 285 | | |
298 | 286 | | |
| |||
301 | 289 | | |
302 | 290 | | |
303 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
304 | 295 | | |
305 | 296 | | |
306 | 297 | | |
| |||
325 | 316 | | |
326 | 317 | | |
327 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
328 | 377 | | |
329 | 378 | | |
330 | 379 | | |
| 380 | + | |
| 381 | + | |
331 | 382 | | |
332 | 383 | | |
333 | 384 | | |
| |||
0 commit comments