1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2021 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker *
4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker *
8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker *
10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker */
16*795d594fSAndroid Build Coastguard Worker
17*795d594fSAndroid Build Coastguard Worker #include "odr_artifacts.h"
18*795d594fSAndroid Build Coastguard Worker
19*795d594fSAndroid Build Coastguard Worker #include "arch/instruction_set.h"
20*795d594fSAndroid Build Coastguard Worker #include "base/common_art_test.h"
21*795d594fSAndroid Build Coastguard Worker #include "base/file_utils.h"
22*795d594fSAndroid Build Coastguard Worker #include "odrefresh/odrefresh.h"
23*795d594fSAndroid Build Coastguard Worker
24*795d594fSAndroid Build Coastguard Worker namespace art {
25*795d594fSAndroid Build Coastguard Worker namespace odrefresh {
26*795d594fSAndroid Build Coastguard Worker
27*795d594fSAndroid Build Coastguard Worker static constexpr const char* kOdrefreshArtifactDirectory = "/test/dir";
28*795d594fSAndroid Build Coastguard Worker
TEST(OdrArtifactsTest,ForBootImage)29*795d594fSAndroid Build Coastguard Worker TEST(OdrArtifactsTest, ForBootImage) {
30*795d594fSAndroid Build Coastguard Worker ScopedUnsetEnvironmentVariable no_env("ART_APEX_DATA");
31*795d594fSAndroid Build Coastguard Worker setenv("ART_APEX_DATA", kOdrefreshArtifactDirectory, /* overwrite */ 1);
32*795d594fSAndroid Build Coastguard Worker
33*795d594fSAndroid Build Coastguard Worker const std::string image_location = GetApexDataBootImage("/system/framework/framework.jar");
34*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(image_location.starts_with(GetArtApexData()));
35*795d594fSAndroid Build Coastguard Worker
36*795d594fSAndroid Build Coastguard Worker const std::string image_filename =
37*795d594fSAndroid Build Coastguard Worker GetSystemImageFilename(image_location.c_str(), InstructionSet::kArm64);
38*795d594fSAndroid Build Coastguard Worker
39*795d594fSAndroid Build Coastguard Worker const auto artifacts = OdrArtifacts::ForBootImage(image_filename);
40*795d594fSAndroid Build Coastguard Worker CHECK_EQ(std::string(kOdrefreshArtifactDirectory) + "/dalvik-cache/arm64/boot-framework.art",
41*795d594fSAndroid Build Coastguard Worker artifacts.ImagePath());
42*795d594fSAndroid Build Coastguard Worker CHECK_EQ(std::string(kOdrefreshArtifactDirectory) + "/dalvik-cache/arm64/boot-framework.oat",
43*795d594fSAndroid Build Coastguard Worker artifacts.OatPath());
44*795d594fSAndroid Build Coastguard Worker CHECK_EQ(std::string(kOdrefreshArtifactDirectory) + "/dalvik-cache/arm64/boot-framework.vdex",
45*795d594fSAndroid Build Coastguard Worker artifacts.VdexPath());
46*795d594fSAndroid Build Coastguard Worker }
47*795d594fSAndroid Build Coastguard Worker
TEST(OdrArtifactsTest,ForSystemServer)48*795d594fSAndroid Build Coastguard Worker TEST(OdrArtifactsTest, ForSystemServer) {
49*795d594fSAndroid Build Coastguard Worker ScopedUnsetEnvironmentVariable no_env("ART_APEX_DATA");
50*795d594fSAndroid Build Coastguard Worker setenv("ART_APEX_DATA", kOdrefreshArtifactDirectory, /* overwrite */ 1);
51*795d594fSAndroid Build Coastguard Worker
52*795d594fSAndroid Build Coastguard Worker const std::string image_location = GetApexDataImage("/system/framework/services.jar");
53*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(image_location.starts_with(GetArtApexData()));
54*795d594fSAndroid Build Coastguard Worker
55*795d594fSAndroid Build Coastguard Worker const std::string image_filename =
56*795d594fSAndroid Build Coastguard Worker GetSystemImageFilename(image_location.c_str(), InstructionSet::kX86);
57*795d594fSAndroid Build Coastguard Worker const auto artifacts = OdrArtifacts::ForSystemServer(image_filename);
58*795d594fSAndroid Build Coastguard Worker CHECK_EQ(
59*795d594fSAndroid Build Coastguard Worker std::string(kOdrefreshArtifactDirectory) + "/dalvik-cache/x86/system@[email protected]@classes.art",
60*795d594fSAndroid Build Coastguard Worker artifacts.ImagePath());
61*795d594fSAndroid Build Coastguard Worker CHECK_EQ(
62*795d594fSAndroid Build Coastguard Worker std::string(kOdrefreshArtifactDirectory) + "/dalvik-cache/x86/system@[email protected]@classes.odex",
63*795d594fSAndroid Build Coastguard Worker artifacts.OatPath());
64*795d594fSAndroid Build Coastguard Worker CHECK_EQ(
65*795d594fSAndroid Build Coastguard Worker std::string(kOdrefreshArtifactDirectory) + "/dalvik-cache/x86/system@[email protected]@classes.vdex",
66*795d594fSAndroid Build Coastguard Worker artifacts.VdexPath());
67*795d594fSAndroid Build Coastguard Worker }
68*795d594fSAndroid Build Coastguard Worker
69*795d594fSAndroid Build Coastguard Worker } // namespace odrefresh
70*795d594fSAndroid Build Coastguard Worker } // namespace art
71