• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 /** Utils for testing with minimal dependencies. */
18 
19 #ifndef ART_LIBARTBASE_BASE_TESTING_H_
20 #define ART_LIBARTBASE_BASE_TESTING_H_
21 
22 #include <string>
23 #include <vector>
24 
25 #include "base/globals.h"
26 
27 namespace art {
28 namespace testing {
29 
IsHost()30 inline bool IsHost() { return !art::kIsTargetBuild; }
31 
32 // Returns ${ANDROID_BUILD_TOP}. Ensure it has tailing /.
33 std::string GetAndroidBuildTop();
34 
35 // Returns ${ANDROID_HOST_OUT}.
36 std::string GetAndroidHostOut();
37 
38 // Returns the path where boot classpath and boot image files are installed
39 // for host tests (by the art_common mk module, typically built through "m
40 // art-host-tests"). Different in CI where they are unpacked from the
41 // art-host-tests.zip file.
42 std::string GetHostBootClasspathInstallRoot();
43 
44 // Note: "libcore" here means art + conscrypt + icu.
45 
46 // Gets the names of the libcore modules.
47 // If `core_only` is true, only returns the names of CORE_IMG_JARS in Android.common_path.mk.
48 std::vector<std::string> GetLibCoreModuleNames(bool core_only = false);
49 
50 // Gets the paths of the libcore dex files for given modules, prefixed appropriately for host or
51 // target tests.
52 std::vector<std::string> GetLibCoreDexFileNames(const std::vector<std::string>& modules);
53 
54 // Gets the paths of the libcore module dex files, prefixed appropriately for host or target tests.
GetLibCoreDexFileNames()55 inline std::vector<std::string> GetLibCoreDexFileNames() {
56   return GetLibCoreDexFileNames(GetLibCoreModuleNames());
57 }
58 
59 // Gets the paths of the libcore dex files, prefixed by the given string.
60 // If `core_only` is true, only returns the filenames of CORE_IMG_JARS in Android.common_path.mk.
61 std::vector<std::string> GetLibCoreDexFileNames(const std::string& prefix, bool core_only = false);
62 
63 // Gets the on-device locations of the libcore dex files for given modules.
64 std::vector<std::string> GetLibCoreDexLocations(const std::vector<std::string>& modules);
65 
66 // Gets the on-device locations of the libcore dex files.
67 // If `core_only` is true, only returns the filenames of CORE_IMG_JARS in Android.common_path.mk.
68 std::vector<std::string> GetLibCoreDexLocations(bool core_only = false);
69 
70 std::string GetClassPathOption(const char* option, const std::vector<std::string>& class_path);
71 
72 }  // namespace testing
73 }  // namespace art
74 
75 #endif  // ART_LIBARTBASE_BASE_TESTING_H_
76