Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | */ |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 16 | |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 17 | #include "dex_file.h" |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 18 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 19 | #include <memory> |
| 20 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 21 | #include "base/stl_util.h" |
| 22 | #include "base/unix_file/fd_file.h" |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 23 | #include "common_runtime_test.h" |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 24 | #include "dex_file-inl.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 25 | #include "os.h" |
| 26 | #include "scoped_thread_state_change.h" |
| 27 | #include "thread-inl.h" |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 28 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 29 | namespace art { |
| 30 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 31 | class DexFileTest : public CommonRuntimeTest {}; |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 32 | |
| 33 | TEST_F(DexFileTest, Open) { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 34 | ScopedObjectAccess soa(Thread::Current()); |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 35 | std::unique_ptr<const DexFile> dex(OpenTestDexFile("Nested")); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 36 | ASSERT_TRUE(dex.get() != nullptr); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 37 | } |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 38 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 39 | static const uint8_t kBase64Map[256] = { |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 40 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 41 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 42 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 43 | 255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63, |
| 44 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, |
| 45 | 255, 254, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, |
| 46 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, // NOLINT |
| 47 | 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, // NOLINT |
| 48 | 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 49 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, // NOLINT |
| 50 | 49, 50, 51, 255, 255, 255, 255, 255, 255, 255, 255, 255, // NOLINT |
| 51 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 52 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 53 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 54 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 55 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 56 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 57 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 58 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 59 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 60 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 61 | 255, 255, 255, 255 |
| 62 | }; |
| 63 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 64 | static inline uint8_t* DecodeBase64(const char* src, size_t* dst_size) { |
| 65 | std::vector<uint8_t> tmp; |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 66 | uint32_t t = 0, y = 0; |
| 67 | int g = 3; |
| 68 | for (size_t i = 0; src[i] != '\0'; ++i) { |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 69 | uint8_t c = kBase64Map[src[i] & 0xFF]; |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 70 | if (c == 255) continue; |
| 71 | // the final = symbols are read and used to trim the remaining bytes |
| 72 | if (c == 254) { |
| 73 | c = 0; |
| 74 | // prevent g < 0 which would potentially allow an overflow later |
| 75 | if (--g < 0) { |
| 76 | *dst_size = 0; |
| 77 | return nullptr; |
| 78 | } |
| 79 | } else if (g != 3) { |
| 80 | // we only allow = to be at the end |
| 81 | *dst_size = 0; |
| 82 | return nullptr; |
| 83 | } |
| 84 | t = (t << 6) | c; |
| 85 | if (++y == 4) { |
| 86 | tmp.push_back((t >> 16) & 255); |
| 87 | if (g > 1) { |
| 88 | tmp.push_back((t >> 8) & 255); |
| 89 | } |
| 90 | if (g > 2) { |
| 91 | tmp.push_back(t & 255); |
| 92 | } |
| 93 | y = t = 0; |
| 94 | } |
| 95 | } |
| 96 | if (y != 0) { |
| 97 | *dst_size = 0; |
| 98 | return nullptr; |
| 99 | } |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 100 | std::unique_ptr<uint8_t[]> dst(new uint8_t[tmp.size()]); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 101 | if (dst_size != nullptr) { |
| 102 | *dst_size = tmp.size(); |
| 103 | } else { |
| 104 | *dst_size = 0; |
| 105 | } |
| 106 | std::copy(tmp.begin(), tmp.end(), dst.get()); |
| 107 | return dst.release(); |
| 108 | } |
| 109 | |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 110 | // Although this is the same content logically as the Nested test dex, |
| 111 | // the DexFileHeader test is sensitive to subtle changes in the |
| 112 | // contents due to the checksum etc, so we embed the exact input here. |
| 113 | // |
| 114 | // class Nested { |
| 115 | // class Inner { |
| 116 | // } |
| 117 | // } |
| 118 | static const char kRawDex[] = |
| 119 | "ZGV4CjAzNQAQedgAe7gM1B/WHsWJ6L7lGAISGC7yjD2IAwAAcAAAAHhWNBIAAAAAAAAAAMQCAAAP" |
| 120 | "AAAAcAAAAAcAAACsAAAAAgAAAMgAAAABAAAA4AAAAAMAAADoAAAAAgAAAAABAABIAgAAQAEAAK4B" |
| 121 | "AAC2AQAAvQEAAM0BAADXAQAA+wEAABsCAAA+AgAAUgIAAF8CAABiAgAAZgIAAHMCAAB5AgAAgQIA" |
| 122 | "AAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAkAAAAJAAAABgAAAAAAAAAKAAAABgAAAKgBAAAAAAEA" |
| 123 | "DQAAAAAAAQAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAIAAAAiAEAAKsCAAAA" |
| 124 | "AAAAAQAAAAAAAAAFAAAAAAAAAAgAAACYAQAAuAIAAAAAAAACAAAAlAIAAJoCAAABAAAAowIAAAIA" |
| 125 | "AgABAAAAiAIAAAYAAABbAQAAcBACAAAADgABAAEAAQAAAI4CAAAEAAAAcBACAAAADgBAAQAAAAAA" |
| 126 | "AAAAAAAAAAAATAEAAAAAAAAAAAAAAAAAAAEAAAABAAY8aW5pdD4ABUlubmVyAA5MTmVzdGVkJElu" |
| 127 | "bmVyOwAITE5lc3RlZDsAIkxkYWx2aWsvYW5ub3RhdGlvbi9FbmNsb3NpbmdDbGFzczsAHkxkYWx2" |
| 128 | "aWsvYW5ub3RhdGlvbi9Jbm5lckNsYXNzOwAhTGRhbHZpay9hbm5vdGF0aW9uL01lbWJlckNsYXNz" |
| 129 | "ZXM7ABJMamF2YS9sYW5nL09iamVjdDsAC05lc3RlZC5qYXZhAAFWAAJWTAALYWNjZXNzRmxhZ3MA" |
| 130 | "BG5hbWUABnRoaXMkMAAFdmFsdWUAAgEABw4AAQAHDjwAAgIBDhgBAgMCCwQADBcBAgQBDhwBGAAA" |
| 131 | "AQEAAJAgAICABNQCAAABAAGAgATwAgAAEAAAAAAAAAABAAAAAAAAAAEAAAAPAAAAcAAAAAIAAAAH" |
| 132 | "AAAArAAAAAMAAAACAAAAyAAAAAQAAAABAAAA4AAAAAUAAAADAAAA6AAAAAYAAAACAAAAAAEAAAMQ" |
| 133 | "AAACAAAAQAEAAAEgAAACAAAAVAEAAAYgAAACAAAAiAEAAAEQAAABAAAAqAEAAAIgAAAPAAAArgEA" |
| 134 | "AAMgAAACAAAAiAIAAAQgAAADAAAAlAIAAAAgAAACAAAAqwIAAAAQAAABAAAAxAIAAA=="; |
| 135 | |
Narayan Kamath | 52e6650 | 2016-08-01 14:20:31 +0100 | [diff] [blame] | 136 | // kRawDex38 and 39 are dex'ed versions of the following Java source : |
| 137 | // |
| 138 | // public class Main { |
| 139 | // public static void main(String[] foo) { |
| 140 | // } |
| 141 | // } |
| 142 | // |
| 143 | // The dex file was manually edited to change its dex version code to 38 |
| 144 | // or 39, respectively. |
| 145 | static const char kRawDex38[] = |
| 146 | "ZGV4CjAzOAC4OovJlJ1089ikzK6asMf/f8qp3Kve5VsgAgAAcAAAAHhWNBIAAAAAAAAAAIwBAAAI" |
| 147 | "AAAAcAAAAAQAAACQAAAAAgAAAKAAAAAAAAAAAAAAAAMAAAC4AAAAAQAAANAAAAAwAQAA8AAAACIB" |
| 148 | "AAAqAQAAMgEAAEYBAABRAQAAVAEAAFgBAABtAQAAAQAAAAIAAAAEAAAABgAAAAQAAAACAAAAAAAA" |
| 149 | "AAUAAAACAAAAHAEAAAAAAAAAAAAAAAABAAcAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAADAAAA" |
| 150 | "AAAAAH4BAAAAAAAAAQABAAEAAABzAQAABAAAAHAQAgAAAA4AAQABAAAAAAB4AQAAAQAAAA4AAAAB" |
| 151 | "AAAAAwAGPGluaXQ+AAZMTWFpbjsAEkxqYXZhL2xhbmcvT2JqZWN0OwAJTWFpbi5qYXZhAAFWAAJW" |
| 152 | "TAATW0xqYXZhL2xhbmcvU3RyaW5nOwAEbWFpbgABAAcOAAMBAAcOAAAAAgAAgYAE8AEBCYgCDAAA" |
| 153 | "AAAAAAABAAAAAAAAAAEAAAAIAAAAcAAAAAIAAAAEAAAAkAAAAAMAAAACAAAAoAAAAAUAAAADAAAA" |
| 154 | "uAAAAAYAAAABAAAA0AAAAAEgAAACAAAA8AAAAAEQAAABAAAAHAEAAAIgAAAIAAAAIgEAAAMgAAAC" |
| 155 | "AAAAcwEAAAAgAAABAAAAfgEAAAAQAAABAAAAjAEAAA=="; |
| 156 | |
| 157 | static const char kRawDex39[] = |
| 158 | "ZGV4CjAzOQC4OovJlJ1089ikzK6asMf/f8qp3Kve5VsgAgAAcAAAAHhWNBIAAAAAAAAAAIwBAAAI" |
| 159 | "AAAAcAAAAAQAAACQAAAAAgAAAKAAAAAAAAAAAAAAAAMAAAC4AAAAAQAAANAAAAAwAQAA8AAAACIB" |
| 160 | "AAAqAQAAMgEAAEYBAABRAQAAVAEAAFgBAABtAQAAAQAAAAIAAAAEAAAABgAAAAQAAAACAAAAAAAA" |
| 161 | "AAUAAAACAAAAHAEAAAAAAAAAAAAAAAABAAcAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAADAAAA" |
| 162 | "AAAAAH4BAAAAAAAAAQABAAEAAABzAQAABAAAAHAQAgAAAA4AAQABAAAAAAB4AQAAAQAAAA4AAAAB" |
| 163 | "AAAAAwAGPGluaXQ+AAZMTWFpbjsAEkxqYXZhL2xhbmcvT2JqZWN0OwAJTWFpbi5qYXZhAAFWAAJW" |
| 164 | "TAATW0xqYXZhL2xhbmcvU3RyaW5nOwAEbWFpbgABAAcOAAMBAAcOAAAAAgAAgYAE8AEBCYgCDAAA" |
| 165 | "AAAAAAABAAAAAAAAAAEAAAAIAAAAcAAAAAIAAAAEAAAAkAAAAAMAAAACAAAAoAAAAAUAAAADAAAA" |
| 166 | "uAAAAAYAAAABAAAA0AAAAAEgAAACAAAA8AAAAAEQAAABAAAAHAEAAAIgAAAIAAAAIgEAAAMgAAAC" |
| 167 | "AAAAcwEAAAAgAAABAAAAfgEAAAAQAAABAAAAjAEAAA=="; |
| 168 | |
ganxiaolin | cd16d0a | 2016-07-18 11:21:44 +0800 | [diff] [blame] | 169 | static const char kRawDexZeroLength[] = |
| 170 | "UEsDBAoAAAAAAOhxAkkAAAAAAAAAAAAAAAALABwAY2xhc3Nlcy5kZXhVVAkAA2QNoVdnDaFXdXgL" |
| 171 | "AAEE5AMBAASIEwAAUEsBAh4DCgAAAAAA6HECSQAAAAAAAAAAAAAAAAsAGAAAAAAAAAAAAKCBAAAA" |
| 172 | "AGNsYXNzZXMuZGV4VVQFAANkDaFXdXgLAAEE5AMBAASIEwAAUEsFBgAAAAABAAEAUQAAAEUAAAAA" |
| 173 | "AA=="; |
| 174 | |
Narayan Kamath | 52e6650 | 2016-08-01 14:20:31 +0100 | [diff] [blame] | 175 | static void DecodeAndWriteDexFile(const char* base64, const char* location) { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 176 | // decode base64 |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 177 | CHECK(base64 != nullptr); |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 178 | size_t length; |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 179 | std::unique_ptr<uint8_t[]> dex_bytes(DecodeBase64(base64, &length)); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 180 | CHECK(dex_bytes.get() != nullptr); |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 181 | |
| 182 | // write to provided file |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 183 | std::unique_ptr<File> file(OS::CreateEmptyFile(location)); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 184 | CHECK(file.get() != nullptr); |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 185 | if (!file->WriteFully(dex_bytes.get(), length)) { |
| 186 | PLOG(FATAL) << "Failed to write base64 as dex file"; |
| 187 | } |
Andreas Gampe | 4303ba9 | 2014-11-06 01:00:46 -0800 | [diff] [blame] | 188 | if (file->FlushCloseOrErase() != 0) { |
| 189 | PLOG(FATAL) << "Could not flush and close test file."; |
| 190 | } |
Narayan Kamath | 52e6650 | 2016-08-01 14:20:31 +0100 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static std::unique_ptr<const DexFile> OpenDexFileBase64(const char* base64, |
| 194 | const char* location) { |
| 195 | DecodeAndWriteDexFile(base64, location); |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 196 | |
| 197 | // read dex file |
| 198 | ScopedObjectAccess soa(Thread::Current()); |
Aart Bik | 37d6a3b | 2016-06-21 18:30:10 -0700 | [diff] [blame] | 199 | static constexpr bool kVerifyChecksum = true; |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 200 | std::string error_msg; |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 201 | std::vector<std::unique_ptr<const DexFile>> tmp; |
Aart Bik | 37d6a3b | 2016-06-21 18:30:10 -0700 | [diff] [blame] | 202 | bool success = DexFile::Open(location, location, kVerifyChecksum, &error_msg, &tmp); |
Andreas Gampe | 833a485 | 2014-05-21 18:46:59 -0700 | [diff] [blame] | 203 | CHECK(success) << error_msg; |
| 204 | EXPECT_EQ(1U, tmp.size()); |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 205 | std::unique_ptr<const DexFile> dex_file = std::move(tmp[0]); |
Brian Carlstrom | e0948e1 | 2013-08-29 09:36:15 -0700 | [diff] [blame] | 206 | EXPECT_EQ(PROT_READ, dex_file->GetPermissions()); |
| 207 | EXPECT_TRUE(dex_file->IsReadOnly()); |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 208 | return dex_file; |
| 209 | } |
| 210 | |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 211 | TEST_F(DexFileTest, Header) { |
Brian Carlstrom | 33f741e | 2011-10-03 11:24:05 -0700 | [diff] [blame] | 212 | ScratchFile tmp; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 213 | std::unique_ptr<const DexFile> raw(OpenDexFileBase64(kRawDex, tmp.GetFilename().c_str())); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 214 | ASSERT_TRUE(raw.get() != nullptr); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 215 | |
Brian Carlstrom | f615a61 | 2011-07-23 12:50:34 -0700 | [diff] [blame] | 216 | const DexFile::Header& header = raw->GetHeader(); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 217 | // TODO: header.magic_ |
| 218 | EXPECT_EQ(0x00d87910U, header.checksum_); |
| 219 | // TODO: header.signature_ |
| 220 | EXPECT_EQ(904U, header.file_size_); |
| 221 | EXPECT_EQ(112U, header.header_size_); |
| 222 | EXPECT_EQ(0U, header.link_size_); |
| 223 | EXPECT_EQ(0U, header.link_off_); |
| 224 | EXPECT_EQ(15U, header.string_ids_size_); |
| 225 | EXPECT_EQ(112U, header.string_ids_off_); |
| 226 | EXPECT_EQ(7U, header.type_ids_size_); |
| 227 | EXPECT_EQ(172U, header.type_ids_off_); |
| 228 | EXPECT_EQ(2U, header.proto_ids_size_); |
| 229 | EXPECT_EQ(200U, header.proto_ids_off_); |
| 230 | EXPECT_EQ(1U, header.field_ids_size_); |
| 231 | EXPECT_EQ(224U, header.field_ids_off_); |
| 232 | EXPECT_EQ(3U, header.method_ids_size_); |
| 233 | EXPECT_EQ(232U, header.method_ids_off_); |
| 234 | EXPECT_EQ(2U, header.class_defs_size_); |
| 235 | EXPECT_EQ(256U, header.class_defs_off_); |
| 236 | EXPECT_EQ(584U, header.data_size_); |
| 237 | EXPECT_EQ(320U, header.data_off_); |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 238 | |
| 239 | EXPECT_EQ(header.checksum_, raw->GetLocationChecksum()); |
| 240 | } |
| 241 | |
Narayan Kamath | 52e6650 | 2016-08-01 14:20:31 +0100 | [diff] [blame] | 242 | TEST_F(DexFileTest, Version38Accepted) { |
| 243 | ScratchFile tmp; |
| 244 | std::unique_ptr<const DexFile> raw(OpenDexFileBase64(kRawDex38, tmp.GetFilename().c_str())); |
| 245 | ASSERT_TRUE(raw.get() != nullptr); |
| 246 | |
| 247 | const DexFile::Header& header = raw->GetHeader(); |
| 248 | EXPECT_EQ(38u, header.GetVersion()); |
| 249 | } |
| 250 | |
| 251 | TEST_F(DexFileTest, Version39Rejected) { |
| 252 | ScratchFile tmp; |
| 253 | const char* location = tmp.GetFilename().c_str(); |
| 254 | DecodeAndWriteDexFile(kRawDex39, location); |
| 255 | |
| 256 | ScopedObjectAccess soa(Thread::Current()); |
| 257 | static constexpr bool kVerifyChecksum = true; |
| 258 | std::string error_msg; |
| 259 | std::vector<std::unique_ptr<const DexFile>> dex_files; |
| 260 | ASSERT_FALSE(DexFile::Open(location, location, kVerifyChecksum, &error_msg, &dex_files)); |
| 261 | } |
| 262 | |
ganxiaolin | cd16d0a | 2016-07-18 11:21:44 +0800 | [diff] [blame] | 263 | TEST_F(DexFileTest, ZeroLengthDexRejected) { |
| 264 | ScratchFile tmp; |
| 265 | const char* location = tmp.GetFilename().c_str(); |
| 266 | DecodeAndWriteDexFile(kRawDexZeroLength, location); |
| 267 | |
| 268 | ScopedObjectAccess soa(Thread::Current()); |
| 269 | static constexpr bool kVerifyChecksum = true; |
| 270 | std::string error_msg; |
| 271 | std::vector<std::unique_ptr<const DexFile>> dex_files; |
| 272 | ASSERT_FALSE(DexFile::Open(location, location, kVerifyChecksum, &error_msg, &dex_files)); |
| 273 | } |
| 274 | |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 275 | TEST_F(DexFileTest, GetLocationChecksum) { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 276 | ScopedObjectAccess soa(Thread::Current()); |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 277 | std::unique_ptr<const DexFile> raw(OpenTestDexFile("Main")); |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 278 | EXPECT_NE(raw->GetHeader().checksum_, raw->GetLocationChecksum()); |
| 279 | } |
| 280 | |
| 281 | TEST_F(DexFileTest, GetChecksum) { |
| 282 | uint32_t checksum; |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 283 | ScopedObjectAccess soa(Thread::Current()); |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 284 | std::string error_msg; |
Przemyslaw Szczepaniak | 5b8e6e3 | 2015-09-30 14:40:33 +0100 | [diff] [blame] | 285 | EXPECT_TRUE(DexFile::GetChecksum(GetLibCoreDexFileNames()[0].c_str(), &checksum, &error_msg)) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 286 | << error_msg; |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 287 | EXPECT_EQ(java_lang_dex_file_->GetLocationChecksum(), checksum); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 290 | TEST_F(DexFileTest, ClassDefs) { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 291 | ScopedObjectAccess soa(Thread::Current()); |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 292 | std::unique_ptr<const DexFile> raw(OpenTestDexFile("Nested")); |
| 293 | ASSERT_TRUE(raw.get() != nullptr); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 294 | EXPECT_EQ(2U, raw->NumClassDefs()); |
| 295 | |
Brian Carlstrom | f615a61 | 2011-07-23 12:50:34 -0700 | [diff] [blame] | 296 | const DexFile::ClassDef& c0 = raw->GetClassDef(0); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 297 | EXPECT_STREQ("LNested$Inner;", raw->GetClassDescriptor(c0)); |
| 298 | |
Brian Carlstrom | f615a61 | 2011-07-23 12:50:34 -0700 | [diff] [blame] | 299 | const DexFile::ClassDef& c1 = raw->GetClassDef(1); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 300 | EXPECT_STREQ("LNested;", raw->GetClassDescriptor(c1)); |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 301 | } |
| 302 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 303 | TEST_F(DexFileTest, GetMethodSignature) { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 304 | ScopedObjectAccess soa(Thread::Current()); |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 305 | std::unique_ptr<const DexFile> raw(OpenTestDexFile("GetMethodSignature")); |
| 306 | ASSERT_TRUE(raw.get() != nullptr); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 307 | EXPECT_EQ(1U, raw->NumClassDefs()); |
| 308 | |
| 309 | const DexFile::ClassDef& class_def = raw->GetClassDef(0); |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 310 | ASSERT_STREQ("LGetMethodSignature;", raw->GetClassDescriptor(class_def)); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 311 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 312 | const uint8_t* class_data = raw->GetClassData(class_def); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 313 | ASSERT_TRUE(class_data != nullptr); |
Elliott Hughes | 4d6850c | 2012-01-18 15:55:06 -0800 | [diff] [blame] | 314 | ClassDataItemIterator it(*raw, class_data); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 315 | |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 316 | EXPECT_EQ(1u, it.NumDirectMethods()); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 317 | |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 318 | // Check the signature for the static initializer. |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 319 | { |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 320 | ASSERT_EQ(1U, it.NumDirectMethods()); |
| 321 | const DexFile::MethodId& method_id = raw->GetMethodId(it.GetMemberIndex()); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 322 | const char* name = raw->StringDataByIdx(method_id.name_idx_); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 323 | ASSERT_STREQ("<init>", name); |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 324 | std::string signature(raw->GetMethodSignature(method_id).ToString()); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 325 | ASSERT_EQ("()V", signature); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | // Check both virtual methods. |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 329 | ASSERT_EQ(2U, it.NumVirtualMethods()); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 330 | { |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 331 | it.Next(); |
| 332 | const DexFile::MethodId& method_id = raw->GetMethodId(it.GetMemberIndex()); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 333 | |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 334 | const char* name = raw->StringDataByIdx(method_id.name_idx_); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 335 | ASSERT_STREQ("m1", name); |
| 336 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 337 | std::string signature(raw->GetMethodSignature(method_id).ToString()); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 338 | ASSERT_EQ("(IDJLjava/lang/Object;)Ljava/lang/Float;", signature); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | { |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 342 | it.Next(); |
| 343 | const DexFile::MethodId& method_id = raw->GetMethodId(it.GetMemberIndex()); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 344 | |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 345 | const char* name = raw->StringDataByIdx(method_id.name_idx_); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 346 | ASSERT_STREQ("m2", name); |
| 347 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 348 | std::string signature(raw->GetMethodSignature(method_id).ToString()); |
| 349 | ASSERT_EQ("(ZSC)LGetMethodSignature;", signature); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | |
| 353 | TEST_F(DexFileTest, FindStringId) { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 354 | ScopedObjectAccess soa(Thread::Current()); |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 355 | std::unique_ptr<const DexFile> raw(OpenTestDexFile("GetMethodSignature")); |
| 356 | ASSERT_TRUE(raw.get() != nullptr); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 357 | EXPECT_EQ(1U, raw->NumClassDefs()); |
| 358 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 359 | const char* strings[] = { "LGetMethodSignature;", "Ljava/lang/Float;", "Ljava/lang/Object;", |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 360 | "D", "I", "J", nullptr }; |
| 361 | for (size_t i = 0; strings[i] != nullptr; i++) { |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 362 | const char* str = strings[i]; |
| 363 | const DexFile::StringId* str_id = raw->FindStringId(str); |
| 364 | const char* dex_str = raw->GetStringData(*str_id); |
| 365 | EXPECT_STREQ(dex_str, str); |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | TEST_F(DexFileTest, FindTypeId) { |
| 370 | for (size_t i = 0; i < java_lang_dex_file_->NumTypeIds(); i++) { |
| 371 | const char* type_str = java_lang_dex_file_->StringByTypeIdx(i); |
| 372 | const DexFile::StringId* type_str_id = java_lang_dex_file_->FindStringId(type_str); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 373 | ASSERT_TRUE(type_str_id != nullptr); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 374 | uint32_t type_str_idx = java_lang_dex_file_->GetIndexForStringId(*type_str_id); |
| 375 | const DexFile::TypeId* type_id = java_lang_dex_file_->FindTypeId(type_str_idx); |
Mathieu Chartier | 9507fa2 | 2015-10-29 15:08:57 -0700 | [diff] [blame] | 376 | ASSERT_EQ(type_id, java_lang_dex_file_->FindTypeId(type_str)); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 377 | ASSERT_TRUE(type_id != nullptr); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 378 | EXPECT_EQ(java_lang_dex_file_->GetIndexForTypeId(*type_id), i); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | TEST_F(DexFileTest, FindProtoId) { |
| 383 | for (size_t i = 0; i < java_lang_dex_file_->NumProtoIds(); i++) { |
| 384 | const DexFile::ProtoId& to_find = java_lang_dex_file_->GetProtoId(i); |
| 385 | const DexFile::TypeList* to_find_tl = java_lang_dex_file_->GetProtoParameters(to_find); |
| 386 | std::vector<uint16_t> to_find_types; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 387 | if (to_find_tl != nullptr) { |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 388 | for (size_t j = 0; j < to_find_tl->Size(); j++) { |
| 389 | to_find_types.push_back(to_find_tl->GetTypeItem(j).type_idx_); |
| 390 | } |
| 391 | } |
| 392 | const DexFile::ProtoId* found = |
| 393 | java_lang_dex_file_->FindProtoId(to_find.return_type_idx_, to_find_types); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 394 | ASSERT_TRUE(found != nullptr); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 395 | EXPECT_EQ(java_lang_dex_file_->GetIndexForProtoId(*found), i); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | TEST_F(DexFileTest, FindMethodId) { |
| 400 | for (size_t i = 0; i < java_lang_dex_file_->NumMethodIds(); i++) { |
| 401 | const DexFile::MethodId& to_find = java_lang_dex_file_->GetMethodId(i); |
| 402 | const DexFile::TypeId& klass = java_lang_dex_file_->GetTypeId(to_find.class_idx_); |
| 403 | const DexFile::StringId& name = java_lang_dex_file_->GetStringId(to_find.name_idx_); |
| 404 | const DexFile::ProtoId& signature = java_lang_dex_file_->GetProtoId(to_find.proto_idx_); |
| 405 | const DexFile::MethodId* found = java_lang_dex_file_->FindMethodId(klass, name, signature); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 406 | ASSERT_TRUE(found != nullptr) << "Didn't find method " << i << ": " |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 407 | << java_lang_dex_file_->StringByTypeIdx(to_find.class_idx_) << "." |
| 408 | << java_lang_dex_file_->GetStringData(name) |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 409 | << java_lang_dex_file_->GetMethodSignature(to_find); |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 410 | EXPECT_EQ(java_lang_dex_file_->GetIndexForMethodId(*found), i); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 411 | } |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Ian Rogers | 9b1a4f4 | 2011-11-14 18:35:10 -0800 | [diff] [blame] | 414 | TEST_F(DexFileTest, FindFieldId) { |
| 415 | for (size_t i = 0; i < java_lang_dex_file_->NumFieldIds(); i++) { |
| 416 | const DexFile::FieldId& to_find = java_lang_dex_file_->GetFieldId(i); |
| 417 | const DexFile::TypeId& klass = java_lang_dex_file_->GetTypeId(to_find.class_idx_); |
| 418 | const DexFile::StringId& name = java_lang_dex_file_->GetStringId(to_find.name_idx_); |
| 419 | const DexFile::TypeId& type = java_lang_dex_file_->GetTypeId(to_find.type_idx_); |
| 420 | const DexFile::FieldId* found = java_lang_dex_file_->FindFieldId(klass, name, type); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 421 | ASSERT_TRUE(found != nullptr) << "Didn't find field " << i << ": " |
Ian Rogers | 9b1a4f4 | 2011-11-14 18:35:10 -0800 | [diff] [blame] | 422 | << java_lang_dex_file_->StringByTypeIdx(to_find.type_idx_) << " " |
| 423 | << java_lang_dex_file_->StringByTypeIdx(to_find.class_idx_) << "." |
| 424 | << java_lang_dex_file_->GetStringData(name); |
| 425 | EXPECT_EQ(java_lang_dex_file_->GetIndexForFieldId(*found), i); |
| 426 | } |
| 427 | } |
| 428 | |
Calin Juravle | 4e1d579 | 2014-07-15 23:56:47 +0100 | [diff] [blame] | 429 | TEST_F(DexFileTest, GetMultiDexClassesDexName) { |
Andreas Gampe | 90e3404 | 2015-04-27 20:01:52 -0700 | [diff] [blame] | 430 | ASSERT_EQ("classes.dex", DexFile::GetMultiDexClassesDexName(0)); |
| 431 | ASSERT_EQ("classes2.dex", DexFile::GetMultiDexClassesDexName(1)); |
| 432 | ASSERT_EQ("classes3.dex", DexFile::GetMultiDexClassesDexName(2)); |
| 433 | ASSERT_EQ("classes100.dex", DexFile::GetMultiDexClassesDexName(99)); |
| 434 | } |
| 435 | |
| 436 | TEST_F(DexFileTest, GetMultiDexLocation) { |
Calin Juravle | 4e1d579 | 2014-07-15 23:56:47 +0100 | [diff] [blame] | 437 | std::string dex_location_str = "/system/app/framework.jar"; |
| 438 | const char* dex_location = dex_location_str.c_str(); |
Andreas Gampe | 90e3404 | 2015-04-27 20:01:52 -0700 | [diff] [blame] | 439 | ASSERT_EQ("/system/app/framework.jar", DexFile::GetMultiDexLocation(0, dex_location)); |
| 440 | ASSERT_EQ("/system/app/framework.jar:classes2.dex", |
| 441 | DexFile::GetMultiDexLocation(1, dex_location)); |
| 442 | ASSERT_EQ("/system/app/framework.jar:classes101.dex", |
| 443 | DexFile::GetMultiDexLocation(100, dex_location)); |
Calin Juravle | 4e1d579 | 2014-07-15 23:56:47 +0100 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | TEST_F(DexFileTest, GetDexCanonicalLocation) { |
| 447 | ScratchFile file; |
Vladimir Marko | aa4497d | 2014-09-05 14:01:17 +0100 | [diff] [blame] | 448 | UniqueCPtr<const char[]> dex_location_real(realpath(file.GetFilename().c_str(), nullptr)); |
| 449 | std::string dex_location(dex_location_real.get()); |
Calin Juravle | 4e1d579 | 2014-07-15 23:56:47 +0100 | [diff] [blame] | 450 | |
Calin Juravle | 61281dc | 2014-08-07 11:54:36 +0100 | [diff] [blame] | 451 | ASSERT_EQ(dex_location, DexFile::GetDexCanonicalLocation(dex_location.c_str())); |
Andreas Gampe | 90e3404 | 2015-04-27 20:01:52 -0700 | [diff] [blame] | 452 | std::string multidex_location = DexFile::GetMultiDexLocation(1, dex_location.c_str()); |
Calin Juravle | 4e1d579 | 2014-07-15 23:56:47 +0100 | [diff] [blame] | 453 | ASSERT_EQ(multidex_location, DexFile::GetDexCanonicalLocation(multidex_location.c_str())); |
| 454 | |
| 455 | std::string dex_location_sym = dex_location + "symlink"; |
| 456 | ASSERT_EQ(0, symlink(dex_location.c_str(), dex_location_sym.c_str())); |
| 457 | |
| 458 | ASSERT_EQ(dex_location, DexFile::GetDexCanonicalLocation(dex_location_sym.c_str())); |
| 459 | |
Andreas Gampe | 90e3404 | 2015-04-27 20:01:52 -0700 | [diff] [blame] | 460 | std::string multidex_location_sym = DexFile::GetMultiDexLocation(1, dex_location_sym.c_str()); |
Calin Juravle | 4e1d579 | 2014-07-15 23:56:47 +0100 | [diff] [blame] | 461 | ASSERT_EQ(multidex_location, DexFile::GetDexCanonicalLocation(multidex_location_sym.c_str())); |
| 462 | |
| 463 | ASSERT_EQ(0, unlink(dex_location_sym.c_str())); |
| 464 | } |
| 465 | |
Richard Uhler | e5fed03 | 2015-03-18 08:21:11 -0700 | [diff] [blame] | 466 | TEST(DexFileUtilsTest, GetBaseLocationAndMultiDexSuffix) { |
| 467 | EXPECT_EQ("/foo/bar/baz.jar", DexFile::GetBaseLocation("/foo/bar/baz.jar")); |
| 468 | EXPECT_EQ("/foo/bar/baz.jar", DexFile::GetBaseLocation("/foo/bar/baz.jar:classes2.dex")); |
| 469 | EXPECT_EQ("/foo/bar/baz.jar", DexFile::GetBaseLocation("/foo/bar/baz.jar:classes8.dex")); |
| 470 | EXPECT_EQ("", DexFile::GetMultiDexSuffix("/foo/bar/baz.jar")); |
| 471 | EXPECT_EQ(":classes2.dex", DexFile::GetMultiDexSuffix("/foo/bar/baz.jar:classes2.dex")); |
| 472 | EXPECT_EQ(":classes8.dex", DexFile::GetMultiDexSuffix("/foo/bar/baz.jar:classes8.dex")); |
| 473 | } |
| 474 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 475 | } // namespace art |