lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <sched.h> |
| 2 | #include <stdio.h> |
| 3 | |
| 4 | static int |
| 5 | do_test (void) |
| 6 | { |
| 7 | int result = 0; |
| 8 | |
| 9 | cpu_set_t s1; |
| 10 | cpu_set_t s2; |
| 11 | cpu_set_t s3; |
| 12 | |
| 13 | CPU_ZERO (&s1); |
| 14 | CPU_SET (0, &s1); |
| 15 | |
| 16 | CPU_ZERO (&s2); |
| 17 | CPU_SET (0, &s2); |
| 18 | CPU_SET (1, &s2); |
| 19 | |
| 20 | CPU_AND (&s3, &s1, &s2); |
| 21 | if (! CPU_EQUAL (&s3, &s1)) |
| 22 | { |
| 23 | puts ("result of CPU_AND wrong"); |
| 24 | result = 1; |
| 25 | } |
| 26 | |
| 27 | CPU_OR (&s3, &s1, &s2); |
| 28 | if (! CPU_EQUAL (&s3, &s2)) |
| 29 | { |
| 30 | puts ("result of CPU_OR wrong"); |
| 31 | result = 1; |
| 32 | } |
| 33 | |
| 34 | CPU_XOR (&s3, &s1, &s2); |
| 35 | if (CPU_COUNT (&s3) != 1) |
| 36 | { |
| 37 | puts ("result of CPU_XOR wrong"); |
| 38 | result = 1; |
| 39 | } |
| 40 | |
| 41 | cpu_set_t *vs1 = CPU_ALLOC (2048); |
| 42 | cpu_set_t *vs2 = CPU_ALLOC (2048); |
| 43 | cpu_set_t *vs3 = CPU_ALLOC (2048); |
| 44 | size_t vssize = CPU_ALLOC_SIZE (2048); |
| 45 | |
| 46 | CPU_ZERO_S (vssize, vs1); |
| 47 | CPU_SET_S (0, vssize, vs1); |
| 48 | |
| 49 | CPU_ZERO_S (vssize, vs2); |
| 50 | CPU_SET_S (0, vssize, vs2); |
| 51 | CPU_SET_S (2047, vssize, vs2); |
| 52 | |
| 53 | CPU_AND_S (vssize, vs3, vs1, vs2); |
| 54 | if (! CPU_EQUAL_S (vssize, vs3, vs1)) |
| 55 | { |
| 56 | puts ("result of CPU_AND_S wrong"); |
| 57 | result = 1; |
| 58 | } |
| 59 | |
| 60 | CPU_OR_S (vssize, vs3, vs1, vs2); |
| 61 | if (! CPU_EQUAL_S (vssize, vs3, vs2)) |
| 62 | { |
| 63 | puts ("result of CPU_OR_S wrong"); |
| 64 | result = 1; |
| 65 | } |
| 66 | |
| 67 | CPU_XOR_S (vssize, vs3, vs1, vs2); |
| 68 | if (CPU_COUNT_S (vssize, vs3) != 1) |
| 69 | { |
| 70 | puts ("result of CPU_XOR_S wrong"); |
| 71 | result = 1; |
| 72 | } |
| 73 | |
| 74 | CPU_FREE (vs1); |
| 75 | CPU_FREE (vs2); |
| 76 | CPU_FREE (vs3); |
| 77 | |
| 78 | return result; |
| 79 | } |
| 80 | |
| 81 | #define TEST_FUNCTION do_test () |
| 82 | #include "../test-skeleton.c" |