Richard Uhler | e5fed03 | 2015-03-18 08:21:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "oat_file.h" |
| 18 | |
| 19 | #include <string> |
| 20 | |
| 21 | #include <gtest/gtest.h> |
| 22 | |
Andreas Gampe | 7848da4 | 2015-04-09 11:15:04 -0700 | [diff] [blame] | 23 | #include "common_runtime_test.h" |
Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 24 | #include "scoped_thread_state_change-inl.h" |
Andreas Gampe | 7848da4 | 2015-04-09 11:15:04 -0700 | [diff] [blame] | 25 | |
Richard Uhler | e5fed03 | 2015-03-18 08:21:11 -0700 | [diff] [blame] | 26 | namespace art { |
| 27 | |
Andreas Gampe | 7848da4 | 2015-04-09 11:15:04 -0700 | [diff] [blame] | 28 | class OatFileTest : public CommonRuntimeTest { |
| 29 | }; |
| 30 | |
| 31 | TEST_F(OatFileTest, ResolveRelativeEncodedDexLocation) { |
Richard Uhler | e5fed03 | 2015-03-18 08:21:11 -0700 | [diff] [blame] | 32 | EXPECT_EQ(std::string("/data/app/foo/base.apk"), |
| 33 | OatFile::ResolveRelativeEncodedDexLocation( |
| 34 | nullptr, "/data/app/foo/base.apk")); |
| 35 | |
| 36 | EXPECT_EQ(std::string("/system/framework/base.apk"), |
| 37 | OatFile::ResolveRelativeEncodedDexLocation( |
| 38 | "/data/app/foo/base.apk", "/system/framework/base.apk")); |
| 39 | |
| 40 | EXPECT_EQ(std::string("/data/app/foo/base.apk"), |
| 41 | OatFile::ResolveRelativeEncodedDexLocation( |
| 42 | "/data/app/foo/base.apk", "base.apk")); |
| 43 | |
| 44 | EXPECT_EQ(std::string("/data/app/foo/base.apk"), |
| 45 | OatFile::ResolveRelativeEncodedDexLocation( |
| 46 | "/data/app/foo/base.apk", "foo/base.apk")); |
| 47 | |
| 48 | EXPECT_EQ(std::string("/data/app/foo/base.apk:classes2.dex"), |
| 49 | OatFile::ResolveRelativeEncodedDexLocation( |
| 50 | "/data/app/foo/base.apk", "base.apk:classes2.dex")); |
| 51 | |
| 52 | EXPECT_EQ(std::string("/data/app/foo/base.apk:classes11.dex"), |
| 53 | OatFile::ResolveRelativeEncodedDexLocation( |
| 54 | "/data/app/foo/base.apk", "base.apk:classes11.dex")); |
| 55 | |
| 56 | EXPECT_EQ(std::string("base.apk"), |
| 57 | OatFile::ResolveRelativeEncodedDexLocation( |
| 58 | "/data/app/foo/sludge.apk", "base.apk")); |
| 59 | |
| 60 | EXPECT_EQ(std::string("o/base.apk"), |
| 61 | OatFile::ResolveRelativeEncodedDexLocation( |
| 62 | "/data/app/foo/base.apk", "o/base.apk")); |
| 63 | } |
| 64 | |
Richard Uhler | e5fed03 | 2015-03-18 08:21:11 -0700 | [diff] [blame] | 65 | } // namespace art |