]> git.proxmox.com Git - mirror_lxcfs.git/blob - tests/cpusetrange.c
tests: Fix lxcfs path
[mirror_lxcfs.git] / tests / cpusetrange.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #ifndef _GNU_SOURCE
4 #define _GNU_SOURCE
5 #endif
6
7 #ifndef FUSE_USE_VERSION
8 #define FUSE_USE_VERSION 26
9 #endif
10
11 #define _FILE_OFFSET_BITS 64
12
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdbool.h>
16 #include <stdlib.h>
17
18 #include "../src/cpuset_parse.h"
19
20 static void verify(bool condition) {
21 if (condition) {
22 printf(" PASS\n");
23 } else {
24 printf(" FAIL!\n");
25 exit(1);
26 }
27 }
28
29 int main() {
30 char *a = "1,2";
31 char *b = "1-3,5";
32 char *c = "1,4-5";
33 char *d = "";
34 char *e = "\n";
35
36 printf("1 in %s", a);
37 verify(cpu_in_cpuset(1, a));
38 printf("2 in %s", a);
39 verify(cpu_in_cpuset(2, a));
40 printf("NOT 4 in %s", a);
41 verify(!cpu_in_cpuset(4, a));
42 printf("1 in %s", b);
43 verify(cpu_in_cpuset(1, b));
44 printf("NOT 4 in %s", b);
45 verify(!cpu_in_cpuset(4, b));
46 printf("5 in %s", b);
47 verify(cpu_in_cpuset(5, b));
48 printf("1 in %s", c);
49 verify(cpu_in_cpuset(1, c));
50 printf("5 in %s", c);
51 verify(cpu_in_cpuset(5, c));
52 printf("NOT 6 in %s", c);
53 verify(!cpu_in_cpuset(6, c));
54 printf("NOT 6 in empty set");
55 verify(!cpu_in_cpuset(6, d));
56 printf("NOT 6 in empty set(2)");
57 verify(!cpu_in_cpuset(6, e));
58 }