File: tst-cpuset.c

package info (click to toggle)
glibc 2.28-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, experimental, sid
  • size: 271,788 kB
  • sloc: ansic: 1,008,637; asm: 259,607; makefile: 11,271; sh: 10,477; python: 6,910; cpp: 4,992; perl: 2,258; awk: 2,005; yacc: 290; pascal: 182; sed: 73
file content (82 lines) | stat: -rw-r--r-- 1,501 bytes parent folder | download | duplicates (25)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <sched.h>
#include <stdio.h>

static int
do_test (void)
{
  int result = 0;

  cpu_set_t s1;
  cpu_set_t s2;
  cpu_set_t s3;

  CPU_ZERO (&s1);
  CPU_SET (0, &s1);

  CPU_ZERO (&s2);
  CPU_SET (0, &s2);
  CPU_SET (1, &s2);

  CPU_AND (&s3, &s1, &s2);
  if (! CPU_EQUAL (&s3, &s1))
    {
      puts ("result of CPU_AND wrong");
      result = 1;
    }

  CPU_OR (&s3, &s1, &s2);
  if (! CPU_EQUAL (&s3, &s2))
    {
      puts ("result of CPU_OR wrong");
      result = 1;
    }

  CPU_XOR (&s3, &s1, &s2);
  if (CPU_COUNT (&s3) != 1)
    {
      puts ("result of CPU_XOR wrong");
      result = 1;
    }

  cpu_set_t *vs1 = CPU_ALLOC (2048);
  cpu_set_t *vs2 = CPU_ALLOC (2048);
  cpu_set_t *vs3 = CPU_ALLOC (2048);
  size_t vssize = CPU_ALLOC_SIZE (2048);

  CPU_ZERO_S (vssize, vs1);
  CPU_SET_S (0, vssize, vs1);

  CPU_ZERO_S (vssize, vs2);
  CPU_SET_S (0, vssize, vs2);
  CPU_SET_S (2047, vssize, vs2);

  CPU_AND_S (vssize, vs3, vs1, vs2);
  if (! CPU_EQUAL_S (vssize, vs3, vs1))
    {
      puts ("result of CPU_AND_S wrong");
      result = 1;
    }

  CPU_OR_S (vssize, vs3, vs1, vs2);
  if (! CPU_EQUAL_S (vssize, vs3, vs2))
    {
      puts ("result of CPU_OR_S wrong");
      result = 1;
    }

  CPU_XOR_S (vssize, vs3, vs1, vs2);
  if (CPU_COUNT_S (vssize, vs3) != 1)
    {
      puts ("result of CPU_XOR_S wrong");
      result = 1;
    }

  CPU_FREE (vs1);
  CPU_FREE (vs2);
  CPU_FREE (vs3);

  return result;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"