diff --git a/libc-test/BUILD.gn b/libc-test/BUILD.gn index 571560755e51ffa3a576b3d37adfd93af279f37b..fbe0ddde5a3a2a6544ac129859cc325c7ae290a6 100644 --- a/libc-test/BUILD.gn +++ b/libc-test/BUILD.gn @@ -6,6 +6,7 @@ group("musl_libc_test") { deps = [ "src/api:main", "src/common:runtest", + "src/eabi:eabi_test", "src/functional:functional_test", "src/functionalext:functionalext_test", "src/math:math_test", diff --git a/libc-test/src/eabi/BUILD.gn b/libc-test/src/eabi/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1d53e5bb59195516a3eef72dd39eafd0d49b7f05 --- /dev/null +++ b/libc-test/src/eabi/BUILD.gn @@ -0,0 +1,17 @@ +import("../../test_template.gni") +import("test_src_eabi.gni") + +foreach(s, eabi_list) { + test_unittest(s) { + target_dir = "eabi" + } +} + +group("eabi_test") { + testonly = true + deps = [] + + foreach(s, eabi_list) { + deps += [ ":${s}" ] + } +} diff --git a/libc-test/src/eabi/__aeabi_memclr.c b/libc-test/src/eabi/__aeabi_memclr.c new file mode 100644 index 0000000000000000000000000000000000000000..c68165070e7b9922aabfd673cbf0a030aa08c189 --- /dev/null +++ b/libc-test/src/eabi/__aeabi_memclr.c @@ -0,0 +1,68 @@ +/* Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "test.h" + +/** + * @tc.name : memclr_0100 + * @tc.desc : Test __aeabi_memclr method + * @tc.level : Level 1 + */ +extern int __aeabi_memclr(void *dest, size_t n); +extern int __aeabi_memclr4(void *dest, size_t n); +extern int __aeabi_memclr8(void *dest, size_t n); + +void memclr_0100(void) +{ + char dest[] = "__aeabi_memclr"; + if (__aeabi_memclr(dest, sizeof(dest)) == 0) { + t_error("%s __aeabi_memclr", __func__); + } +} + +/** + * @tc.name : memclr_0200S + * @tc.desc : Test __aeabi_memclr4 method + * @tc.level : Level 1 + */ +void memclr_0200(void) +{ + char dest[] = "__aeabi_memclr"; + if (__aeabi_memclr4(dest, sizeof(dest)) == 0) { + t_error("%s __aeabi_memclr4", __func__); + } +} + +/** + * @tc.name : memclr_0300 + * @tc.desc : Test __aeabi_memclr8 method + * @tc.level : Level 1 + */ +void memclr_0300(void) +{ + char dest[] = "__aeabi_memclr"; + if (__aeabi_memclr8(dest, sizeof(dest)) == 0) { + t_error("%s __aeabi_memclr8", __func__); + } +} + +int main() +{ + memclr_0100(); + memclr_0200(); + memclr_0300(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/eabi/__aeabi_memcpy.c b/libc-test/src/eabi/__aeabi_memcpy.c new file mode 100644 index 0000000000000000000000000000000000000000..8ced359046ebb190eff5d57a6a4373a62dcbbcf5 --- /dev/null +++ b/libc-test/src/eabi/__aeabi_memcpy.c @@ -0,0 +1,75 @@ +/* Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "test.h" + +/** + * @tc.name : memcpy_0100 + * @tc.desc : Test __aeabi_memcpy method + * @tc.level : Level 1 + */ + +extern void *__aeabi_memcpy(void *__restrict, const void *__restrict, size_t); +extern void *__aeabi_memcpy4(void *__restrict, const void *__restrict, size_t); +extern void *__aeabi_memcpy8(void *__restrict, const void *__restrict, size_t); + +void memcpy_0100(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src[] = {4, 5, 6, 7}; + void *result = __aeabi_memcpy(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memcpy error get result is %d\n", __func__, result); + } +} + +/** + * @tc.name : memcpy_0200 + * @tc.desc : Test __aeabi_memcpy4 method + * @tc.level : Level 1 + */ +void memcpy_0200(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src[] = {4, 5, 6, 7}; + void *result = __aeabi_memcpy4(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memcpy4 error get result is %d\n", __func__, result); + } +} + +/** + * @tc.name : memcpy_0300 + * @tc.desc : Test __aeabi_memcpy8 method + * @tc.level : Level 1 + */ +void memcpy_0300(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src[] = {4, 5, 6, 7}; + void *result = __aeabi_memcpy8(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memcpy8 error get result is %d\n", __func__, result); + } +} + +int main() +{ + memcpy_0100(); + memcpy_0200(); + memcpy_0300(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/eabi/__aeabi_memmove.c b/libc-test/src/eabi/__aeabi_memmove.c new file mode 100644 index 0000000000000000000000000000000000000000..e21bce8ede6c812de4e6c2c969608065e3f88121 --- /dev/null +++ b/libc-test/src/eabi/__aeabi_memmove.c @@ -0,0 +1,74 @@ +/* Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "test.h" + +extern void *__aeabi_memmove(void *, const void *, size_t); +extern void *__aeabi_memmove4(void *, const void *, size_t); +extern void *__aeabi_memmove8(void *, const void *, size_t); + +/** + * @tc.name : memmove_0100 + * @tc.desc : Test __aeabi_memmove method + * @tc.level : Level 1 + */ +void memmove_0100(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src[] = {4, 5, 6, 7}; + int *result = __aeabi_memmove(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memmove error get result is %d\n", __func__, result); + } +} + +/** + * @tc.name : memmove_0200 + * @tc.desc : Test __aeabi_memmove4 method + * @tc.level : Level 1 + */ +void memmove_0200(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src[] = {4, 5, 6, 7}; + int *result = __aeabi_memmove4(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memmove4 error get result is %d\n", __func__, result); + } +} + +/** + * @tc.name : memmove_0300 + * @tc.desc : Test __aeabi_memmove8 method + * @tc.level : Level 1 + */ +void memmove_0300(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src[] = {4, 5, 6, 7}; + int *result = __aeabi_memmove8(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memmove8 error get result is %d\n", __func__, result); + } +} + +int main() +{ + memmove_0100(); + memmove_0200(); + memmove_0300(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/eabi/__aeabi_memset.c b/libc-test/src/eabi/__aeabi_memset.c new file mode 100644 index 0000000000000000000000000000000000000000..d07e85dc38a64e8e5d4267662b37616b3ecc1387 --- /dev/null +++ b/libc-test/src/eabi/__aeabi_memset.c @@ -0,0 +1,74 @@ +/* Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "test.h" + +extern void *__aeabi_memset(void *, int, size_t); +extern void *__aeabi_memset4(void *, int, size_t); +extern void *__aeabi_memset8(void *, int, size_t); + +/** + * @tc.name : memset_0100 + * @tc.desc : Test __aeabi_memset method + * @tc.level : Level 1 + */ +void memset_0100(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src = 7; + int *result = __aeabi_memset(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memset error get result is %d\n", __func__, result); + } +} + +/** + * @tc.name : memset_0200 + * @tc.desc : Test __aeabi_memset4 method + * @tc.level : Level 1 + */ +void memset_0200(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src = 7; + int *result = __aeabi_memset4(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memset4 error get result is %d\n", __func__, result); + } +} + +/** + * @tc.name : memset_0300 + * @tc.desc : Test __aeabi_memset8 method + * @tc.level : Level 1 + */ +void memset_0300(void) +{ + int dest[] = {1, 2, 3, 4, 5, 6, 7}; + int src = 7; + int *result = __aeabi_memset8(dest, src, 16); + if (result < 0) { + t_error("%s __aeabi_memset8 error get result is %d\n", __func__, result); + } +} + +int main() +{ + memset_0100(); + memset_0200(); + memset_0300(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/eabi/__aeabi_read_tp.c b/libc-test/src/eabi/__aeabi_read_tp.c new file mode 100644 index 0000000000000000000000000000000000000000..dae733cdbb52de861aabfe1fcfc5d29039224e55 --- /dev/null +++ b/libc-test/src/eabi/__aeabi_read_tp.c @@ -0,0 +1,37 @@ +/* Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "test.h" + +extern void *__aeabi_read_tp(); +/** + * @tc.name : memset_0100 + * @tc.desc : Test __aeabi_read_tp method + * @tc.level : Level 1 + */ +void aeabi_read_tp_0100(void) +{ + void *result = __aeabi_read_tp(); + if (result < 0) { + t_error("%s __aeabi_read_tp error get result is %d\n", __func__, __aeabi_read_tp); + } +} + +int main() +{ + aeabi_read_tp_0100(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/eabi/__gmtime64.c b/libc-test/src/eabi/__gmtime64.c new file mode 100644 index 0000000000000000000000000000000000000000..d1e71302a5d4da0262474d18f3bc12ee9d637545 --- /dev/null +++ b/libc-test/src/eabi/__gmtime64.c @@ -0,0 +1,47 @@ +/* Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "test.h" + +extern struct tm *gmtime(const time_t *t); + +/** + * @tc.name : memset_0100 + * @tc.desc : Test __gmtime64 method + * @tc.level : Level 1 + */ +#define BST (+1) +#define CCT (+8) + +void gmtime64_0100(void) +{ + time_t rawtime; + struct tm *info; + + time(&rawtime); + info = gmtime(&rawtime); + + if (info < 0) { + t_error("%s __gmtime64 error get result is %2d\n", __func__, (info->tm_hour + CCT) % 24); + } +} + +int main() +{ + gmtime64_0100(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/eabi/__sigtimedwait_time64.c b/libc-test/src/eabi/__sigtimedwait_time64.c new file mode 100644 index 0000000000000000000000000000000000000000..9b579d5909dd2dd52a0635afe383783f4b0e7e45 --- /dev/null +++ b/libc-test/src/eabi/__sigtimedwait_time64.c @@ -0,0 +1,57 @@ +/* Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "test.h" + +extern int __sigtimedwait_time64(const sigset_t *restrict mask, + siginfo_t *restrict si, + const struct timespec *restrict timeout); +/** + * @tc.name : memset_0100 + * @tc.desc : Test __sigtimedwait_time64 method + * @tc.level : Level 1 + */ +void sigtimedwait_time64_0100(void) +{ + sigset_t set; + pid_t pid; + sigemptyset(&set); + sigaddset(&set, SIGCHLD); + sigprocmask(SIG_BLOCK, &set, NULL); + pid = fork(); + if( pid == -1) { + exit(1); + } else if( pid ) { + sigset_t set2; + siginfo_t siginfo; + struct timespec timeout = {3, 0}; + int signal; + sigemptyset(&set2); + sigaddset(&set2, SIGCHLD); + signal = __sigtimedwait_time64(&set2, &siginfo, &timeout); + if (signal < 0) { + t_error( "%s __sigtimedwait_time64 error get result is %d\n", __func__, signal); + } + } +} + +int main() +{ + sigtimedwait_time64_0100(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/eabi/test_src_eabi.gni b/libc-test/src/eabi/test_src_eabi.gni new file mode 100644 index 0000000000000000000000000000000000000000..0bd52982f6d4248f30c314349e6502d6fc3b8c98 --- /dev/null +++ b/libc-test/src/eabi/test_src_eabi.gni @@ -0,0 +1,9 @@ +eabi_list = [ + "__aeabi_memcpy", + "__aeabi_memmove", + "__aeabi_memset", + "__aeabi_memclr", + "__gmtime64", + "__aeabi_read_tp", + "__sigtimedwait_time64", +]