Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / NetBSD / rmd160.cpp
blob5b9ff0cb2e11fe9f0f579ef9b4b5d8cad42f7798
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
3 #include <assert.h>
4 #include <rmd160.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
9 void test1() {
10 RMD160_CTX ctx;
11 uint8_t entropy[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
12 uint8_t digest[RMD160_DIGEST_LENGTH];
14 RMD160Init(&ctx);
15 RMD160Update(&ctx, entropy, __arraycount(entropy));
16 RMD160Final(digest, &ctx);
18 printf("test1: '");
19 for (size_t i = 0; i < __arraycount(digest); i++)
20 printf("%02x", digest[i]);
21 printf("'\n");
24 void test2() {
25 RMD160_CTX ctx;
26 uint8_t entropy[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
27 char digest[RMD160_DIGEST_STRING_LENGTH];
29 RMD160Init(&ctx);
30 RMD160Update(&ctx, entropy, __arraycount(entropy));
31 char *p = RMD160End(&ctx, digest);
32 assert(p == digest);
34 printf("test2: '%s'\n", digest);
37 void test3() {
38 RMD160_CTX ctx;
39 uint8_t entropy[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
41 RMD160Init(&ctx);
42 RMD160Update(&ctx, entropy, __arraycount(entropy));
43 char *p = RMD160End(&ctx, NULL);
44 assert(strlen(p) == RMD160_DIGEST_STRING_LENGTH - 1);
46 printf("test3: '%s'\n", p);
48 free(p);
51 void test4() {
52 char digest[RMD160_DIGEST_STRING_LENGTH];
54 char *p = RMD160File("/etc/fstab", digest);
55 assert(p == digest);
57 printf("test4: '%s'\n", p);
60 void test5() {
61 char *p = RMD160File("/etc/fstab", NULL);
62 assert(strlen(p) == RMD160_DIGEST_STRING_LENGTH - 1);
64 printf("test5: '%s'\n", p);
66 free(p);
69 void test6() {
70 char digest[RMD160_DIGEST_STRING_LENGTH];
72 char *p = RMD160FileChunk("/etc/fstab", digest, 10, 20);
73 assert(p == digest);
75 printf("test6: '%s'\n", p);
78 void test7() {
79 char *p = RMD160FileChunk("/etc/fstab", NULL, 10, 20);
80 assert(strlen(p) == RMD160_DIGEST_STRING_LENGTH - 1);
82 printf("test7: '%s'\n", p);
84 free(p);
87 void test8() {
88 uint8_t entropy[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
89 char digest[RMD160_DIGEST_STRING_LENGTH];
91 char *p = RMD160Data(entropy, __arraycount(entropy), digest);
92 assert(p == digest);
94 printf("test8: '%s'\n", p);
97 void test9() {
98 uint8_t entropy[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
100 char *p = RMD160Data(entropy, __arraycount(entropy), NULL);
101 assert(strlen(p) == RMD160_DIGEST_STRING_LENGTH - 1);
103 printf("test9: '%s'\n", p);
105 free(p);
108 int main(void) {
109 printf("RMD160\n");
111 test1();
112 test2();
113 test3();
114 test4();
115 test5();
116 test6();
117 test7();
118 test8();
119 test9();
121 // CHECK: RMD160
122 // CHECK: test1: '2787e5a006365df6e8e799315b669dc34866783c'
123 // CHECK: test2: '2787e5a006365df6e8e799315b669dc34866783c'
124 // CHECK: test3: '2787e5a006365df6e8e799315b669dc34866783c'
125 // CHECK: test4: '{{.*}}'
126 // CHECK: test5: '{{.*}}'
127 // CHECK: test6: '{{.*}}'
128 // CHECK: test7: '{{.*}}'
129 // CHECK: test8: '2787e5a006365df6e8e799315b669dc34866783c'
130 // CHECK: test9: '2787e5a006365df6e8e799315b669dc34866783c'
132 return 0;