Back to index

glibc  2.9
tst-cpuset.c
Go to the documentation of this file.
00001 #include <sched.h>
00002 #include <stdio.h>
00003 
00004 static int
00005 do_test (void)
00006 {
00007   int result = 0;
00008 
00009   cpu_set_t s1;
00010   cpu_set_t s2;
00011   cpu_set_t s3;
00012 
00013   CPU_ZERO (&s1);
00014   CPU_SET (0, &s1);
00015 
00016   CPU_ZERO (&s2);
00017   CPU_SET (0, &s2);
00018   CPU_SET (1, &s2);
00019 
00020   CPU_AND (&s3, &s1, &s2);
00021   if (! CPU_EQUAL (&s3, &s1))
00022     {
00023       puts ("result of CPU_AND wrong");
00024       result = 1;
00025     }
00026 
00027   CPU_OR (&s3, &s1, &s2);
00028   if (! CPU_EQUAL (&s3, &s2))
00029     {
00030       puts ("result of CPU_OR wrong");
00031       result = 1;
00032     }
00033 
00034   CPU_XOR (&s3, &s1, &s2);
00035   if (CPU_COUNT (&s3) != 1)
00036     {
00037       puts ("result of CPU_XOR wrong");
00038       result = 1;
00039     }
00040 
00041   cpu_set_t *vs1 = CPU_ALLOC (2048);
00042   cpu_set_t *vs2 = CPU_ALLOC (2048);
00043   cpu_set_t *vs3 = CPU_ALLOC (2048);
00044   size_t vssize = CPU_ALLOC_SIZE (2048);
00045 
00046   CPU_ZERO_S (vssize, vs1);
00047   CPU_SET_S (0, vssize, vs1);
00048 
00049   CPU_ZERO_S (vssize, vs2);
00050   CPU_SET_S (0, vssize, vs2);
00051   CPU_SET_S (2047, vssize, vs2);
00052 
00053   CPU_AND_S (vssize, vs3, vs1, vs2);
00054   if (! CPU_EQUAL_S (vssize, vs3, vs1))
00055     {
00056       puts ("result of CPU_AND_S wrong");
00057       result = 1;
00058     }
00059 
00060   CPU_OR_S (vssize, vs3, vs1, vs2);
00061   if (! CPU_EQUAL_S (vssize, vs3, vs2))
00062     {
00063       puts ("result of CPU_OR_S wrong");
00064       result = 1;
00065     }
00066 
00067   CPU_XOR_S (vssize, vs3, vs1, vs2);
00068   if (CPU_COUNT_S (vssize, vs3) != 1)
00069     {
00070       puts ("result of CPU_XOR_S wrong");
00071       result = 1;
00072     }
00073 
00074   CPU_FREE (vs1);
00075   CPU_FREE (vs2);
00076   CPU_FREE (vs3);
00077 
00078   return result;
00079 }
00080 
00081 #define TEST_FUNCTION do_test ()
00082 #include "../test-skeleton.c"