MCPcopy Create free account
hub / github.com/F-Stack/f-stack / main

Function main

freebsd/kern/subr_unit.c:1013–1086  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1011}
1012
1013int
1014main(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);

Callers

nothing calls this directly

Calls 15

strtolFunction · 0.85
new_unrhdrFunction · 0.85
print_unrhdrFunction · 0.85
callocFunction · 0.85
arc4random_uniformFunction · 0.85
test_alloc_unrFunction · 0.85
test_alloc_unr_specificFunction · 0.85
check_unrhdrFunction · 0.85
free_unrFunction · 0.85
delete_unrhdrFunction · 0.85
usageFunction · 0.70
printfFunction · 0.70

Tested by

no test coverage detected