Fix extensive smoke test 46/173546/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 22 Mar 2018 08:06:20 +0000 (17:06 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Thu, 22 Mar 2018 08:08:10 +0000 (17:08 +0900)
Cast global environment object just once when allocating.
Use static_cast for downcasting, because we know obviously that
SmokeEnvironment class is derived from testing::Environment class.

Change-Id: I89629f81453235f7dfc526a1e796bf7396cafe89
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/unit_tests/extensive_smoke_test.cc

index ed51023..5c88971 100644 (file)
@@ -50,26 +50,22 @@ class SmokeEnvironment : public testing::Environment {
 
 namespace {
 
-testing::Environment *env = nullptr;
+smoke_test::SmokeEnvironment *env = nullptr;
 void signalHandler(int signum) {
   env->TearDown();
   exit(signum);
 }
 
-smoke_test::SmokeEnvironment *dcast(testing::Environment* _env) {
-  return dynamic_cast<smoke_test::SmokeEnvironment *>(_env);
-}
-
 }  // namespace
 
 namespace smoke_test {
 
 class SmokeTest : public testing::Test {
  public:
-  SmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)),
+  SmokeTest() : backend(std::to_string(env->test_user.uid)),
       params{PackageType::WGT, false} {
-    params.test_user.uid = dcast(env)->test_user.uid;
-    params.test_user.gid = dcast(env)->test_user.gid;
+    params.test_user.uid = env->test_user.uid;
+    params.test_user.gid = env->test_user.gid;
   }
  protected:
   WgtBackendInterface backend;
@@ -78,10 +74,10 @@ class SmokeTest : public testing::Test {
 
 class HybridSmokeTest : public testing::Test {
  public:
-  HybridSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)),
+  HybridSmokeTest() : backend(std::to_string(env->test_user.uid)),
       params{PackageType::HYBRID, false} {
-    params.test_user.uid = dcast(env)->test_user.uid;
-    params.test_user.gid = dcast(env)->test_user.gid;
+    params.test_user.uid = env->test_user.uid;
+    params.test_user.gid = env->test_user.gid;
   }
  protected:
   HybridBackendInterface backend;
@@ -429,8 +425,9 @@ int main(int argc,  char** argv) {
     ::testing::GTEST_FLAG(filter) = "SmokeTest.*";
   }
   testing::InitGoogleTest(&argc, argv);
-  ::env = testing::AddGlobalTestEnvironment(
-      new smoke_test::SmokeEnvironment(request_mode));
+  ::env = static_cast<smoke_test::SmokeEnvironment*>(
+      testing::AddGlobalTestEnvironment(
+          new smoke_test::SmokeEnvironment(request_mode)));
   signal(SIGINT, ::signalHandler);
   signal(SIGSEGV, ::signalHandler);
   return RUN_ALL_TESTS();