1#include <sched.h>
2#include <stdio.h>
3#include <sys/param.h>
4
5static int
6do_test (void)
7{
8 cpu_set_t c;
9
10 CPU_ZERO (&c);
11
12 for (int cnt = 0; cnt < MIN (CPU_SETSIZE, 130); ++cnt)
13 {
14 int n = CPU_COUNT (&c);
15 if (n != cnt)
16 {
17 printf (format: "expected %d, not %d\n", cnt, n);
18 return 1;
19 }
20
21 CPU_SET (cnt, &c);
22 }
23
24 return 0;
25}
26
27#define TEST_FUNCTION do_test ()
28#include "../test-skeleton.c"
29

source code of glibc/posix/tst-cpucount.c