Skip to content
Snippets Groups Projects
  • Vladislav Shpilevoy's avatar
    675a4c21
    test: create isolated ev_loop for swim unit tests · 675a4c21
    Vladislav Shpilevoy authored
    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
    675a4c21
    History
    test: create isolated ev_loop for swim unit tests
    Vladislav Shpilevoy authored
    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