core/harness: don't use local static variable in instance method
authorU. Artie Eoff <ullysses.a.eoff@intel.com>
Tue, 18 Jun 2013 22:48:08 +0000 (15:48 -0700)
committerU. Artie Eoff <ullysses.a.eoff@intel.com>
Tue, 18 Jun 2013 23:13:17 +0000 (16:13 -0700)
The use of a local static variable in a non-static class method is
only instantiated once and used by all instances of that object.

In core::test::Harness::client() we were statically creating the
result (client) with the current instances' display_ member.  Hence,
if a second core::test::Harness instance was created using a
different display_, the client() return value for the second instance
would be that of the first instance (i.e. it uses the first instances'
display_).  This is not what we'd expect/want as an API consumer.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
src/test/core/harness.cpp
src/test/core/harness.h

index 00cef12..ced8859 100644 (file)
@@ -29,6 +29,7 @@ namespace core {
 Harness::Harness()
        : test::Harness::Harness()
        , display_()
+       , client_(display_)
 {
        return;
 }
@@ -57,8 +58,7 @@ void Harness::yield(const unsigned time) const
 
 const test::Client& Harness::client() const
 {
-       static const test::Client c(display_);
-       return c;
+       return client_;
 }
 
 class SimpleTest : public Harness
index f800fc1..0152c67 100644 (file)
@@ -48,6 +48,7 @@ private:
        void runStep(TestStep step) const;
 
        Display display_;
+       Client client_;
 };
 
 #define WFITS_CORE_HARNESS_TEST_CASE(HarnessClass) \