4 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 * See https://llvm.org/LICENSE.txt for license information.
6 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
13 #include "stringlib.h"
15 static const struct fun
18 char *(*fun
)(char *dest
, const char *src
);
24 # if __ARM_FEATURE_SVE
25 F(__strcpy_aarch64_sve
)
27 #elif __arm__ && defined (__thumb2__) && !defined (__thumb__)
34 static int test_status
;
35 #define ERR(...) (test_status=1, printf(__VA_ARGS__))
39 static char dbuf
[LEN
+2*A
];
40 static char sbuf
[LEN
+2*A
];
41 static char wbuf
[LEN
+2*A
];
43 static void *alignup(void *p
)
45 return (void*)(((uintptr_t)p
+ A
-1) & -A
);
48 static void test(const struct fun
*fun
, int dalign
, int salign
, int len
)
50 char *src
= alignup(sbuf
);
51 char *dst
= alignup(dbuf
);
53 char *s
= src
+ salign
;
54 char *d
= dst
+ dalign
;
55 char *w
= want
+ dalign
;
59 if (len
> LEN
|| dalign
>= A
|| salign
>= A
)
61 for (i
= 0; i
< len
+A
; i
++) {
63 want
[i
] = dst
[i
] = '*';
65 for (i
= 0; i
< len
; i
++)
66 s
[i
] = w
[i
] = 'a' + i
%23;
71 ERR("%s(%p,..) returned %p\n", fun
->name
, d
, p
);
72 for (i
= 0; i
< len
+A
; i
++) {
73 if (dst
[i
] != want
[i
]) {
74 ERR("%s(align %d, align %d, %d) failed\n", fun
->name
, dalign
, salign
, len
);
75 ERR("got : %.*s\n", dalign
+len
+1, dst
);
76 ERR("want: %.*s\n", dalign
+len
+1, want
);
85 for (int i
=0; funtab
[i
].name
; i
++) {
87 for (int d
= 0; d
< A
; d
++)
88 for (int s
= 0; s
< A
; s
++) {
90 for (n
= 0; n
< 100; n
++)
91 test(funtab
+i
, d
, s
, n
);
92 for (; n
< LEN
; n
*= 2)
93 test(funtab
+i
, d
, s
, n
);
95 printf("%s %s\n", test_status
? "FAIL" : "PASS", funtab
[i
].name
);