Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: fix linked list tests reusing
Registration
s (#1016)
## 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>
- Loading branch information