more normalized path fix

Test: manual
Change-Id: I8fe073cb4bc4fa1a3af784cfcfa8db4d0a232991
diff --git a/services/incremental/test/IncrementalServiceTest.cpp b/services/incremental/test/IncrementalServiceTest.cpp
index 2826818..9cdc83e 100644
--- a/services/incremental/test/IncrementalServiceTest.cpp
+++ b/services/incremental/test/IncrementalServiceTest.cpp
@@ -406,29 +406,16 @@
     int storageId =
             mIncrementalService->createStorage(tempDir.path, std::move(mDataLoaderParcel),
                                                IncrementalService::CreateOptions::CreateNew);
-    std::string_view dir_path("test");
-    EXPECT_CALL(*mIncFs, makeDir(_, dir_path, _));
-    auto res = mIncrementalService->makeDir(storageId, dir_path, 0555);
-    ASSERT_EQ(res, 0);
-}
+    std::string dir_path("test");
 
-TEST_F(IncrementalServiceTest, testMakeDirectoryNested) {
-    mVold->mountIncFsSuccess();
-    mIncFs->makeFileSuccess();
-    mVold->bindMountSuccess();
-    mIncrementalManager->prepareDataLoaderSuccess();
-    mIncrementalManager->startDataLoaderSuccess();
-    TemporaryDir tempDir;
-    int storageId =
-            mIncrementalService->createStorage(tempDir.path, std::move(mDataLoaderParcel),
-                                               IncrementalService::CreateOptions::CreateNew);
-    auto first = "first"sv;
-    auto second = "second"sv;
-    std::string dir_path = std::string(first) + "/" + std::string(second);
-    EXPECT_CALL(*mIncFs, makeDir(_, first, _)).Times(0);
-    EXPECT_CALL(*mIncFs, makeDir(_, second, _)).Times(0);
-    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(dir_path), _)).Times(1);
+    std::string tempPath(tempDir.path);
+    std::replace(tempPath.begin(), tempPath.end(), '/', '_');
+    std::string mount_dir = std::string(mRootDir.path) + "/" + tempPath.substr(1);
+    std::string normalized_dir_path = mount_dir + "/mount/st_1_0/" + dir_path;
 
+    // Expecting incfs to call makeDir on a path like:
+    // /data/local/tmp/TemporaryDir-06yixG/data_local_tmp_TemporaryDir-xwdFhT/mount/st_1_0/test
+    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(normalized_dir_path), _));
     auto res = mIncrementalService->makeDir(storageId, dir_path, 0555);
     ASSERT_EQ(res, 0);
 }
@@ -446,15 +433,29 @@
     auto first = "first"sv;
     auto second = "second"sv;
     auto third = "third"sv;
+
+    std::string tempPath(tempDir.path);
+    std::replace(tempPath.begin(), tempPath.end(), '/', '_');
+    std::string mount_dir = std::string(mRootDir.path) + "/" + tempPath.substr(1);
+
     InSequence seq;
     auto parent_path = std::string(first) + "/" + std::string(second);
     auto dir_path = parent_path + "/" + std::string(third);
-    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(dir_path), _)).WillOnce(Return(-ENOENT));
-    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(parent_path), _)).WillOnce(Return(-ENOENT));
-    EXPECT_CALL(*mIncFs, makeDir(_, first, _)).WillOnce(Return(0));
-    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(parent_path), _)).WillOnce(Return(0));
-    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(dir_path), _)).WillOnce(Return(0));
-    auto res = mIncrementalService->makeDirs(storageId, dir_path, 0555);
+
+    std::string normalized_first_path = mount_dir + "/mount/st_1_0/" + std::string(first);
+    std::string normalized_parent_path = mount_dir + "/mount/st_1_0/" + parent_path;
+    std::string normalized_dir_path = mount_dir + "/mount/st_1_0/" + dir_path;
+
+    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(normalized_dir_path), _))
+            .WillOnce(Return(-ENOENT));
+    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(normalized_parent_path), _))
+            .WillOnce(Return(-ENOENT));
+    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(normalized_first_path), _))
+            .WillOnce(Return(0));
+    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(normalized_parent_path), _))
+            .WillOnce(Return(0));
+    EXPECT_CALL(*mIncFs, makeDir(_, std::string_view(normalized_dir_path), _)).WillOnce(Return(0));
+    auto res = mIncrementalService->makeDirs(storageId, normalized_dir_path, 0555);
     ASSERT_EQ(res, 0);
 }
 } // namespace android::os::incremental