test: create isolated ev_loop for swim unit tests
The SWIM unit tests code with the fake events and time does lots of forbidden things: it manually invokes pending watcher callbacks; manages global time without a kernel; puts not existing descriptors into the loop. These foul blows open the gates to the full control over IO events, descriptors, virtual time. Hundreds of virtual seconds pass in milliseconds in reality, it makes SWIM unit tests fast despite complex logic. All these actions does not affect the loop until yield. On yield a scheduler fiber wakes up and 1) infinitely generates EV_READ on not existing descriptors because a kernel considers them closed; 2) manual pending callbacks invocation asserts, because it is not allowed for non-scheduler fibers. To avoid these problems a new isolated loop is created, not visible for the scheduler. Here the fake events library can rack and ruin whatever it wants. Needed for #4250
Showing
- src/lib/swim/swim.c 12 additions, 9 deletionssrc/lib/swim/swim.c
- src/lib/swim/swim_ev.c 6 additions, 0 deletionssrc/lib/swim/swim_ev.c
- src/lib/swim/swim_ev.h 18 additions, 0 deletionssrc/lib/swim/swim_ev.h
- src/lib/swim/swim_io.c 8 additions, 7 deletionssrc/lib/swim/swim_io.c
- test/unit/swim_test_ev.c 16 additions, 0 deletionstest/unit/swim_test_ev.c
- test/unit/swim_test_utils.c 1 addition, 1 deletiontest/unit/swim_test_utils.c
Please register or sign in to comment