summaryrefslogtreecommitdiffstats
path: root/runtime/oat_file_test.cc
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2015-03-18 08:21:11 -0700
committerRichard Uhler <ruhler@google.com>2015-03-24 12:48:09 -0700
commite5fed03772144595c0904faf3d6974cc55214c8c (patch)
tree27c242e48cabd2543f472930d1ad7e2ab86557fe /runtime/oat_file_test.cc
parentb93581f857e36a62f690e26e78167f2abea0f033 (diff)
downloadandroid_art-e5fed03772144595c0904faf3d6974cc55214c8c.tar.gz
android_art-e5fed03772144595c0904faf3d6974cc55214c8c.tar.bz2
android_art-e5fed03772144595c0904faf3d6974cc55214c8c.zip
Support relative encoded dex locations in oat files.
Now when opening an oat file, the caller can pass an absolute dex location used to resolve the absolute path for any relative encoded dex locations in the oat file. Bug: 19550105 Change-Id: I6e9559afe4d86ac12cf0b90176b5ea696a83d0e7
Diffstat (limited to 'runtime/oat_file_test.cc')
-rw-r--r--runtime/oat_file_test.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/runtime/oat_file_test.cc b/runtime/oat_file_test.cc
new file mode 100644
index 0000000000..f2213e9879
--- /dev/null
+++ b/runtime/oat_file_test.cc
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 "oat_file.h"
+
+#include <string>
+
+#include <gtest/gtest.h>
+
+namespace art {
+
+TEST(OatFileTest, ResolveRelativeEncodedDexLocation) {
+ EXPECT_EQ(std::string("/data/app/foo/base.apk"),
+ OatFile::ResolveRelativeEncodedDexLocation(
+ nullptr, "/data/app/foo/base.apk"));
+
+ EXPECT_EQ(std::string("/system/framework/base.apk"),
+ OatFile::ResolveRelativeEncodedDexLocation(
+ "/data/app/foo/base.apk", "/system/framework/base.apk"));
+
+ EXPECT_EQ(std::string("/data/app/foo/base.apk"),
+ OatFile::ResolveRelativeEncodedDexLocation(
+ "/data/app/foo/base.apk", "base.apk"));
+
+ EXPECT_EQ(std::string("/data/app/foo/base.apk"),
+ OatFile::ResolveRelativeEncodedDexLocation(
+ "/data/app/foo/base.apk", "foo/base.apk"));
+
+ EXPECT_EQ(std::string("/data/app/foo/base.apk:classes2.dex"),
+ OatFile::ResolveRelativeEncodedDexLocation(
+ "/data/app/foo/base.apk", "base.apk:classes2.dex"));
+
+ EXPECT_EQ(std::string("/data/app/foo/base.apk:classes11.dex"),
+ OatFile::ResolveRelativeEncodedDexLocation(
+ "/data/app/foo/base.apk", "base.apk:classes11.dex"));
+
+ EXPECT_EQ(std::string("base.apk"),
+ OatFile::ResolveRelativeEncodedDexLocation(
+ "/data/app/foo/sludge.apk", "base.apk"));
+
+ EXPECT_EQ(std::string("o/base.apk"),
+ OatFile::ResolveRelativeEncodedDexLocation(
+ "/data/app/foo/base.apk", "o/base.apk"));
+}
+
+} // namespace art