diff options
| author | Nicolas Geoffray <ngeoffray@google.com> | 2017-09-05 12:56:20 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2017-09-05 12:56:20 +0000 |
| commit | 0db570dfeae901b987a1fce561f4fbac7447a250 (patch) | |
| tree | c5760628292e74bacfd05523aa3667af46f9174b | |
| parent | 9ebc49e8c728d6631f1b0ca77b5be3fdc1339b26 (diff) | |
| parent | 06f0410aa924653126c95e49917bf635b1268a39 (diff) | |
Merge "Handle the case cwd has a trailing slash." am: c101222c85
am: 06f0410aa9
Change-Id: I7cdaa65172f98f5af8b39e4c1bd512af3cd72202
| -rw-r--r-- | runtime/class_loader_context_test.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/class_loader_context_test.cc b/runtime/class_loader_context_test.cc index 930160f2b4b..ddbb73b5b24 100644 --- a/runtime/class_loader_context_test.cc +++ b/runtime/class_loader_context_test.cc @@ -338,10 +338,13 @@ TEST_F(ClassLoaderContextTest, OpenValidDexFilesSymLink) { } static std::string CreateRelativeString(const std::string& in, const char* cwd) { - if (!android::base::StartsWith(in, cwd)) { + int cwd_len = strlen(cwd); + if (!android::base::StartsWith(in, cwd) || (cwd_len < 1)) { LOG(FATAL) << in << " " << cwd; } - return in.substr(strlen(cwd) + 1); + bool contains_trailing_slash = (cwd[cwd_len - 1] == '/'); + int start_position = cwd_len + (contains_trailing_slash ? 0 : 1); + return in.substr(start_position); } TEST_F(ClassLoaderContextTest, OpenValidDexFilesRelative) { |
