| 1011 | } |
| 1012 | |
| 1013 | int |
| 1014 | main(int argc, char **argv) |
| 1015 | { |
| 1016 | struct unrhdr *uh; |
| 1017 | char *a; |
| 1018 | long count = 10000; /* Number of unrs to test */ |
| 1019 | long reps = 1, m; |
| 1020 | int ch; |
| 1021 | u_int i; |
| 1022 | |
| 1023 | verbose = false; |
| 1024 | |
| 1025 | while ((ch = getopt(argc, argv, "hr:v")) != -1) { |
| 1026 | switch (ch) { |
| 1027 | case 'r': |
| 1028 | errno = 0; |
| 1029 | reps = strtol(optarg, NULL, 0); |
| 1030 | if (errno == ERANGE || errno == EINVAL) { |
| 1031 | usage(argv); |
| 1032 | exit(2); |
| 1033 | } |
| 1034 | |
| 1035 | break; |
| 1036 | case 'v': |
| 1037 | verbose = true; |
| 1038 | break; |
| 1039 | case 'h': |
| 1040 | default: |
| 1041 | usage(argv); |
| 1042 | exit(2); |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | setbuf(stdout, NULL); |
| 1047 | uh = new_unrhdr(0, count - 1, NULL); |
| 1048 | print_unrhdr(uh); |
| 1049 | |
| 1050 | a = calloc(count, sizeof(char)); |
| 1051 | if (a == NULL) |
| 1052 | err(1, "calloc failed"); |
| 1053 | |
| 1054 | printf("sizeof(struct unr) %zu\n", sizeof(struct unr)); |
| 1055 | printf("sizeof(struct unrb) %zu\n", sizeof(struct unrb)); |
| 1056 | printf("sizeof(struct unrhdr) %zu\n", sizeof(struct unrhdr)); |
| 1057 | printf("NBITS %lu\n", (unsigned long)NBITS); |
| 1058 | for (m = 0; m < count * reps; m++) { |
| 1059 | i = arc4random_uniform(count); |
| 1060 | #if 0 |
| 1061 | if (a[i] && (j & 1)) |
| 1062 | continue; |
| 1063 | #endif |
| 1064 | if ((arc4random() & 1) != 0) |
| 1065 | test_alloc_unr(uh, i, a); |
| 1066 | else |
| 1067 | test_alloc_unr_specific(uh, i, a); |
| 1068 | |
| 1069 | if (verbose) |
| 1070 | print_unrhdr(uh); |
nothing calls this directly
no test coverage detected