1add_libc_testsuite(libc_string_unittests)
2
3add_subdirectory(memory_utils)
4
5add_libc_unittest(
6  strcat_test
7  SUITE
8    libc_string_unittests
9  SRCS
10    strcat_test.cpp
11  DEPENDS
12    libc.src.string.strcat
13)
14
15add_libc_unittest(
16  strcpy_test
17  SUITE
18    libc_string_unittests
19  SRCS
20    strcpy_test.cpp
21  DEPENDS
22    libc.src.string.strcpy
23)
24
25add_libc_unittest(
26  strlen_test
27  SUITE
28    libc_string_unittests
29  SRCS
30    strlen_test.cpp
31  DEPENDS
32    libc.src.string.strlen
33)
34
35add_libc_unittest(
36  strcmp_test
37  SUITE
38    libc_string_unittests
39  SRCS
40    strcmp_test.cpp
41  DEPENDS
42    libc.src.string.strcmp
43)
44
45add_libc_unittest(
46  memchr_test
47  SUITE
48    libc_string_unittests
49  SRCS
50    memchr_test.cpp
51  DEPENDS
52    libc.src.string.memchr
53)
54
55add_libc_unittest(
56  strchr_test
57  SUITE
58    libc_string_unittests
59  SRCS
60    strchr_test.cpp
61  DEPENDS
62    libc.src.string.strchr
63)
64
65add_libc_unittest(
66  strstr_test
67  SUITE
68    libc_string_unittests
69  SRCS
70    strstr_test.cpp
71  DEPENDS
72    libc.src.string.strstr
73)
74
75add_libc_unittest(
76  strncpy_test
77  SUITE
78    libc_string_unittests
79  SRCS
80    strncpy_test.cpp
81  DEPENDS
82    libc.src.string.strncpy
83)
84
85add_libc_unittest(
86  strnlen_test
87  SUITE
88    libc_string_unittests
89  SRCS
90    strnlen_test.cpp
91  DEPENDS
92    libc.src.string.strnlen
93)
94
95add_libc_unittest(
96  memrchr_test
97  SUITE
98    libc_string_unittests
99  SRCS
100    memrchr_test.cpp
101  DEPENDS
102    libc.src.string.memrchr
103)
104
105add_libc_unittest(
106  strrchr_test
107  SUITE
108    libc_string_unittests
109  SRCS
110    strrchr_test.cpp
111  DEPENDS
112    libc.src.string.strrchr
113)
114
115add_libc_unittest(
116  strcspn_test
117  SUITE
118    libc_string_unittests
119  SRCS
120    strcspn_test.cpp
121  DEPENDS
122    libc.src.string.strcspn
123)
124
125add_libc_unittest(
126  strspn_test
127  SUITE
128    libc_string_unittests
129  SRCS
130    strspn_test.cpp
131  DEPENDS
132    libc.src.string.strspn
133)
134
135add_libc_unittest(
136  strpbrk_test
137  SUITE
138    libc_string_unittests
139  SRCS
140    strpbrk_test.cpp
141  DEPENDS
142    libc.src.string.strpbrk
143)
144
145add_libc_unittest(
146  strtok_test
147  SUITE
148    libc_string_unittests
149  SRCS
150    strtok_test.cpp
151  DEPENDS
152    libc.src.string.strtok
153)
154
155add_libc_unittest(
156  strtok_r_test
157  SUITE
158    libc_string_unittests
159  SRCS
160    strtok_r_test.cpp
161  DEPENDS
162    libc.src.string.strtok_r
163)
164
165# Tests all implementations that can run on the host.
166function(add_libc_multi_impl_test name)
167  get_property(fq_implementations GLOBAL PROPERTY ${name}_implementations)
168  foreach(fq_config_name IN LISTS fq_implementations)
169    get_target_property(required_cpu_features ${fq_config_name} REQUIRE_CPU_FEATURES)
170    host_supports(can_run "${required_cpu_features}")
171    if(can_run)
172      add_libc_unittest(
173        ${fq_config_name}_test
174        SUITE
175          libc_string_unittests
176        DEPENDS
177          ${fq_config_name}
178        ${ARGN}
179      )
180    else()
181      message(STATUS "Skipping test for '${fq_config_name}' insufficient host cpu features '${required_cpu_features}'")
182    endif()
183  endforeach()
184endfunction()
185
186add_libc_multi_impl_test(memcpy SRCS memcpy_test.cpp)
187add_libc_multi_impl_test(memset SRCS memset_test.cpp)
188add_libc_multi_impl_test(bzero SRCS bzero_test.cpp)
189