1 /*
2  * Copyright (C) 2019 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 #pragma once
17 
18 #include "linkerconfig/variables.h"
19 
MockGenericVariables()20 inline void MockGenericVariables() {
21   android::linkerconfig::modules::Variables::AddValue("VENDOR_VNDK_VERSION",
22                                                       "99");
23   android::linkerconfig::modules::Variables::AddValue("PRODUCT_VNDK_VERSION",
24                                                       "99");
25   android::linkerconfig::modules::Variables::AddValue("PRODUCT", "product");
26   android::linkerconfig::modules::Variables::AddValue("SYSTEM_EXT",
27                                                       "system_ext");
28   android::linkerconfig::modules::Variables::AddValue("LLNDK_LIBRARIES_VENDOR",
29                                                       "llndk_libraries");
30   android::linkerconfig::modules::Variables::AddValue("LLNDK_LIBRARIES_PRODUCT",
31                                                       "llndk_libraries");
32   android::linkerconfig::modules::Variables::AddValue(
33       "SANITIZER_RUNTIME_LIBRARIES", "sanitizer_runtime_libraries");
34   android::linkerconfig::modules::Variables::AddValue(
35       "PRIVATE_LLNDK_LIBRARIES_VENDOR", "private_llndk_libraries");
36   android::linkerconfig::modules::Variables::AddValue(
37       "PRIVATE_LLNDK_LIBRARIES_PRODUCT", "private_llndk_libraries");
38   android::linkerconfig::modules::Variables::AddValue(
39       "VNDK_SAMEPROCESS_LIBRARIES_VENDOR", "vndk_sameprocess_libraries");
40   android::linkerconfig::modules::Variables::AddValue(
41       "VNDK_SAMEPROCESS_LIBRARIES_PRODUCT", "vndk_sameprocess_libraries");
42   android::linkerconfig::modules::Variables::AddValue(
43       "VNDK_CORE_LIBRARIES_VENDOR", "vndk_core_libraries");
44   android::linkerconfig::modules::Variables::AddValue(
45       "VNDK_CORE_LIBRARIES_PRODUCT", "vndk_core_libraries");
46   android::linkerconfig::modules::Variables::AddValue(
47       "VNDK_USING_CORE_VARIANT_LIBRARIES", "");
48   android::linkerconfig::modules::Variables::AddValue("STUB_LIBRARIES",
49                                                       "stub_libraries");
50   android::linkerconfig::modules::Variables::AddValue(
51       "SANITIZER_DEFAULT_VENDOR", "sanitizer_default_libraries");
52   android::linkerconfig::modules::Variables::AddValue(
53       "SANITIZER_DEFAULT_PRODUCT", "sanitizer_default_libraries");
54 }
55 
MockVndkVersion(std::string vndk_version)56 inline void MockVndkVersion(std::string vndk_version) {
57   android::linkerconfig::modules::Variables::AddValue("VENDOR_VNDK_VERSION",
58                                                       vndk_version);
59   android::linkerconfig::modules::Variables::AddValue("PRODUCT_VNDK_VERSION",
60                                                       vndk_version);
61 }
62 
MockVndkUsingCoreVariant()63 inline void MockVndkUsingCoreVariant() {
64   android::linkerconfig::modules::Variables::AddValue(
65       "VNDK_USING_CORE_VARIANT_LIBRARIES", "vndk_using_core_variant_libraries");
66 }
67 
GenerateContextWithVndk()68 inline android::linkerconfig::contents::Context GenerateContextWithVndk() {
69   android::linkerconfig::modules::ApexInfo vndk_apex;
70   vndk_apex.name = "com.android.vndk.v99";
71 
72   android::linkerconfig::contents::Context ctx;
73   ctx.AddApexModule(vndk_apex);
74 
75   return ctx;
76 }
77