xref: /aosp_15_r20/art/libartbase/base/testing.cc (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2022 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 <string>
18*795d594fSAndroid Build Coastguard Worker #include <vector>
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include "android-base/stringprintf.h"
21*795d594fSAndroid Build Coastguard Worker #include "base/file_utils.h"
22*795d594fSAndroid Build Coastguard Worker #include "base/globals.h"
23*795d594fSAndroid Build Coastguard Worker 
24*795d594fSAndroid Build Coastguard Worker namespace art {
25*795d594fSAndroid Build Coastguard Worker namespace testing {
26*795d594fSAndroid Build Coastguard Worker 
27*795d594fSAndroid Build Coastguard Worker namespace {
28*795d594fSAndroid Build Coastguard Worker 
GetDexFileName(const std::string & jar_prefix,const std::string & prefix)29*795d594fSAndroid Build Coastguard Worker std::string GetDexFileName(const std::string& jar_prefix, const std::string& prefix) {
30*795d594fSAndroid Build Coastguard Worker   const char* apexPath =
31*795d594fSAndroid Build Coastguard Worker       (jar_prefix == "conscrypt") ?
32*795d594fSAndroid Build Coastguard Worker           kAndroidConscryptApexDefaultPath :
33*795d594fSAndroid Build Coastguard Worker           (jar_prefix == "core-icu4j" ? kAndroidI18nApexDefaultPath : kAndroidArtApexDefaultPath);
34*795d594fSAndroid Build Coastguard Worker   return android::base::StringPrintf(
35*795d594fSAndroid Build Coastguard Worker       "%s%s/javalib/%s.jar", prefix.c_str(), apexPath, jar_prefix.c_str());
36*795d594fSAndroid Build Coastguard Worker }
37*795d594fSAndroid Build Coastguard Worker 
38*795d594fSAndroid Build Coastguard Worker }  // namespace
39*795d594fSAndroid Build Coastguard Worker 
GetLibCoreModuleNames(bool core_only)40*795d594fSAndroid Build Coastguard Worker std::vector<std::string> GetLibCoreModuleNames(bool core_only) {
41*795d594fSAndroid Build Coastguard Worker   // Note: This must start with the CORE_IMG_JARS in Android.common_path.mk because that's what we
42*795d594fSAndroid Build Coastguard Worker   // use for compiling the boot.art image. It may contain additional modules from TEST_CORE_JARS.
43*795d594fSAndroid Build Coastguard Worker 
44*795d594fSAndroid Build Coastguard Worker   // CORE_IMG_JARS modules.
45*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> modules{
46*795d594fSAndroid Build Coastguard Worker       "core-oj",
47*795d594fSAndroid Build Coastguard Worker       "core-libart",
48*795d594fSAndroid Build Coastguard Worker       "okhttp",
49*795d594fSAndroid Build Coastguard Worker       "bouncycastle",
50*795d594fSAndroid Build Coastguard Worker       "apache-xml",
51*795d594fSAndroid Build Coastguard Worker   };
52*795d594fSAndroid Build Coastguard Worker 
53*795d594fSAndroid Build Coastguard Worker   // Additional modules.
54*795d594fSAndroid Build Coastguard Worker   if (!core_only) {
55*795d594fSAndroid Build Coastguard Worker     modules.push_back("core-icu4j");
56*795d594fSAndroid Build Coastguard Worker     modules.push_back("conscrypt");
57*795d594fSAndroid Build Coastguard Worker   }
58*795d594fSAndroid Build Coastguard Worker 
59*795d594fSAndroid Build Coastguard Worker   return modules;
60*795d594fSAndroid Build Coastguard Worker }
61*795d594fSAndroid Build Coastguard Worker 
GetLibCoreDexFileNames(const std::string & prefix,const std::vector<std::string> & modules)62*795d594fSAndroid Build Coastguard Worker std::vector<std::string> GetLibCoreDexFileNames(const std::string& prefix,
63*795d594fSAndroid Build Coastguard Worker                                                 const std::vector<std::string>& modules) {
64*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> result;
65*795d594fSAndroid Build Coastguard Worker   result.reserve(modules.size());
66*795d594fSAndroid Build Coastguard Worker   for (const std::string& module : modules) {
67*795d594fSAndroid Build Coastguard Worker     result.push_back(GetDexFileName(module, prefix));
68*795d594fSAndroid Build Coastguard Worker   }
69*795d594fSAndroid Build Coastguard Worker   return result;
70*795d594fSAndroid Build Coastguard Worker }
71*795d594fSAndroid Build Coastguard Worker 
GetLibCoreDexFileNames(const std::string & prefix,bool core_only)72*795d594fSAndroid Build Coastguard Worker std::vector<std::string> GetLibCoreDexFileNames(const std::string& prefix, bool core_only) {
73*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> modules = GetLibCoreModuleNames(core_only);
74*795d594fSAndroid Build Coastguard Worker   return GetLibCoreDexFileNames(prefix, modules);
75*795d594fSAndroid Build Coastguard Worker }
76*795d594fSAndroid Build Coastguard Worker 
GetLibCoreDexLocations(const std::vector<std::string> & modules)77*795d594fSAndroid Build Coastguard Worker std::vector<std::string> GetLibCoreDexLocations(const std::vector<std::string>& modules) {
78*795d594fSAndroid Build Coastguard Worker   return GetLibCoreDexFileNames(/*prefix=*/"", modules);
79*795d594fSAndroid Build Coastguard Worker }
80*795d594fSAndroid Build Coastguard Worker 
GetLibCoreDexLocations(bool core_only)81*795d594fSAndroid Build Coastguard Worker std::vector<std::string> GetLibCoreDexLocations(bool core_only) {
82*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> modules = GetLibCoreModuleNames(core_only);
83*795d594fSAndroid Build Coastguard Worker   return GetLibCoreDexLocations(modules);
84*795d594fSAndroid Build Coastguard Worker }
85*795d594fSAndroid Build Coastguard Worker 
86*795d594fSAndroid Build Coastguard Worker }  // namespace testing
87*795d594fSAndroid Build Coastguard Worker }  // namespace art
88