| Orion Hodson | 4c3ade6 | 2021-02-10 14:07:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 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 "odr_artifacts.h" |
| 18 | |
| 19 | #include "arch/instruction_set.h" |
| 20 | #include "base/common_art_test.h" |
| 21 | #include "base/file_utils.h" |
| 22 | #include "base/string_view_cpp20.h" |
| 23 | #include "odrefresh/odrefresh.h" |
| 24 | |
| 25 | namespace art { |
| 26 | namespace odrefresh { |
| 27 | |
| 28 | TEST(OdrArtifactsTest, ForBootImageExtension) { |
| 29 | ScopedUnsetEnvironmentVariable no_env("ART_APEX_DATA"); |
| 30 | |
| 31 | const std::string image_location = GetApexDataBootImage("/system/framework/framework.jar"); |
| 32 | EXPECT_TRUE(StartsWith(image_location, GetArtApexData())); |
| 33 | |
| 34 | const std::string image_filename = |
| 35 | GetSystemImageFilename(image_location.c_str(), InstructionSet::kArm64); |
| 36 | |
| 37 | const auto artifacts = OdrArtifacts::ForBootImageExtension(image_filename); |
| 38 | CHECK_EQ(std::string(kOdrefreshArtifactDirectory) + "/arm64/boot-framework.art", |
| 39 | artifacts.ImagePath()); |
| 40 | CHECK_EQ(std::string(kOdrefreshArtifactDirectory) + "/arm64/boot-framework.oat", |
| 41 | artifacts.OatPath()); |
| 42 | CHECK_EQ(std::string(kOdrefreshArtifactDirectory) + "/arm64/boot-framework.vdex", |
| 43 | artifacts.VdexPath()); |
| 44 | } |
| 45 | |
| 46 | TEST(OdrArtifactsTest, ForSystemServer) { |
| 47 | ScopedUnsetEnvironmentVariable no_env("ART_APEX_DATA"); |
| 48 | |
| 49 | const std::string image_location = GetApexDataImage("/system/framework/services.jar"); |
| 50 | EXPECT_TRUE(StartsWith(image_location, GetArtApexData())); |
| 51 | |
| 52 | const std::string image_filename = |
| 53 | GetSystemImageFilename(image_location.c_str(), InstructionSet::kX86); |
| 54 | const auto artifacts = OdrArtifacts::ForSystemServer(image_filename); |
| 55 | CHECK_EQ( |
| 56 | std::string(kOdrefreshArtifactDirectory) + "/x86/system@framework@services.jar@classes.art", |
| 57 | artifacts.ImagePath()); |
| 58 | CHECK_EQ( |
| 59 | std::string(kOdrefreshArtifactDirectory) + "/x86/system@framework@services.jar@classes.odex", |
| 60 | artifacts.OatPath()); |
| 61 | CHECK_EQ( |
| 62 | std::string(kOdrefreshArtifactDirectory) + "/x86/system@framework@services.jar@classes.vdex", |
| 63 | artifacts.VdexPath()); |
| 64 | } |
| 65 | |
| 66 | } // namespace odrefresh |
| 67 | } // namespace art |