1# Copyright (c) 2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("../../../test_template.gni")
15
16group("dlns_test") {
17  testonly = true
18  deps = [
19    ":dlns_dlopen_ext_test",
20    ":dlns_dlopen_test",
21    ":dlns_dlsym_dep_a",
22    ":dlns_dlsym_test",
23    ":dlns_inherit_test",
24    ":dlns_separated_test",
25    ":dlns_set_fun_test",
26    ":dlns_special_scene_test",
27    ":dlopen_fill_random",
28    ":dlopen_hash_sysv",
29  ]
30}
31
32ohos_executable("dlns_dlopen_test") {
33  subsystem_name = "musl"
34  part_name = "libc-test"
35  include_dirs = [
36    "../common",
37    "//third_party/musl/porting/linux/user/include",
38    "//third_party/musl/libc-test/src/common",
39  ]
40  if (musl_arch == "arm") {
41    defines = [ "MUSL_ARM" ]
42  }
43  sources = [ "dlns_dlopen.c" ]
44  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
45
46  ldflags = [ "-Wl,-rpath=/data/tests/libc-test/src/" ]
47}
48
49ohos_executable("dlns_set_fun_test") {
50  subsystem_name = "musl"
51  part_name = "libc-test"
52  include_dirs = [
53    "../common",
54    "//third_party/musl/porting/linux/user/include",
55    "//third_party/musl/libc-test/src/common",
56  ]
57
58  sources = [ "dlns_set_fun.c" ]
59  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
60  if (!musl_unit_test_flag) {
61    libs = [ "${musl_lib_dir}/libc.a" ]
62    libs += [ "${musl_lib_dir}/libc_ldso.a" ]
63  }
64}
65
66ohos_executable("dlns_inherit_test") {
67  subsystem_name = "musl"
68  part_name = "libc-test"
69  include_dirs = [
70    "../common",
71    "//third_party/musl/porting/linux/user/include",
72    "//third_party/musl/libc-test/src/common",
73  ]
74
75  sources = [ "dlns_inherit.c" ]
76  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
77  if (!musl_unit_test_flag) {
78    libs = [ "${musl_lib_dir}/libc.a" ]
79    libs += [ "${musl_lib_dir}/libc_ldso.a" ]
80  }
81}
82
83ohos_executable("dlns_separated_test") {
84  subsystem_name = "musl"
85  part_name = "libc-test"
86  include_dirs = [
87    "../common",
88    "//third_party/musl/porting/linux/user/include",
89    "//third_party/musl/libc-test/src/common",
90  ]
91
92  sources = [ "dlns_separated.c" ]
93  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
94  if (!musl_unit_test_flag) {
95    libs = [ "${musl_lib_dir}/libc.a" ]
96    libs += [ "${musl_lib_dir}/libc_ldso.a" ]
97  }
98}
99
100ohos_executable("dlns_special_scene_test") {
101  subsystem_name = "musl"
102  part_name = "libc-test"
103  include_dirs = [
104    "../common",
105    "//third_party/musl/porting/linux/user/include",
106    "//third_party/musl/libc-test/src/common",
107  ]
108
109  sources = [ "dlns_special_scene.c" ]
110  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
111}
112
113ohos_executable("dlns_dlsym_test") {
114  subsystem_name = "musl"
115  part_name = "libc-test"
116  include_dirs = [
117    "../common",
118    "//third_party/musl/porting/linux/user/include",
119    "//third_party/musl/libc-test/src/common",
120  ]
121
122  sources = [ "dlns_dlsym.c" ]
123  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
124}
125
126ohos_executable("dlns_dlopen_ext_test") {
127  subsystem_name = "musl"
128  part_name = "libc-test"
129  include_dirs = [ "../common" ]
130
131  sources = [ "dlns_dlopen_ext.c" ]
132  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
133}
134
135ohos_shared_library("dlns_dlsym_dep_c") {
136  include_dirs = [ "." ]
137
138  sources = [ "dlns_dlsym_dep_c.c" ]
139
140  output_name = "dlns_dlsym_dep_c"
141
142  output_extension = "so"
143
144  subsystem_name = "musl"
145  part_name = "libc-test-lib"
146}
147
148ohos_shared_library("dlns_dlsym_dep_b") {
149  include_dirs = [ "." ]
150
151  sources = [ "dlns_dlsym_dep_b.c" ]
152
153  output_name = "dlns_dlsym_dep_b"
154
155  output_extension = "so"
156
157  deps = [ ":dlns_dlsym_dep_c" ]
158
159  subsystem_name = "musl"
160  part_name = "libc-test-lib"
161}
162
163ohos_shared_library("dlns_dlsym_dep_a") {
164  include_dirs = [ "." ]
165
166  sources = [ "dlns_dlsym_dep_a.c" ]
167
168  output_name = "dlns_dlsym_dep_a"
169
170  output_extension = "so"
171
172  deps = [ ":dlns_dlsym_dep_b" ]
173
174  subsystem_name = "musl"
175  part_name = "libc-test-lib"
176}
177
178ohos_shared_library("dlopen_hash_sysv") {
179  include_dirs = [ "." ]
180
181  sources = [ "dlns_dlsym_dep_c.c" ]
182
183  output_name = "dlopen_hash_sysv"
184
185  output_extension = "so"
186
187  subsystem_name = "musl"
188  part_name = "libc-test-lib"
189
190  ldflags = [ "-Wl,--hash-style=sysv" ]
191}
192
193ohos_shared_library("dlopen_fill_random") {
194  include_dirs = [ "." ]
195
196  sources = [ "dlns_dlsym_dep_c.c" ]
197
198  stack_protector_ret = true
199
200  output_name = "dlopen_fill_random"
201
202  output_extension = "so"
203
204  subsystem_name = "musl"
205  part_name = "libc-test-lib"
206}
207