diff --git a/BUILD.gn b/BUILD.gn index 9d466b8435a301664773ad277aa758128cd033c5..ef2a625f6db94a15136c9bd0d28bbd14e450d802 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -828,7 +828,6 @@ ecma_source = [ "ecmascript/compiler/aot_file/elf_checker.cpp", "ecmascript/compiler/aot_file/an_file_data_manager.cpp", "ecmascript/compiler/aot_file/an_file_info.cpp", - "ecmascript/compiler/aot_file/aot_checksum_helper.cpp", "ecmascript/compiler/aot_file/aot_file_info.cpp", "ecmascript/compiler/aot_file/stub_file_info.cpp", "ecmascript/compiler/aot_file/gdb_jit.cpp", diff --git a/ecmascript/compiler/aot_file/an_file_info.cpp b/ecmascript/compiler/aot_file/an_file_info.cpp index 7ab7498f119eacac55e6319d02299594e177ed98..a7b86d8fa9031dbd1c63787f13f0466b13024bea 100644 --- a/ecmascript/compiler/aot_file/an_file_info.cpp +++ b/ecmascript/compiler/aot_file/an_file_info.cpp @@ -15,10 +15,11 @@ #include "ecmascript/compiler/aot_file/an_file_info.h" -#include "ecmascript/compiler/aot_file/aot_checksum_helper.h" +#include "ecmascript/base/dtoa_helper.h" #include "ecmascript/compiler/aot_file/elf_builder.h" #include "ecmascript/compiler/aot_file/elf_reader.h" -#include "ecmascript/log_wrapper.h" +#include "macros.h" +#include namespace panda::ecmascript { bool AnFileInfo::Save(const std::string &filename, Triple triple, size_t anFileMaxByteSize, @@ -89,7 +90,7 @@ bool AnFileInfo::LoadInternal(const std::string &filename) return false; } if (!ParseChecksumInfo(des)) { - LOG_ECMA(ERROR) << "Parse checksum info failed, stop load aot"; + LOG_ECMA(ERROR) << "update fileName to checksum map failed"; return false; } ParseFunctionEntrySection(des); @@ -175,11 +176,30 @@ bool AnFileInfo::ParseChecksumInfo(ModuleSectionDes &des) uint32_t secSize = des.GetSecSize(ElfSecName::ARK_CHECKSUMINFO); const char *data = reinterpret_cast(secAddr); std::unordered_map checksumInfoMap; - if (!AOTChecksumHelper::DeserializeChecksumMapFromChar(data, secSize, checksumInfoMap)) { - LOG_COMPILER(ERROR) << "Deserialize checksum info from .an file failed!"; + const char *end = data + secSize; + + if (secSize == 0 || *(end - 1) != '\0') { + LOG_COMPILER(ERROR) << "Invalid checksum section: missing null terminator or invalid checksum section"; return false; } + while (data < end) { + std::string currentString(data); + size_t colonPos = currentString.find(':'); + if (colonPos == std::string::npos || colonPos == currentString.length() - 1) { + LOG_COMPILER(ERROR) << "Invalid fileName to checksum info " << currentString; + return false; + } + std::string fileName = currentString.substr(0, colonPos); + uint32_t checksum; + if (!base::StringHelper::StrToUInt32(currentString.substr(colonPos + 1).c_str(), &checksum)) { + LOG_COMPILER(ERROR) << "Invalid checksum " << currentString << " parse failed"; + return false; + } + checksumInfoMap.emplace(fileName.c_str(), checksum); + // 1 for '\0' + data += currentString.size() + 1; + } AnFileDataManager::GetInstance()->UnsafeMergeChecksumInfo(checksumInfoMap); return true; } @@ -261,13 +281,47 @@ void AnFileInfo::AddFuncEntrySec() void AnFileInfo::AddFileNameToChecksumSec(const std::unordered_map &fileNameToChecksumMap) { - AOTChecksumHelper::SerializeChecksumMapToVector(fileNameToChecksumMap, checksumDataVector_); + // save fileName to checksum relationship as like + // pandafileNormalizeDes:checksum + // /xxx/yyy/zzz.abc:123456 + uint32_t secSize = 0; + for (const auto &pair : fileNameToChecksumMap) { + // 2 for ':' and '\0' + secSize += pair.first.size() + FastUint32ToDigits(pair.second) + 2; + } + checksumData_.resize(secSize); + char *basePtr = checksumData_.data(); + + char *writePtr = basePtr; + for (const auto &pair : fileNameToChecksumMap) { + int written = sprintf_s(writePtr, secSize - (writePtr - basePtr), "%s:%u", pair.first.c_str(), pair.second); + if (written < 0) { + LOG_COMPILER(FATAL) << "sprintf_s failed"; + UNREACHABLE(); + } + // 1 for '\0' + writePtr += written + 1; + } ModuleSectionDes &des = des_[ElfBuilder::FuncEntryModuleDesIndex]; - uint64_t checksumInfoAddr = reinterpret_cast(checksumDataVector_.data()); - uint32_t checksumInfoSize = checksumDataVector_.size(); + uint64_t checksumInfoAddr = reinterpret_cast(basePtr); + uint32_t checksumInfoSize = secSize; des.SetSecAddrAndSize(ElfSecName::ARK_CHECKSUMINFO, checksumInfoAddr, checksumInfoSize); } +uint32_t AnFileInfo::FastUint32ToDigits(uint32_t number) +{ + return (number >= base::DtoaHelper::TEN9POW) ? 10 // 10 digits + : (number >= base::DtoaHelper::TEN8POW) ? 9 // 9 digits + : (number >= base::DtoaHelper::TEN7POW) ? 8 // 8 digits + : (number >= base::DtoaHelper::TEN6POW) ? 7 // 7 digits + : (number >= base::DtoaHelper::TEN5POW) ? 6 // 6 digits + : (number >= base::DtoaHelper::TEN4POW) ? 5 // 5 digits + : (number >= base::DtoaHelper::TEN3POW) ? 4 // 4 digits + : (number >= base::DtoaHelper::TEN2POW) ? 3 // 3 digits + : (number >= base::DtoaHelper::TEN) ? 2 // 2 digits + : 1; // 1 digit +} + void AnFileInfo::GenerateMethodToEntryIndexMap() { const std::vector &entries = GetStubs(); diff --git a/ecmascript/compiler/aot_file/an_file_info.h b/ecmascript/compiler/aot_file/an_file_info.h index f2d26184b6fd595174fc42adbf0be9fd475d156d..97e526a3ea2f6fb452dde96bb0cc145cdb6ab808 100644 --- a/ecmascript/compiler/aot_file/an_file_info.h +++ b/ecmascript/compiler/aot_file/an_file_info.h @@ -110,6 +110,7 @@ private: void UpdateFuncEntries(); void AddFuncEntrySec(); void AddFileNameToChecksumSec(const std::unordered_map &fileNameToChecksumMap); + uint32_t FastUint32ToDigits(uint32_t number); uint64_t curTextSecOffset_ {0}; // Future work: add main entry mapping to ai file std::map mainEntryMap_ {}; diff --git a/ecmascript/compiler/aot_file/aot_checksum_helper.cpp b/ecmascript/compiler/aot_file/aot_checksum_helper.cpp deleted file mode 100644 index 4f28c63d3fb815015a945c770ee87f5def265d42..0000000000000000000000000000000000000000 --- a/ecmascript/compiler/aot_file/aot_checksum_helper.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "ecmascript/base/dtoa_helper.h" -#include "ecmascript/base/string_helper.h" -#include "ecmascript/compiler/aot_file/aot_checksum_helper.h" -#include "ecmascript/log_wrapper.h" -#include "libpandabase/macros.h" - -namespace panda::ecmascript { - -bool AOTChecksumHelper::SerializeChecksumMapToVector(const std::unordered_map &fileNameToChecksumMap, - std::vector &checksumDataVector) -{ - // save fileName to checksum relationship as like - // pandafileNormalizeDes:checksum - // /xxx/yyy/zzz.abc:123456 - if (fileNameToChecksumMap.empty()) { - LOG_COMPILER(ERROR) << "abc file checksum map cant't be empty!"; - return false; - } - uint32_t checksumVectorSize = CalculateChecksumVectorSize(fileNameToChecksumMap); - checksumDataVector.resize(checksumVectorSize); - if (!WriteChecksumInfoToVector(fileNameToChecksumMap, checksumDataVector)) { - checksumDataVector.resize(0); - LOG_COMPILER(ERROR) << "Serialize checksumMap to .an failed!"; - return false; - } - return true; -} - -uint32_t AOTChecksumHelper::CalculateChecksumVectorSize( - const std::unordered_map &fileNameToChecksumMap) -{ - uint32_t size = 0; - for (const auto &pair : fileNameToChecksumMap) { - // 2 for ':' and '\0' - size += pair.first.size() + FastUint32ToDigits(pair.second) + 2; - } - return size; -} - -uint32_t AOTChecksumHelper::FastUint32ToDigits(uint32_t number) -{ - return (number >= base::DtoaHelper::TEN9POW) ? 10 // 10 digits - : (number >= base::DtoaHelper::TEN8POW) ? 9 // 9 digits - : (number >= base::DtoaHelper::TEN7POW) ? 8 // 8 digits - : (number >= base::DtoaHelper::TEN6POW) ? 7 // 7 digits - : (number >= base::DtoaHelper::TEN5POW) ? 6 // 6 digits - : (number >= base::DtoaHelper::TEN4POW) ? 5 // 5 digits - : (number >= base::DtoaHelper::TEN3POW) ? 4 // 4 digits - : (number >= base::DtoaHelper::TEN2POW) ? 3 // 3 digits - : (number >= base::DtoaHelper::TEN) ? 2 // 2 digits - : 1; // 1 digit -} - -bool AOTChecksumHelper::WriteChecksumInfoToVector(const std::unordered_map &fileNameToChecksumMap, - std::vector &checksumDataVector) -{ - char *basePtr = checksumDataVector.data(); - char *endPtr = basePtr + checksumDataVector.size(); - char *writePtr = basePtr; - for (const auto &pair : fileNameToChecksumMap) { - size_t remainSize = endPtr - writePtr; - int written = snprintf_s(writePtr, remainSize, remainSize - 1, "%s:%u", pair.first.c_str(), pair.second); - if (written < 0 || static_cast(written) >= remainSize) { - LOG_COMPILER(ERROR) << "wirte checksum info to AOT .an file failed!"; - return false; - } - // 1 for '\0' - writePtr += written + 1; - } - if (writePtr != endPtr) { - LOG_COMPILER(ERROR) << "Checksum vector not fully filled: " - << "expected size=" << checksumDataVector.size() - << ", actual used=" << (writePtr - basePtr); - return false; - } - return true; -} - -bool AOTChecksumHelper::DeserializeChecksumMapFromChar(const char *checksumData, uint32_t checksumDataSize, - std::unordered_map &fileNameToChecksumMap) -{ - if (checksumData == nullptr || checksumDataSize == 0) { - LOG_COMPILER(ERROR) << "Invalid checksum data"; - return false; - } - - const char *curPtr = checksumData; - const char *endPtr = checksumData + checksumDataSize; - - while (curPtr < endPtr) { - const char *entryEnd = static_cast(memchr(curPtr, '\0', endPtr - curPtr)); - if (entryEnd == nullptr || entryEnd >= endPtr) { - LOG_COMPILER(ERROR) << "Corrupted checksum data: missing string terminator"; - return false; - } - - const char *separator = static_cast(memchr(curPtr, ':', entryEnd - curPtr)); - if (separator == nullptr || separator >= entryEnd) { - LOG_COMPILER(ERROR) << "Corrupted checksum data: missing separator"; - return false; - } - - if (separator == curPtr || separator + 1 == entryEnd) { - LOG_COMPILER(ERROR) << "Invalid entry format: empty filename or checksum"; - return false; - } - - CString filename(curPtr, separator - curPtr); - - uint32_t checksum; - if (!base::StringHelper::StrToUInt32(separator + 1, &checksum)) { - LOG_COMPILER(ERROR) << "Invalid checksum value"; - return false; - } - - fileNameToChecksumMap.emplace(std::move(filename), checksum); - - curPtr = entryEnd + 1; - } - - if (fileNameToChecksumMap.empty()) { - LOG_COMPILER(ERROR) << "No valid entries found in checksum data"; - return false; - } - return true; -} - -} // namespace panda::ecmascript diff --git a/ecmascript/compiler/aot_file/aot_checksum_helper.h b/ecmascript/compiler/aot_file/aot_checksum_helper.h deleted file mode 100644 index 4b66aee5aee6dcd1cc4b451f1622924a5c6ec22e..0000000000000000000000000000000000000000 --- a/ecmascript/compiler/aot_file/aot_checksum_helper.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_COMPILER_AOT_FILE_AOT_CHECKSUM_HELPER_H -#define ECMASCRIPT_COMPILER_AOT_FILE_AOT_CHECKSUM_HELPER_H -#include -#include "ecmascript/mem/c_string.h" -namespace panda::ecmascript { -class AOTChecksumHelper { -public: - AOTChecksumHelper() = delete; - ~AOTChecksumHelper() = delete; - static bool SerializeChecksumMapToVector(const std::unordered_map &fileNameToChecksumMap, - std::vector &checksumDataVector); - static bool DeserializeChecksumMapFromChar(const char *checksumData, uint32_t checksumDataSize, - std::unordered_map &fileNameToChecksumMap); - static uint32_t CalculateChecksumVectorSize(const std::unordered_map &fileNameToChecksumMap); - static bool WriteChecksumInfoToVector(const std::unordered_map &fileNameToChecksumMap, - std::vector &checksumDataVector); - static uint32_t FastUint32ToDigits(uint32_t number); -}; -} // namespace panda::ecmascript -#endif // ECMASCRIPT_COMPILER_AOT_FILE_AOT_CHECKSUM_HELPER_H \ No newline at end of file diff --git a/ecmascript/compiler/aot_file/aot_file_info.h b/ecmascript/compiler/aot_file/aot_file_info.h index e42fbc87b5cbcf82b94d76f1401180dcdd1106f4..b1880a221242ebe1ddced0e18fa6a2cc5afe539c 100644 --- a/ecmascript/compiler/aot_file/aot_file_info.h +++ b/ecmascript/compiler/aot_file/aot_file_info.h @@ -148,7 +148,7 @@ protected: uint32_t totalCodeSize_ {0}; std::vector entries_ {}; std::vector des_ {}; - std::vector checksumDataVector_ {}; + std::vector checksumData_ {}; ExecutedMemoryAllocator::ExeMem stubsMem_ {}; MemMap fileMapMem_ {}; diff --git a/ecmascript/compiler/aot_file/tests/BUILD.gn b/ecmascript/compiler/aot_file/tests/BUILD.gn index 26c07a3f8a18bc1e2ca70d8416fa417f0b140843..b40603c486e0a49b54b04835fa4f38f16ed09ab4 100644 --- a/ecmascript/compiler/aot_file/tests/BUILD.gn +++ b/ecmascript/compiler/aot_file/tests/BUILD.gn @@ -76,31 +76,6 @@ host_unittest_action("AOTFileTest") { deps += hiviewdfx_deps } -host_unittest_action("AOTChecksumTest") { - module_out_path = module_output_path - - sources = [ "aot_checksum_test.cpp" ] - - configs = [ - "../../../../:asm_interp_enable_config", - "../../../../:ecma_test_config", - ] - - deps = [ - "../../:libark_jsoptimizer_set", - "../../../../:libark_jsruntime_test", - ] - - external_deps = [ - "icu:shared_icui18n", - "icu:shared_icuuc", - "runtime_core:libarkassembler_static", - ] - - external_deps += hiviewdfx_ext_deps - deps += hiviewdfx_deps -} - host_unittest_action("BinaryBufferParserTest") { module_out_path = module_output_path @@ -155,7 +130,6 @@ group("unittest") { testonly = true deps = [] deps += [ - ":AOTChecksumTest", ":AOTFileTest", ":BinaryBufferParserTest", ":AnFileInfoTest", @@ -169,16 +143,10 @@ group("unittest") { group("host_unittest") { testonly = true - deps = [ - ":AOTChecksumTestAction", - ":AOTFileTestAction", - ] + deps = [ ":AOTFileTestAction" ] if (is_mac) { - deps -= [ - ":AOTChecksumTestAction", - ":AOTFileTestAction", - ] + deps -= [ ":AOTFileTestAction" ] } else if (ets_runtime_enable_cmc_gc) { # CMC-GC UT FIX LATER deps -= [ ":AOTFileTestAction" ] diff --git a/ecmascript/compiler/aot_file/tests/aot_checksum_test.cpp b/ecmascript/compiler/aot_file/tests/aot_checksum_test.cpp deleted file mode 100644 index 4a674c885da3958bb5175ce1c1d47af1e48f4088..0000000000000000000000000000000000000000 --- a/ecmascript/compiler/aot_file/tests/aot_checksum_test.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "gtest/gtest.h" - -#include "ecmascript/compiler/aot_file/aot_checksum_helper.h" -#include "ecmascript/tests/test_helper.h" - -using namespace panda::ecmascript; -using namespace panda::ecmascript::base; -namespace panda::test { -class AOTChecksumTest : public testing::Test { -public: - static void SetUpTestCase() - { - GTEST_LOG_(INFO) << "SetUpTestCase"; - } - - static void TearDownTestCase() - { - GTEST_LOG_(INFO) << "TearDownTestCase"; - } - - void SetUp() override {} - - void TearDown() override {} -}; - -HWTEST_F_L0(AOTChecksumTest, ChecksumSerializeTest) -{ - std::unordered_map testMap; - testMap.emplace("test1.abc", 12345); - testMap.emplace("test2.abc", 67890); - - std::vector dataVector; - AOTChecksumHelper::SerializeChecksumMapToVector(testMap, dataVector); - - ASSERT_FALSE(dataVector.empty()); - ASSERT_EQ(dataVector.back(), '\0'); - - uint32_t expectedSize = AOTChecksumHelper::CalculateChecksumVectorSize(testMap); - ASSERT_EQ(dataVector.size(), expectedSize); - - std::unordered_map resultMap; - AOTChecksumHelper::DeserializeChecksumMapFromChar(dataVector.data(), dataVector.size(), resultMap); - - ASSERT_EQ(resultMap.size(), testMap.size()); - for (const auto &pair : testMap) { - auto it = resultMap.find(pair.first); - ASSERT_TRUE(it != resultMap.end()); - ASSERT_EQ(it->second, pair.second); - } -}; - -HWTEST_F_L0(AOTChecksumTest, EmptyMapTestTest) -{ - std::unordered_map emptyMap; - std::vector dataVector; - ASSERT_FALSE(AOTChecksumHelper::SerializeChecksumMapToVector(emptyMap, dataVector)); -}; - -HWTEST_F_L0(AOTChecksumTest, MaxChecksumTest) -{ - std::unordered_map testMap; - testMap.emplace("test.abc", std::numeric_limits::max()); - - std::vector dataVector; - AOTChecksumHelper::SerializeChecksumMapToVector(testMap, dataVector); - - ASSERT_FALSE(dataVector.empty()); - - std::unordered_map resultMap; - AOTChecksumHelper::DeserializeChecksumMapFromChar(dataVector.data(), dataVector.size(), resultMap); - - auto it = resultMap.find("test.abc"); - ASSERT_TRUE(it != resultMap.end()); - ASSERT_EQ(it->second, std::numeric_limits::max()); -}; - -HWTEST_F_L0(AOTChecksumTest, MuiltiSeparator) -{ - // This case is designed to ensure that in future versions, if a filename contains colons, we should only match the - // first colon. If some situations that abc contains colons, for security, disable abc load an for aovid different - // abc checksum - std::unordered_map testMap; - testMap.emplace("path:to:file.abc", 12345); - testMap.emplace("another:path:test.abc", 67890); - - std::vector dataVector; - AOTChecksumHelper::SerializeChecksumMapToVector(testMap, dataVector); - - std::unordered_map resultMap; - ASSERT_FALSE(AOTChecksumHelper::DeserializeChecksumMapFromChar(dataVector.data(), dataVector.size(), resultMap)); -}; - -HWTEST_F_L0(AOTChecksumTest, NullPtrProvidedTest) -{ - std::unordered_map resultMap; - ASSERT_FALSE(AOTChecksumHelper::DeserializeChecksumMapFromChar(nullptr, 10, resultMap)); -}; - -HWTEST_F_L0(AOTChecksumTest, ZeroSizeProvidedTest) -{ - std::unordered_map resultMap; - ASSERT_FALSE(AOTChecksumHelper::DeserializeChecksumMapFromChar("test", 0, resultMap)); -}; - -HWTEST_F_L0(AOTChecksumTest, NoSeparatorTest) -{ - std::vector invalidData = {'t', 'e', 's', 't', 'g', 'o', 'o', 'd', ':', '1', '2', '3', - '\0', 't', 'e', 's', 't', 'b', 'a', 'd', '4', '5', '6', '\0'}; - std::unordered_map resultMap; - ASSERT_FALSE(AOTChecksumHelper::DeserializeChecksumMapFromChar(invalidData.data(), invalidData.size(), resultMap)); -}; - -HWTEST_F_L0(AOTChecksumTest, NoBigEnoughBufferTest) -{ - std::unordered_map testMap; - testMap.emplace("test1.abc", 12345); - testMap.emplace("test2.abc", 67890); - - uint32_t realSize = AOTChecksumHelper::CalculateChecksumVectorSize(testMap); - - std::vector smallVector(realSize - 1); - - ASSERT_FALSE(AOTChecksumHelper::WriteChecksumInfoToVector(testMap, smallVector)); -}; - -HWTEST_F_L0(AOTChecksumTest, NoFileNameTest) -{ - std::vector invalidData = {'t', 'e', 's', 't', 'g', 'o', 'o', 'd', ':', '1', - '2', '3', '\0', ':', '1', '2', '3', '4', '5', '\0'}; - - std::unordered_map resultMap; - ASSERT_FALSE(AOTChecksumHelper::DeserializeChecksumMapFromChar(invalidData.data(), invalidData.size(), resultMap)); -}; - -HWTEST_F_L0(AOTChecksumTest, NoChecksumTest) -{ - std::vector invalidData = {'t', 'e', 's', 't', 'g', 'o', 'o', 'd', ':', - '1', '2', '3', '\0', 'b', 'a', 'd', ':', '\0'}; - - std::unordered_map resultMap; - ASSERT_FALSE(AOTChecksumHelper::DeserializeChecksumMapFromChar(invalidData.data(), invalidData.size(), resultMap)); -}; - -HWTEST_F_L0(AOTChecksumTest, InvalidChecksumTest) -{ - std::vector invalidData = {'t', 'e', 's', 't', 'g', 'o', 'o', 'd', ':', '1', '2', - '3', '\0', 'b', 'a', 'd', ':', 'a', 'b', 'c', '\0'}; - - std::unordered_map resultMap; - ASSERT_FALSE(AOTChecksumHelper::DeserializeChecksumMapFromChar(invalidData.data(), invalidData.size(), resultMap)); -}; - -HWTEST_F_L0(AOTChecksumTest, NotFullFillChecksumVecTest) -{ - std::unordered_map testMap; - testMap.emplace("test1.abc", 12345); - testMap.emplace("test2.abc", 67890); - - uint32_t correctSize = AOTChecksumHelper::CalculateChecksumVectorSize(testMap); - std::vector tooLargeVector(correctSize + 10); - - ASSERT_FALSE(AOTChecksumHelper::WriteChecksumInfoToVector(testMap, tooLargeVector)); -}; - -} // namespace panda::test diff --git a/ecmascript/compiler/aot_file/tests/aot_file_test.cpp b/ecmascript/compiler/aot_file/tests/aot_file_test.cpp index 2f5c0c4c2e3d01b6d926a3393e3cf33afec2d135..2e90f1d6430ced5d048c63072c75c5d3fe9fdb6d 100644 --- a/ecmascript/compiler/aot_file/tests/aot_file_test.cpp +++ b/ecmascript/compiler/aot_file/tests/aot_file_test.cpp @@ -13,19 +13,20 @@ * limitations under the License. */ -#include "gtest/gtest.h" - #include "ecmascript/compiler/aot_compilation_env.h" -#include "ecmascript/compiler/aot_compiler_preprocessor.h" #include "ecmascript/compiler/aot_compiler_stats.h" -#include "ecmascript/compiler/aot_file/an_file_data_manager.h" #include "ecmascript/compiler/aot_file/tests/aot_file_generator_mock.h" -#include "ecmascript/compiler/pass_manager.h" +#include "gtest/gtest.h" +#include "ecmascript/tests/test_helper.h" +#include "ecmascript/platform/filesystem.h" +#include "ecmascript/compiler/aot_file/an_file_data_manager.h" +#include "ecmascript/ohos/ohos_pkg_args.h" #include "ecmascript/compiler/pass_options.h" +#include "ecmascript/compiler/pass_manager.h" +#include "ecmascript/compiler/aot_compiler_preprocessor.h" +#include "ecmascript/compiler/aot_compilation_env.h" +#include "ecmascript/ohos/ohos_pkg_verifier.h" #include "ecmascript/js_runtime_options.h" -#include "ecmascript/ohos/ohos_pkg_args.h" -#include "ecmascript/platform/filesystem.h" -#include "ecmascript/tests/test_helper.h" using namespace panda; using namespace panda::ecmascript; @@ -427,7 +428,7 @@ protected: HWTEST_F_L0(AOTFileTest, fileSizeEqualExpectedTest) { - // This case use to test the compiler out .an file size equal to expected size by calculate. + // This case use to test the compiler out .an file size equal to expected size by calcutelate. // Test file use file_size_test.abc std::string testFile = "file_size_test.abc"; SetEnvrionmentForTest(testFile); @@ -449,7 +450,7 @@ HWTEST_F_L0(AOTFileTest, dontSaveAnFile) GetAnFileInTest(testApPath_, testAotPath_, testAbcPath_, 1); ASSERT_FALSE(Exists(testAnPath_)); ASSERT_FALSE(Exists(testAiPath_)); - // We can still calculate the correct size + // We can still calcutelate the correct size ASSERT_NE(testAnExpectedSize_, 0); }