]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test-job-type.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
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.
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.
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/>.
29 int main(int argc
, char*argv
[]) {
30 JobType a
, b
, c
, d
, e
, f
, g
;
32 for (a
= 0; a
< _JOB_TYPE_MAX
; a
++)
33 for (b
= 0; b
< _JOB_TYPE_MAX
; b
++) {
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
));
38 for (c
= 0; c
< _JOB_TYPE_MAX
; c
++) {
40 /* Verify transitivity of mergeability
42 assert(!job_type_is_mergeable(a
, b
) ||
43 !job_type_is_mergeable(b
, c
) ||
44 job_type_is_mergeable(a
, c
));
47 if (job_type_merge(&d
, b
) >= 0) {
49 printf("%s + %s = %s\n", job_type_to_string(a
), job_type_to_string(b
), job_type_to_string(d
));
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
));
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
));
64 if (job_type_merge(&e
, c
) >= 0) {
66 /* Verify associativity */
69 assert(job_type_merge(&f
, c
) == 0);
72 assert(job_type_merge(&g
, a
) == 0);
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
));