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 4c03e5d..4785885 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -249,9 +249,9 @@
 
     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_;
   }
diff --git a/runtime/jit/offline_profiling_info.cc b/runtime/jit/offline_profiling_info.cc
index d0d3e70..0aff1f7 100644
--- a/runtime/jit/offline_profiling_info.cc
+++ b/runtime/jit/offline_profiling_info.cc
@@ -37,13 +37,14 @@
 // 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 ffd1433..c388c4a 100644
--- a/runtime/jit/offline_profiling_info.h
+++ b/runtime/jit/offline_profiling_info.h
@@ -66,6 +66,8 @@
 
   // 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);