OSDN Git Service

Fix compiler driver gtest.
authorCalin Juravle <calin@google.com>
Fri, 5 Feb 2016 19:44:05 +0000 (19:44 +0000)
committerNicolas Geoffray <ngeoffray@google.com>
Fri, 12 Feb 2016 12:32:29 +0000 (12:32 +0000)
(cherry picked from commit 35c4e0b2ad573e820d6e9d461a571af300611d36)

Change-Id: Ia59f4463a6158f7a949debd7a93f35fa633cd36a

compiler/driver/compiler_driver_test.cc
runtime/jit/offline_profiling_info.cc
runtime/jit/offline_profiling_info.h

index 4c03e5d..4785885 100644 (file)
@@ -249,9 +249,9 @@ class CompilerDriverProfileTest : public CompilerDriverTest {
 
     ProfileCompilationInfo info;
     for (const std::unique_ptr<const DexFile>& 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_;
   }
index d0d3e70..0aff1f7 100644 (file)
@@ -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);
   }
 }
 
index ffd1433..c388c4a 100644 (file)
@@ -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);