]> git.proxmox.com Git - mirror_lxcfs.git/blame - tests/cpusetrange.c
Merge pull request #558 from tych0/cpu-num-proc-stat
[mirror_lxcfs.git] / tests / cpusetrange.c
CommitLineData
db0463bf 1/* SPDX-License-Identifier: LGPL-2.1+ */
1f5596dd 2
625e698a 3#include "config.h"
1f5596dd 4
fa47bb52
SH
5#include <stdio.h>
6#include <string.h>
7#include <stdbool.h>
8#include <stdlib.h>
9
e842d86c 10#include "../src/cpuset_parse.h"
fa47bb52 11
1f5596dd 12static void verify(bool condition) {
fa47bb52
SH
13 if (condition) {
14 printf(" PASS\n");
15 } else {
16 printf(" FAIL!\n");
17 exit(1);
18 }
19}
20
51816c7b 21int main(void) {
fa47bb52
SH
22 char *a = "1,2";
23 char *b = "1-3,5";
24 char *c = "1,4-5";
25 char *d = "";
26 char *e = "\n";
27
28 printf("1 in %s", a);
29 verify(cpu_in_cpuset(1, a));
30 printf("2 in %s", a);
31 verify(cpu_in_cpuset(2, a));
32 printf("NOT 4 in %s", a);
33 verify(!cpu_in_cpuset(4, a));
34 printf("1 in %s", b);
35 verify(cpu_in_cpuset(1, b));
36 printf("NOT 4 in %s", b);
37 verify(!cpu_in_cpuset(4, b));
38 printf("5 in %s", b);
39 verify(cpu_in_cpuset(5, b));
40 printf("1 in %s", c);
41 verify(cpu_in_cpuset(1, c));
42 printf("5 in %s", c);
43 verify(cpu_in_cpuset(5, c));
44 printf("NOT 6 in %s", c);
45 verify(!cpu_in_cpuset(6, c));
46 printf("NOT 6 in empty set");
47 verify(!cpu_in_cpuset(6, d));
48 printf("NOT 6 in empty set(2)");
49 verify(!cpu_in_cpuset(6, e));
50}