Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Posix / strlcpy.cpp
blobd7a5d1d3a51e9c14a41aab1a6805a803ca4d7bbd
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t
3 // UNSUPPORTED: target={{.*linux.*}}
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
9 void test1() {
10 const char src[] = "abc";
11 char dst[7] = {'x', 'y', 'z', 0};
12 size_t len;
14 len = strlcpy(dst, src, sizeof(dst));
15 printf("%s %zu ", dst, len);
18 void test2() {
19 const char src[] = "abc";
20 char dst[7] = {0};
21 size_t len;
23 len = strlcat(dst, src, sizeof(dst));
24 printf("%s %zu ", dst, len);
27 void test3() {
28 const char src[] = "abc";
29 char dst[4] = {'x', 'y', 'z', 0};
30 size_t len;
32 len = strlcat(dst, src, sizeof(dst));
33 printf("%s %zu ", dst, len);
36 void test4() {
37 const char src[] = "";
38 char dst[4] = {'x', 'y', 'z', 0};
39 size_t len;
41 len = strlcat(dst, src, sizeof(dst));
42 printf("%s %zu\n", dst, len);
45 int main(void) {
46 test1();
47 test2();
48 test3();
49 test4();
51 // CHECK: abc 3 abc 3 xyz 3 0
53 return 0;