1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
3 // UNSUPPORTED: target={{.*(linux|solaris).*}}
10 void print_buf(unsigned char *buf
, size_t buflen
) {
12 for (auto i
= 0; i
< buflen
; i
++)
13 printf("%" PRIx8
, buf
[i
]);
19 time_t now
= ::time(nullptr);
20 arc4random_addrandom((unsigned char *)&now
, sizeof(now
));
24 void test_arc4random() {
25 printf("test_arc4random\n");
26 auto i
= arc4random();
27 print_buf((unsigned char *)&i
, sizeof(i
));
30 void test_arc4random_uniform() {
31 printf("test_arc4random_uniform\n");
32 auto i
= arc4random_uniform(1024);
33 print_buf((unsigned char *)&i
, sizeof(i
));
36 void test_arc4random_buf10() {
37 printf("test_arc4random_buf10\n");
42 arc4random_buf(buf
, sizeof(buf
));
43 print_buf((unsigned char *)buf
, sizeof(buf
));
46 void test_arc4random_buf256() {
47 printf("test_arc4random_buf256\n");
52 arc4random_buf(buf
, sizeof(buf
));
53 print_buf((unsigned char *)buf
, sizeof(buf
));
59 test_arc4random_uniform();
60 test_arc4random_buf10();
61 test_arc4random_buf256();
63 // CHECK: test_arc4random
64 // CHECK: buf '{{.*}}'
65 // CHECK: test_arc4random_uniform
66 // CHECK: buf '{{.*}}'
67 // CHECK: test_arc4random_buf10
68 // CHECK: buf '{{.*}}'
69 // CHECK: test_arc4random_buf256
70 // CHECK: buf '{{.*}}'