From 683e1dabe1435c588111fa35c9d6fd587258144d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 3 Jan 2009 13:32:24 +0100 Subject: [PATCH] cleanup, add further testcase (starting prerequisite subsystems) SubsystemRunner considered finished. --- src/common/subsystem-runner.hpp | 2 +- tests/40components.tests | 5 ++ tests/lib/subsystem-runner-test.cpp | 104 ++++++++++++++++++---------- 3 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/common/subsystem-runner.hpp b/src/common/subsystem-runner.hpp index 60fbd9e56..1e7deb32f 100644 --- a/src/common/subsystem-runner.hpp +++ b/src/common/subsystem-runner.hpp @@ -133,7 +133,7 @@ namespace lumiera { triggerEmergency (bool cond) { Lock guard (this); - emergency_ |= cond; + if (cond) emergency_= true; } bool diff --git a/tests/40components.tests b/tests/40components.tests index 2a1c8be8c..6ed448349 100644 --- a/tests/40components.tests +++ b/tests/40components.tests @@ -338,6 +338,11 @@ END TEST "Starting and stopping subsystems" SubsystemRunner_test < %s....", cStr(*this)); } bool @@ -146,36 +146,36 @@ namespace lumiera { void run (Subsys::SigTerm termination) ///< simulates a "running" subsystem { - cout << *this << ": start running...\n"; - Literal runSpec (extractID ("run",spec_)); ASSERT (!isnil (runSpec)); - if ("false"!=runSpec) //----actually hold running state for some time + if ("false"!=runSpec) //----actually enter running state for some time { didRun_ = true; running_duration_ = MIN_RUNNING_TIME_ms; running_duration_ += (rand() % (MAX_RUNNING_TIME_ms - MIN_RUNNING_TIME_ms)); + INFO (test, "thread %s now running....", cStr(*this)); + Lock wait_blocking (this, &MockSys::tick); } Error problemIndicator("simulated Problem killing a subsystem",LUMIERA_ERROR_TEST); lumiera_error(); // reset error state.... // Note: in real life this actually - // would be an catched exception! + // would be an catched exception! { Lock guard (this); isUp_ = false; - cout << *this << ": terminates.\n"; + INFO (test, "thread %s terminates.", cStr(*this)); termination ("true"==runSpec? 0 : &problemIndicator); } } bool - tick () ///< simulates async termination, either on request or by timing + tick () ///< simulates async termination, either on request or by timing { Lock sync(this); if (!sync.isTimedWait()) @@ -200,7 +200,7 @@ namespace lumiera { running_duration_(0) { } - ~MockSys() { cout << *this << " dead.\n"; } + ~MockSys() { } operator string () const { return "MockSys(\""+id_+"\")"; } @@ -209,8 +209,8 @@ namespace lumiera { bool didRun () const { return didRun_; } }; - - + + } // (End) test classes and data.... @@ -227,6 +227,8 @@ namespace lumiera { * @test managing start and stop of several dependent "subsystems" * under various conditions. Using mock-subsystems, which actually * spawn a thread and finish by themselves and generally behave sane. + * For each such MockSys, we can define a behaviour pattern, e.g. + * weather the start succeeds and if the run terminates with error. * * @see lumiera::Subsys * @see lumiera::SubsystemRunner @@ -237,13 +239,14 @@ namespace lumiera { { virtual void - run (Arg) + run (Arg) { singleSubsys_complete_cycle(); singleSubsys_start_failure(); singleSubsys_emegency_exit(); dependentSubsys_complete_cycle(); + dependentSubsys_start_failure(); } @@ -330,18 +333,6 @@ namespace lumiera { } - void zoing(string zoz) - { - cout << "zoing! "<