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
17 #include <gtest/gtest.h>
18
19 #include "linkerconfig/configwriter.h"
20 #include "linkerconfig/link.h"
21
22 constexpr const char* kSharedLibsExpectedResult =
23 R"(namespace.originalNamespace.link.targetNamespace.shared_libs = lib1.so
24 namespace.originalNamespace.link.targetNamespace.shared_libs += lib2.so
25 namespace.originalNamespace.link.targetNamespace.shared_libs += lib3.so
26 )";
27
TEST(linkerconfig_link,link_with_all_shared_libs)28 TEST(linkerconfig_link, link_with_all_shared_libs) {
29 android::linkerconfig::modules::ConfigWriter writer;
30
31 auto link = std::make_shared<android::linkerconfig::modules::Link>(
32 "originalNamespace", "targetNamespace");
33 link->AllowAllSharedLibs();
34
35 link->WriteConfig(writer);
36 auto config_text = writer.ToString();
37
38 ASSERT_EQ(config_text,
39 "namespace.originalNamespace.link.targetNamespace.allow_all_shared_"
40 "libs = true\n");
41 }
42
TEST(linkerconfig_link,link_with_shared_libs)43 TEST(linkerconfig_link, link_with_shared_libs) {
44 android::linkerconfig::modules::ConfigWriter writer;
45 auto link = std::make_shared<android::linkerconfig::modules::Link>(
46 "originalNamespace", "targetNamespace");
47 link->AddSharedLib("lib1.so", "lib2.so", "lib3.so");
48
49 link->WriteConfig(writer);
50 auto config_text = writer.ToString();
51
52 ASSERT_EQ(config_text, kSharedLibsExpectedResult);
53 }
54