Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / NetBSD / md4.cpp
bloba319e89a3519f1afbc5ebdbf9500a1cd95c92618
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
3 #include <sys/param.h>
5 #include <assert.h>
6 #include <endian.h>
7 #include <md4.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
12 void test1() {
13 MD4_CTX ctx;
14 uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
15 uint8_t digest[MD4_DIGEST_LENGTH];
17 MD4Init(&ctx);
18 MD4Update(&ctx, entropy, __arraycount(entropy));
19 MD4Final(digest, &ctx);
21 printf("test1: '");
22 for (size_t i = 0; i < __arraycount(digest); i++)
23 printf("%02x", digest[i]);
24 printf("'\n");
27 void test2() {
28 MD4_CTX ctx;
29 uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
30 char digest[MD4_DIGEST_STRING_LENGTH];
32 MD4Init(&ctx);
33 MD4Update(&ctx, entropy, __arraycount(entropy));
34 char *p = MD4End(&ctx, digest);
35 assert(p == digest);
37 printf("test2: '%s'\n", digest);
40 void test3() {
41 MD4_CTX ctx;
42 uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
44 MD4Init(&ctx);
45 MD4Update(&ctx, entropy, __arraycount(entropy));
46 char *p = MD4End(&ctx, NULL);
47 assert(strlen(p) == MD4_DIGEST_STRING_LENGTH - 1);
49 printf("test3: '%s'\n", p);
51 free(p);
54 void test4() {
55 char digest[MD4_DIGEST_STRING_LENGTH];
57 char *p = MD4File("/etc/fstab", digest);
58 assert(p == digest);
60 printf("test4: '%s'\n", p);
63 void test5() {
64 char *p = MD4File("/etc/fstab", NULL);
65 assert(strlen(p) == MD4_DIGEST_STRING_LENGTH - 1);
67 printf("test5: '%s'\n", p);
69 free(p);
72 void test6() {
73 uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
74 char digest[MD4_DIGEST_STRING_LENGTH];
76 char *p = MD4Data(entropy, __arraycount(entropy), digest);
77 assert(p == digest);
79 printf("test6: '%s'\n", p);
82 void test7() {
83 uint8_t entropy[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
85 char *p = MD4Data(entropy, __arraycount(entropy), NULL);
86 assert(strlen(p) == MD4_DIGEST_STRING_LENGTH - 1);
88 printf("test7: '%s'\n", p);
90 free(p);
93 int main(void) {
94 printf("MD4\n");
96 test1();
97 test2();
98 test3();
99 test4();
100 test5();
101 test6();
102 test7();
104 // CHECK: MD4
105 // CHECK: test1: 'bf78fda2ca35eb7a026bfcdd3d17283d'
106 // CHECK: test2: 'bf78fda2ca35eb7a026bfcdd3d17283d'
107 // CHECK: test3: 'bf78fda2ca35eb7a026bfcdd3d17283d'
108 // CHECK: test4: '{{.*}}'
109 // CHECK: test5: '{{.*}}'
110 // CHECK: test6: 'bf78fda2ca35eb7a026bfcdd3d17283d'
111 // CHECK: test7: 'bf78fda2ca35eb7a026bfcdd3d17283d'
113 return 0;