From: Calin Juravle Date: Fri, 5 Feb 2016 19:44:05 +0000 (+0000) Subject: Fix compiler driver gtest. X-Git-Tag: android-x86-7.1-r1~408^2~7^2~38^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=31708b736a2d75a9eb21f51038a7703f84f95f31;p=android-x86%2Fart.git Fix compiler driver gtest. (cherry picked from commit 35c4e0b2ad573e820d6e9d461a571af300611d36) Change-Id: Ia59f4463a6158f7a949debd7a93f35fa633cd36a --- diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 4c03e5ddf..478588561 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -249,9 +249,9 @@ class CompilerDriverProfileTest : public CompilerDriverTest { ProfileCompilationInfo info; for (const std::unique_ptr& dex_file : dex_files) { - std::cout << std::string(dex_file->GetLocation()); - profile_info_.AddData(dex_file->GetLocation(), dex_file->GetLocationChecksum(), 1); - profile_info_.AddData(dex_file->GetLocation(), dex_file->GetLocationChecksum(), 2); + std::string key = ProfileCompilationInfo::GetProfileDexFileKey(dex_file->GetLocation()); + profile_info_.AddData(key, dex_file->GetLocationChecksum(), 1); + profile_info_.AddData(key, dex_file->GetLocationChecksum(), 2); } return &profile_info_; } diff --git a/runtime/jit/offline_profiling_info.cc b/runtime/jit/offline_profiling_info.cc index d0d3e705e..0aff1f7ec 100644 --- a/runtime/jit/offline_profiling_info.cc +++ b/runtime/jit/offline_profiling_info.cc @@ -37,13 +37,14 @@ namespace art { // Note: this is OK because we don't store profiles of different apps into the same file. // Apps with split apks don't cause trouble because each split has a different name and will not // collide with other entries. -static std::string GetProfileDexFileKey(const std::string& dex_location) { +std::string ProfileCompilationInfo::GetProfileDexFileKey(const std::string& dex_location) { DCHECK(!dex_location.empty()); size_t last_sep_index = dex_location.find_last_of('/'); if (last_sep_index == std::string::npos) { return dex_location; } else { - return dex_location.substr(last_sep_index); + DCHECK(last_sep_index < dex_location.size()); + return dex_location.substr(last_sep_index + 1); } } diff --git a/runtime/jit/offline_profiling_info.h b/runtime/jit/offline_profiling_info.h index ffd14335d..c388c4a42 100644 --- a/runtime/jit/offline_profiling_info.h +++ b/runtime/jit/offline_profiling_info.h @@ -66,6 +66,8 @@ class ProfileCompilationInfo { // For testing purposes. bool Equals(ProfileCompilationInfo& other); + // Exposed for testing purpose. + static std::string GetProfileDexFileKey(const std::string& dex_location); private: bool AddData(const std::string& dex_location, uint32_t checksum, uint16_t method_idx);