From 8fd603cd500a08fd6e92ae035d8b462f909cdbfa Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Thu, 9 Dec 2021 10:18:11 -0800 Subject: [PATCH] Fix failed archive tests on linux and remove trait - Change the test Archive Folder name, Extract Folder Name, and File List file to be all lowercase to prevent the 'ResolvePath' function in LocalFileIO when executed to cause issues on case sensitive file systems (#6277) - Fix memory corruption in profile builds on Linux when using AZ::IO::PathView by using AZ::IO::FixedMaxPath instead Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- .../Platform/Linux/AzTest_Traits_Linux.h | 1 - .../Archive/ArchiveComponent.cpp | 8 ++--- .../AzToolsFramework/Tests/ArchiveTests.cpp | 30 ++----------------- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h b/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h index 5593d813a9..b3939f1ef2 100644 --- a/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h +++ b/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h @@ -14,7 +14,6 @@ #define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000 #define AZ_TRAIT_DISABLE_FAILED_ATOM_RPI_TESTS true -#define AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS true #define AZ_TRAIT_DISABLE_FAILED_FRAMEPROFILER_TEST true #define AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS true diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Archive/ArchiveComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Archive/ArchiveComponent.cpp index 3d0299667c..a7400c089d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Archive/ArchiveComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Archive/ArchiveComponent.cpp @@ -158,16 +158,16 @@ namespace AzToolsFramework bool success = true; AZStd::vector fileBuffer; - const AZ::IO::Path workingPath{ dirToArchive }; + const AZ::IO::FixedMaxPath workingPath{ dirToArchive }; for (const auto& fileName : foundFiles.GetValue()) { bool thisSuccess = false; - AZ::IO::PathView relativePath = AZ::IO::PathView{ fileName }.LexicallyRelative(workingPath); + AZ::IO::FixedMaxPath relativePath = AZ::IO::FixedMaxPath{ fileName }.LexicallyRelative(workingPath); + AZ::IO::FixedMaxPath fullPath = (workingPath / relativePath); - AZ::IO::Path fullPath = (workingPath / relativePath); - if (ArchiveUtils::ReadFile(fullPath, AZ::IO::OpenMode::ModeRead, fileBuffer)) + if (ArchiveUtils::ReadFile(static_cast(fullPath), AZ::IO::OpenMode::ModeRead, fileBuffer)) { int result = archive->UpdateFile( relativePath.Native(), fileBuffer.data(), fileBuffer.size(), s_compressionMethod, diff --git a/Code/Framework/AzToolsFramework/Tests/ArchiveTests.cpp b/Code/Framework/AzToolsFramework/Tests/ArchiveTests.cpp index 395e4c9049..2eb7b835ad 100644 --- a/Code/Framework/AzToolsFramework/Tests/ArchiveTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/ArchiveTests.cpp @@ -69,12 +69,12 @@ namespace UnitTest QString GetArchiveFolderName() { - return "Archive"; + return "archive"; } QString GetExtractFolderName() { - return "Extracted"; + return "extracted"; } void CreateArchiveFolder(QString archiveFolderName, QStringList fileList) @@ -90,7 +90,7 @@ namespace UnitTest QString CreateArchiveListTextFile() { - QString listFilePath = QDir(m_tempDir.GetDirectory()).absoluteFilePath("FileList.txt"); + QString listFilePath = QDir(m_tempDir.GetDirectory()).absoluteFilePath("filelist.txt"); QString textContent = CreateArchiveFileList().join("\n"); EXPECT_TRUE(CreateDummyFile(listFilePath, textContent)); return listFilePath; @@ -151,11 +151,7 @@ namespace UnitTest UnitTest::ScopedTemporaryDirectory m_tempDir; }; -#if AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS - TEST_F(ArchiveComponentTest, DISABLED_CreateArchive_FilesAtThreeDepths_ArchiveCreated) -#else TEST_F(ArchiveComponentTest, CreateArchive_FilesAtThreeDepths_ArchiveCreated) -#endif // AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS { EXPECT_TRUE(m_tempDir.IsValid()); CreateArchiveFolder(); @@ -167,11 +163,7 @@ namespace UnitTest EXPECT_TRUE(createResult); } -#if AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS - TEST_F(ArchiveComponentTest, DISABLED_ListFilesInArchive_FilesAtThreeDepths_FilesFound) -#else TEST_F(ArchiveComponentTest, ListFilesInArchive_FilesAtThreeDepths_FilesFound) -#endif // AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS { EXPECT_TRUE(m_tempDir.IsValid()); CreateArchiveFolder(); @@ -190,11 +182,7 @@ namespace UnitTest EXPECT_EQ(fileList.size(), 6); } -#if AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS - TEST_F(ArchiveComponentTest, DISABLED_CreateDeltaCatalog_AssetsNotRegistered_Failure) -#else TEST_F(ArchiveComponentTest, CreateDeltaCatalog_AssetsNotRegistered_Failure) -#endif // AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS { QStringList fileList = CreateArchiveFileList(); @@ -213,11 +201,7 @@ namespace UnitTest EXPECT_EQ(catalogCreated, false); } -#if AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS - TEST_F(ArchiveComponentTest, DISABLED_AddFilesToArchive_FromListFile_Success) -#else TEST_F(ArchiveComponentTest, AddFilesToArchive_FromListFile_Success) -#endif // AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS { QString listFile = CreateArchiveListTextFile(); CreateArchiveFolder(GetArchiveFolderName(), CreateArchiveFileList()); @@ -233,11 +217,7 @@ namespace UnitTest EXPECT_TRUE(result); } -#if AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS - TEST_F(ArchiveComponentTest, DISABLED_ExtractArchive_AllFiles_Success) -#else TEST_F(ArchiveComponentTest, ExtractArchive_AllFiles_Success) -#endif // AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS { CreateArchiveFolder(); AZ_TEST_START_TRACE_SUPPRESSION; @@ -264,11 +244,7 @@ namespace UnitTest } } -#if AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS - TEST_F(ArchiveComponentTest, DISABLED_CreateDeltaCatalog_ArchiveWithoutCatalogAssetsRegistered_Success) -#else TEST_F(ArchiveComponentTest, CreateDeltaCatalog_ArchiveWithoutCatalogAssetsRegistered_Success) -#endif // AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS { QStringList fileList = CreateArchiveFileList();