1# Copyright (c) 2023 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("ldso_cfi_test") {
17  testonly = true
18  deps = [
19    ":cfi_avaiable_schemes_test",
20    ":cfi_cross_dso_dtor_test_exe",
21    ":cfi_cross_dso_dtor_test_use",
22    ":cfi_cross_dso_test_exe",
23    ":cfi_cross_dso_test_lib",
24    ":large_size_lib",
25    ":large_size_test",
26    ":ldso_cfi_check",
27    ":ldso_cfi_test_lib",
28    ":ldso_cfi_typeconversion",
29  ]
30  if (target_cpu == "arm64") {
31    deps += [
32      ":cfi_icall_report_test",
33      ":cfi_report_test",
34    ]
35  }
36}
37
38ohos_executable("ldso_cfi_check") {
39  subsystem_name = "musl"
40  part_name = "libc-test"
41  include_dirs = [
42    "../common",
43    "//third_party/musl/porting/linux/user/include",
44    "//third_party/musl/porting/linux/user/ldso",
45    "//third_party/musl/libc-test/src/common",
46  ]
47
48  sources = [ "ldso_cfi_check.c" ]
49  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
50}
51
52ohos_shared_library("ldso_cfi_test_lib") {
53  include_dirs = [ "." ]
54  sources = [ "ldso_cfi_test_lib.c" ]
55
56  output_name = "ldso_cfi_test_lib"
57  output_extension = "so"
58  subsystem_name = "musl"
59  part_name = "libc-test-lib"
60}
61
62ohos_shared_library("cfi_cross_dso_test_lib") {
63  sanitize = {
64    cfi = true
65    cfi_cross_dso = true
66    debug = true
67  }
68  subsystem_name = "musl"
69  part_name = "libc-test-lib"
70  include_dirs = [
71    "../common",
72    "//third_party/musl/porting/linux/user/include",
73    "//third_party/musl/porting/linux/user/ldso",
74    "//third_party/musl/libc-test/src/common",
75  ]
76  use_rtti = true
77
78  sources = [ "./crossdso/cfi_test_lib.cpp" ]
79}
80
81ohos_executable("cfi_cross_dso_test_exe") {
82  sanitize = {
83    cfi = true
84    cfi_cross_dso = true
85    debug = true
86  }
87  subsystem_name = "musl"
88  part_name = "libc-test"
89  include_dirs = [
90    "../common",
91    "//third_party/musl/porting/linux/user/include",
92    "//third_party/musl/porting/linux/user/ldso",
93    "//third_party/musl/libc-test/src/common",
94  ]
95  use_rtti = true
96
97  sources = [ "./crossdso/cfi_test_exe.cpp" ]
98  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
99}
100
101ohos_shared_library("cfi_cross_dso_dtor_test_base") {
102  sanitize = {
103    cfi = true
104    cfi_cross_dso = true
105    debug = true
106  }
107  subsystem_name = "musl"
108  part_name = "libc-test-lib"
109  include_dirs = [
110    "../common",
111    "//third_party/musl/porting/linux/user/include",
112    "//third_party/musl/porting/linux/user/ldso",
113    "//third_party/musl/libc-test/src/common",
114  ]
115  use_rtti = true
116
117  sources = [ "./crossdso_dtor/libbase.cpp" ]
118}
119
120ohos_shared_library("cfi_cross_dso_dtor_test_use") {
121  sanitize = {
122    cfi = true
123    cfi_cross_dso = true
124    debug = true
125  }
126  subsystem_name = "musl"
127  part_name = "libc-test-lib"
128  include_dirs = [
129    "../common",
130    "//third_party/musl/porting/linux/user/include",
131    "//third_party/musl/porting/linux/user/ldso",
132    "//third_party/musl/libc-test/src/common",
133  ]
134  use_rtti = true
135
136  sources = [ "./crossdso_dtor/libuse.cpp" ]
137
138  deps = [ ":cfi_cross_dso_dtor_test_base" ]
139}
140
141ohos_executable("cfi_cross_dso_dtor_test_exe") {
142  sanitize = {
143    cfi = true
144    cfi_cross_dso = true
145    debug = true
146  }
147  subsystem_name = "musl"
148  part_name = "libc-test"
149  include_dirs = [
150    "../common",
151    "//third_party/musl/porting/linux/user/include",
152    "//third_party/musl/porting/linux/user/ldso",
153    "//third_party/musl/libc-test/src/common",
154  ]
155  use_rtti = true
156
157  ldflags = [ "-Wl,-rpath=./" ]
158
159  sources = [ "./crossdso_dtor/cfi_dtor_test.cpp" ]
160  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
161  deps = [ ":cfi_cross_dso_dtor_test_base" ]
162}
163
164ohos_executable("cfi_avaiable_schemes_test") {
165  sanitize = {
166    cfi = true
167    cfi_cross_dso = true
168    debug = true
169  }
170  subsystem_name = "musl"
171  part_name = "libc-test"
172  include_dirs = [
173    "../common",
174    "//third_party/musl/porting/linux/user/include",
175    "//third_party/musl/porting/linux/user/ldso",
176    "//third_party/musl/libc-test/src/common",
177  ]
178  use_rtti = true
179
180  sources = [ "cfi_avaiable_schemes_test.cpp" ]
181  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
182}
183
184ohos_executable("ldso_cfi_typeconversion") {
185  sanitize = {
186    cfi = true
187    cfi_cross_dso = true
188    debug = true
189  }
190  subsystem_name = "musl"
191  part_name = "libc-test"
192  include_dirs = [
193    "../common",
194    "//third_party/musl/porting/linux/user/include",
195    "//third_party/musl/porting/linux/user/ldso",
196    "//third_party/musl/libc-test/src/common",
197  ]
198  use_rtti = true
199
200  sources = [ "ldso_cfi_typeconversion.cpp" ]
201  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
202}
203
204ohos_executable("cfi_icall_report_test") {
205  sanitize = {
206    cfi = true
207    cfi_cross_dso = true
208    debug = false
209  }
210  subsystem_name = "musl"
211  part_name = "libc-test"
212
213  sources = [ "./cfi_report_test/cfi_icall_report_test.cpp" ]
214  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
215}
216
217ohos_executable("cfi_report_test") {
218  subsystem_name = "musl"
219  part_name = "libc-test"
220
221  sources = [ "./cfi_report_test/cfi_report_test.cpp" ]
222  configs = [ "//third_party/musl/libc-test/src/common:config_runtest" ]
223}
224
225ohos_executable("large_size_test") {
226  sanitize = {
227    cfi = true
228    cfi_cross_dso = true
229  }
230  ldflags = [ "-Wl,-rpath=./" ]
231  subsystem_name = "musl"
232  part_name = "libc-test"
233  deps = [ ":large_size_lib" ]
234  sources = [ "./large_size_library/large_size_test.cpp" ]
235}
236
237ohos_shared_library("large_size_lib") {
238  sanitize = {
239    cfi = true
240    cfi_cross_dso = true
241  }
242  output_name = "large_size"
243  output_extension = "so"
244  subsystem_name = "musl"
245  part_name = "libc-test-lib"
246
247  sources = [ "./large_size_library/large_size_lib.cpp" ]
248}
249