• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "libcap.h"
2 
3 static cap_value_t top;
4 
cf(cap_value_t x)5 static int cf(cap_value_t x) {
6     return top - x - 1;
7 }
8 
test_cap_bits(void)9 static int test_cap_bits(void) {
10     static cap_value_t vs[] = {
11 	5, 6, 11, 12, 15, 16, 17, 38, 41, 63, 64, __CAP_MAXBITS+3, 0, -1
12     };
13     int failed = 0;
14     cap_value_t i;
15     for (i = 0; vs[i] >= 0; i++) {
16 	cap_value_t ans;
17 
18 	top = i;
19 	_binary_search(ans, cf, 0, __CAP_MAXBITS, 0);
20 	if (ans != top) {
21 	    if (top > __CAP_MAXBITS && ans == __CAP_MAXBITS) {
22 	    } else {
23 		printf("test_cap_bits miscompared [%d] top=%d - got=%d\n",
24 		       i, top, ans);
25 		failed = -1;
26 	    }
27 	}
28     }
29     return failed;
30 }
31 
main(int argc,char ** argv)32 int main(int argc, char **argv) {
33     int result = 0;
34     result = test_cap_bits() | result;
35     if (result) {
36 	printf("test FAILED\n");
37 	exit(1);
38     }
39 }
40