From 3e76b5568873b66fa2b4e3507c001a565565f113 Mon Sep 17 00:00:00 2001 From: Damian Pietruchowski Date: Mon, 20 Mar 2017 12:35:03 +0100 Subject: [PATCH] [SmokeTest] Fix rw filesystem validation Requires: https://review.tizen.org/gerrit/#/c/119323/ Change-Id: I623fb15084b8b25fdad9e923b53cf2f3badb6221 Signed-off-by: Damian Pietruchowski --- src/unit_tests/smoke_utils.cc | 36 ++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index b2cacbb..de965c1 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -63,6 +63,25 @@ const char kPreloadApps[] = "/usr/apps"; const char kPreloadManifestDir[] = "/usr/share/packages"; const char kPreloadIcons[] = "/usr/share/icons"; +namespace { + +enum RWDirectory { + DATA, + CACHE, + SHARED_CACHE, + SHARED_DATA, + SHARED_TRUSTED +}; + +const char* rwDirectories[] = { + "data", + "cache", + "shared/cache", + "shared/data", + "shared/trusted" +}; + +} bool TouchFile(const bf::path& path) { @@ -133,9 +152,9 @@ bool ValidateFileContentInPackage(const std::string& pkgid, void ValidatePackageRWFS(const std::string& pkgid, uid_t uid) { bf::path root_path = ci::GetRootAppPath(false, uid); bf::path package_path = root_path / pkgid; - bf::path data_path = package_path / "data"; - bf::path cache_path = package_path / "cache"; - bf::path shared_data_path = package_path / "shared" / "data"; + bf::path data_path = package_path / rwDirectories[DATA]; + bf::path cache_path = package_path / rwDirectories[CACHE]; + bf::path shared_data_path = package_path / rwDirectories[SHARED_DATA]; ASSERT_TRUE(bf::exists(data_path)); ASSERT_TRUE(bf::exists(cache_path)); @@ -181,9 +200,16 @@ void ValidatePackageFS(const std::string& pkgid, const std::string& appid, iter != bf::recursive_directory_iterator(); ++iter) { if (bf::is_symlink(symlink_status(iter->path()))) continue; - if (iter->path().filename() == "data" || - iter->path().filename() == ".mmc") + bool is_rw_dir = false; + for(const auto rw_dir : rwDirectories) { + bf::path rw_dir_path = rw_dir; + bf::path relative_path = ci::MakeRelativePath(iter->path(), package_path); + is_rw_dir |= (relative_path == rw_dir_path); + } + if (iter->path().filename() == ".mmc" || is_rw_dir) { + iter.no_push(); continue; + } struct stat stats; stat(iter->path().c_str(), &stats); ASSERT_EQ(uid, stats.st_uid); -- 2.34.1