[SmokeTest] Skip tests for preload request 86/117286/6
authorDamian Pietruchowski <d.pietruchow@samsung.com>
Fri, 3 Mar 2017 13:40:57 +0000 (14:40 +0100)
committerDamian Pietruchowski <d.pietruchow@samsung.com>
Tue, 14 Mar 2017 08:26:52 +0000 (01:26 -0700)
Tests for preload request should be skipped
when request mode is not global and when tests
are called by user different than root.

Change-Id: I249c07794e713023fad6f21d1f621bcac3080621
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
src/unit_tests/smoke_test.cc

index 0fb52ff..25d87d8 100644 (file)
@@ -848,7 +848,8 @@ class SmokeTest : public testing::Test {
 
 class PreloadSmokeTest : public testing::Test {
   void SetUp() override {
-    ASSERT_TRUE(kRequestMode == ci::RequestMode::GLOBAL);
+    ASSERT_EQ(ci::RequestMode::GLOBAL, kRequestMode);
+    ASSERT_EQ(0, getuid()) << "Test cannot be run by normal user";
   }
 };
 
@@ -1386,8 +1387,7 @@ TEST_F(SmokeTest, MigrateLegacyExternalImageMode) {
   ValidateExternalPackage(pkgid, {appid});
 }
 
-TEST_F(PreloadSmokeTest, InstallationMode_Preload) {
-  ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+TEST_F(PreloadSmokeTest, InstallationMode_Preload) {;
   bf::path path = kSmokePackagesDirectory / "InstallationMode_Preload.wgt";
   std::string pkgid = "smokewgt37";
   std::string appid = "smokewgt37.InstallationModePreload";
@@ -1397,7 +1397,6 @@ TEST_F(PreloadSmokeTest, InstallationMode_Preload) {
 }
 
 TEST_F(PreloadSmokeTest, UpdateMode_Preload) {
-  ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
   bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Preload.wgt";
   bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Preload2.wgt";
   std::string pkgid = "smokewgt38";
@@ -1415,7 +1414,6 @@ TEST_F(PreloadSmokeTest, UpdateMode_Preload) {
 }
 
 TEST_F(PreloadSmokeTest, DeinstallationMode_Preload) {
-  ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
   bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Preload.wgt";
   std::string pkgid = "smokewgt39";
   std::string appid = "smokewgt39.DeinstallationModePreload";
@@ -1500,9 +1498,13 @@ TEST_F(SmokeTest, SharedRes30HybridDelta) {
 }  // namespace common_installer
 
 int main(int argc,  char** argv) {
+  ParseRequestMode(argc, argv);
+  if (getuid() != 0 || kRequestMode != ci::RequestMode::GLOBAL) {
+    std::cout << "Skip tests for preload request" << std::endl;
+    ::testing::GTEST_FLAG(filter) = "SmokeTest.*";
+  }
   testing::InitGoogleTest(&argc, argv);
   testing::Environment *env = testing::AddGlobalTestEnvironment(
       new common_installer::SmokeEnvironment());
-  ParseRequestMode(argc, argv);
   return RUN_ALL_TESTS();
 }