@@ -159,7 +159,12 @@ class FileSystemTest : public ::testing::Test, public ::testing::WithParamInterf
159159 std::string GetTestDir () const {
160160 std::string file_system = GetParam ();
161161 if (file_system == " local" ) {
162- return paimon::test::GetDataDir ();
162+ std::string data_dir = paimon::test::GetDataDir ();
163+ if (data_dir.empty () || data_dir[0 ] != ' /' ) {
164+ EXPECT_OK_AND_ASSIGN (std::string current_path, PathUtil::GetWorkingDirectory ());
165+ data_dir = PathUtil::JoinPath (current_path, data_dir);
166+ }
167+ return data_dir;
163168 } else if (file_system == " jindo" ) {
164169 return " oss://paimon-unittest/test_data/" ;
165170 }
@@ -209,6 +214,28 @@ TEST_P(FileSystemTest, TestCreate) {
209214 ASSERT_NOK_WITH_MSG (fs_->Create (path, /* overwrite=*/ false ), " already exists" );
210215}
211216
217+ TEST_P (FileSystemTest, TestCreateRelativeFileInCurrentDirectory) {
218+ if (GetParam () != " local" ) {
219+ GTEST_SKIP () << " this test is only tested for the local file system" ;
220+ }
221+
222+ std::string path = " relative_file_" + RandomName ();
223+ ASSERT_OK_AND_ASSIGN (auto out, fs_->Create (path, /* overwrite=*/ true ));
224+ std::string content = " content" ;
225+ ASSERT_OK_AND_ASSIGN (int32_t write_len, out->Write (content.data (), content.size ()));
226+ ASSERT_EQ (write_len, content.size ());
227+ ASSERT_OK_AND_ASSIGN (std::string uri, out->GetUri ());
228+ ASSERT_FALSE (uri.empty ());
229+ ASSERT_EQ (uri[0 ], ' /' );
230+ ASSERT_EQ (PathUtil::GetName (uri), path);
231+ ASSERT_OK (out->Close ());
232+
233+ std::string read_content;
234+ ASSERT_OK (fs_->ReadFile (path, &read_content));
235+ ASSERT_EQ (read_content, content);
236+ ASSERT_OK (fs_->Delete (path));
237+ }
238+
212239// --- write&read
213240TEST_P (FileSystemTest, TestSimpleWriteAndRead) {
214241 std::string content = " abcdefghijk" ;
@@ -648,6 +675,27 @@ TEST_P(FileSystemTest, TestRename) {
648675 " src file is not a dir" );
649676}
650677
678+ TEST_P (FileSystemTest, TestRenameWithFileSchemeUsesNormalizedPath) {
679+ if (GetParam () != " local" ) {
680+ GTEST_SKIP () << " this test is only tested for the local file system" ;
681+ }
682+
683+ const std::string src = " file:" + test_root_ + " /scheme_src.txt" ;
684+ const std::string dst = " file:" + test_root_ + " /scheme_dst.txt" ;
685+
686+ ASSERT_OK (fs_->WriteFile (src, " content" , /* overwrite=*/ false ));
687+ ASSERT_OK (fs_->Rename (src, dst));
688+
689+ ASSERT_OK_AND_ASSIGN (bool src_exists, fs_->Exists (src));
690+ ASSERT_FALSE (src_exists);
691+ ASSERT_OK_AND_ASSIGN (bool dst_exists, fs_->Exists (dst));
692+ ASSERT_TRUE (dst_exists);
693+
694+ std::string content;
695+ ASSERT_OK (fs_->ReadFile (dst, &content));
696+ ASSERT_EQ (content, " content" );
697+ }
698+
651699TEST_P (FileSystemTest, TestRename2) {
652700 {
653701 // test rename dir
@@ -781,6 +829,19 @@ TEST_P(FileSystemTest, TestExists) {
781829 ASSERT_TRUE (is_exist);
782830}
783831
832+ TEST_P (FileSystemTest, TestExistsInLocalFileSystem) {
833+ if (GetParam () != " local" ) {
834+ GTEST_SKIP () << " this test is only tested for the local file system" ;
835+ }
836+
837+ ASSERT_OK_AND_ASSIGN (bool is_exist, fs_->Exists (" /" ));
838+ ASSERT_TRUE (is_exist);
839+ ASSERT_OK_AND_ASSIGN (is_exist, fs_->Exists (" " ));
840+ ASSERT_TRUE (is_exist);
841+ ASSERT_OK_AND_ASSIGN (is_exist, fs_->Exists (" ." ));
842+ ASSERT_TRUE (is_exist);
843+ }
844+
784845// --- delete
785846TEST_P (FileSystemTest, TestExistingFileDeletion) {
786847 auto check = [&](bool recursive) {
@@ -985,8 +1046,16 @@ TEST_P(FileSystemTest, TestMkdir) {
9851046 ASSERT_OK (fs_->Mkdirs (test_root_ + " /tmp/local/f/1" ));
9861047 ASSERT_OK (fs_->Mkdirs (test_root_ + " /tmp1" ));
9871048 ASSERT_OK (fs_->Mkdirs (test_root_ + " /tmp1/f2/" ));
1049+ }
1050+
1051+ TEST_P (FileSystemTest, TestMkdirInLocalFileSystem) {
1052+ if (GetParam () != " local" ) {
1053+ GTEST_SKIP () << " this test is only tested for the local file system" ;
1054+ }
1055+
9881056 ASSERT_OK (fs_->Mkdirs (" /" ));
989- ASSERT_NOK_WITH_MSG (fs_->Mkdirs (" " ), " path is an empty string." );
1057+ ASSERT_OK (fs_->Mkdirs (" " ));
1058+ ASSERT_OK (fs_->Mkdirs (" ." ));
9901059}
9911060
9921061TEST_P (FileSystemTest, TestMkdir2) {
@@ -1399,6 +1468,14 @@ TEST_P(FileSystemTest, TestAtomicStoreAlreadyExist) {
13991468 ASSERT_TRUE (is_exist);
14001469}
14011470
1402- INSTANTIATE_TEST_SUITE_P (UseLocal, FileSystemTest, ::testing::Values(" local" /* , "jindo"*/ ));
1471+ std::vector<std::string> GetTestValuesForFileSystemTest () {
1472+ std::vector<std::string> values;
1473+ values.emplace_back (" local" );
1474+ // values.emplace_back("jindo");
1475+ return values;
1476+ }
1477+
1478+ INSTANTIATE_TEST_SUITE_P (FsType, FileSystemTest,
1479+ ::testing::ValuesIn (GetTestValuesForFileSystemTest()));
14031480
14041481} // namespace paimon::test
0 commit comments