]> git.ipfire.org Git - people/ms/systemd.git/blob - test-job-type.c
Remove .h files from _SOURCES
[people/ms/systemd.git] / test-job-type.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <stdio.h>
23 #include <errno.h>
24 #include <string.h>
25 #include <unistd.h>
26
27 #include "job.h"
28
29 int main(int argc, char*argv[]) {
30 JobType a, b, c, d, e, f, g;
31
32 for (a = 0; a < _JOB_TYPE_MAX; a++)
33 for (b = 0; b < _JOB_TYPE_MAX; b++) {
34
35 if (!job_type_is_mergeable(a, b))
36 printf("Not mergeable: %s + %s\n", job_type_to_string(a), job_type_to_string(b));
37
38 for (c = 0; c < _JOB_TYPE_MAX; c++) {
39
40 /* Verify transitivity of mergeability
41 * of job types */
42 assert(!job_type_is_mergeable(a, b) ||
43 !job_type_is_mergeable(b, c) ||
44 job_type_is_mergeable(a, c));
45
46 d = a;
47 if (job_type_merge(&d, b) >= 0) {
48
49 printf("%s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(d));
50
51 /* Verify that merged entries can be
52 * merged with the same entries they
53 * can be merged with seperately */
54 assert(!job_type_is_mergeable(a, c) || job_type_is_mergeable(d, c));
55 assert(!job_type_is_mergeable(b, c) || job_type_is_mergeable(d, c));
56
57 /* Verify that if a merged
58 * with b is not mergable with
59 * c then either a or b is not
60 * mergeable with c either. */
61 assert(job_type_is_mergeable(d, c) || !job_type_is_mergeable(a, c) || !job_type_is_mergeable(b, c));
62
63 e = b;
64 if (job_type_merge(&e, c) >= 0) {
65
66 /* Verify associativity */
67
68 f = d;
69 assert(job_type_merge(&f, c) == 0);
70
71 g = e;
72 assert(job_type_merge(&g, a) == 0);
73
74 assert(f == g);
75
76 printf("%s + %s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(c), job_type_to_string(d));
77 }
78 }
79 }
80 }
81
82
83 return 0;
84 }