Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / freebsd / misc.c
blob13f16de57cc56367ff3ff9ab3872b783cf3b492d
1 /*
2 * Tests miscellaneous syscalls
4 * uuidgen
5 * genrandom
6 */
8 #include <sys/types.h>
9 #include <sys/uuid.h>
10 #include <sys/random.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include "../../../config.h"
14 #include "../../memcheck.h"
16 int main(void)
18 struct uuid s;
19 if (-1 == uuidgen(&s, 1))
21 perror("uuidgen failed:");
24 struct uuid v[10];
25 if (-1 == uuidgen(v, 10))
27 perror("uuidgen failed:");
30 #if defined(HAVE_GETRANDOM)
32 char buf[100];
33 if (-1 == getrandom(buf, 100, GRND_NONBLOCK))
35 perror("getrandom failed:");
38 #endif
40 // error section
41 struct uuid* ps = malloc(2*sizeof(struct uuid));
42 free(ps);
43 uuidgen(ps, 2);
45 int badint = 1;;
46 VALGRIND_MAKE_MEM_UNDEFINED(&badint, sizeof(int));
47 uuidgen(&s, badint);
49 #if defined(HAVE_GETRANDOM)
51 badint = 100;
52 VALGRIND_MAKE_MEM_UNDEFINED(&badint, sizeof(int));
53 getrandom(buf, badint, badint);
55 char* buf2 = malloc(100);
56 free(buf2);
58 getrandom(buf2, 100, 0);
60 #endif