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