From 1ea745ca2e4482acc293c30ef8fea158732def59 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Tue, 13 Jun 2017 13:06:01 +0200 Subject: [PATCH] signal test: do not test multiple handlers The multiple-handlers test was checking if handlers at one signal were activated in a fair manner. But on Qemu, the error tolerance of one was too small in rare cases (2 of 100 runs). However, having multiple handlers for the same signal context can be considered deprecated anyway. With the recommended Signal_handler wrapper for signal sessions, you can't use this feature. Thus, we removed the multiple-handlers test. Fixes #2450 --- repos/os/src/test/signal/main.cc | 87 ++++---------------------------- 1 file changed, 11 insertions(+), 76 deletions(-) diff --git a/repos/os/src/test/signal/main.cc b/repos/os/src/test/signal/main.cc index 2285503185..acd09df63f 100644 --- a/repos/os/src/test/signal/main.cc +++ b/repos/os/src/test/signal/main.cc @@ -185,69 +185,6 @@ struct Fast_sender_test : Signal_test } }; -struct Multiple_handlers_test : Signal_test -{ - static constexpr char const *brief = - "get multiple handlers at one sender activated in a fair manner"; - - enum { HANDLER_INTERVAL_MS = 8 * SPEED, - SENDER_INTERVAL_MS = 1 * SPEED, - FINISH_IDLE_MS = 2 * HANDLER_INTERVAL_MS, - DURATION_MS = 50 * SPEED, - NR_OF_HANDLERS = 4 }; - - struct Unequal_sent_and_received_signals : Exception { }; - struct Unequal_activation_of_handlers : Exception { }; - - Env &env; - Heap heap { env.ram(), env.rm() }; - Timer::Connection timer { env }; - Signal_context context; - Signal_receiver receiver; - Registry > handlers; - Sender sender { env, receiver.manage(&context), - SENDER_INTERVAL_MS, true}; - - Multiple_handlers_test(Env &env, int id) : Signal_test(id, brief), env(env) - { - for (unsigned i = 0; i < NR_OF_HANDLERS; i++) - new (heap) Registered(handlers, env, receiver, - HANDLER_INTERVAL_MS, true, i); - timer.msleep(DURATION_MS); - - /* stop emitting signals */ - log("stop generating new signals"); - sender.idle(true); - timer.msleep(FINISH_IDLE_MS); - - /* let handlers settle down */ - handlers.for_each([&] (Handler &handler) { handler.idle(true); }); - timer.msleep(FINISH_IDLE_MS); - - /* print statistics and clean up */ - unsigned total_rcv = 0, max_act = 0, min_act = ~0;; - handlers.for_each([&] (Handler &handler) { - unsigned const rcv = handler.receive_cnt(); - unsigned const act = handler.activation_cnt(); - log(handler, " received ", rcv, " signals, was activated ", act, " times"); - total_rcv += rcv; - if (act > max_act) { max_act = act; } - if (act < min_act) { min_act = act; } - destroy(heap, &handler); - }); - log("sender submitted a total of ", sender.submit_cnt(), " signals"); - log("handlers received a total of ", total_rcv, " signals"); - - /* check if number of sent signals match the received ones */ - if (sender.submit_cnt() != total_rcv) { - throw Unequal_sent_and_received_signals(); } - - /* check if handlers had been activated equally (tolerance of one) */ - if (max_act - min_act > 1) { - throw Unequal_activation_of_handlers(); } - } -}; - struct Stress_test : Signal_test { static constexpr char const *brief = @@ -702,21 +639,20 @@ struct Nested_stress_test : Signal_test struct Main { Env &env; - Signal_handler
test_9_done { env.ep(), *this, &Main::handle_test_9_done }; + Signal_handler
test_8_done { env.ep(), *this, &Main::handle_test_8_done }; Constructible test_1; - Constructible test_2; - Constructible test_3; - Constructible test_4; - Constructible test_5; - Constructible test_6; - Constructible test_7; - Constructible test_8; - Constructible test_9; + Constructible test_2; + Constructible test_3; + Constructible test_4; + Constructible test_5; + Constructible test_6; + Constructible test_7; + Constructible test_8; - void handle_test_9_done() + void handle_test_8_done() { - test_9.destruct(); + test_8.destruct(); log("--- Signalling test finished ---"); } @@ -730,8 +666,7 @@ struct Main test_5.construct(env, 5); test_5.destruct(); test_6.construct(env, 6); test_6.destruct(); test_7.construct(env, 7); test_7.destruct(); - test_8.construct(env, 8); test_8.destruct(); - test_9.construct(env, 9, test_9_done); + test_8.construct(env, 8, test_8_done); } };