]>
git.ipfire.org Git - thirdparty/systemd.git/blob - test-job-type.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
10 int main(int argc
, char*argv
[]) {
11 JobType a
, b
, c
, d
, e
, f
, g
;
13 for (a
= 0; a
< _JOB_TYPE_MAX
; a
++)
14 for (b
= 0; b
< _JOB_TYPE_MAX
; b
++) {
16 if (!job_type_is_mergeable(a
, b
))
17 printf("Not mergeable: %s + %s\n", job_type_to_string(a
), job_type_to_string(b
));
19 for (c
= 0; c
< _JOB_TYPE_MAX
; c
++) {
21 /* Verify transitivity of mergeability
23 assert(!job_type_is_mergeable(a
, b
) ||
24 !job_type_is_mergeable(b
, c
) ||
25 job_type_is_mergeable(a
, c
));
28 if (job_type_merge(&d
, b
) >= 0) {
30 printf("%s + %s = %s\n", job_type_to_string(a
), job_type_to_string(b
), job_type_to_string(d
));
32 /* Verify that merged entries can be
33 * merged with the same entries they
34 * can be merged with seperately */
35 assert(!job_type_is_mergeable(a
, c
) || job_type_is_mergeable(d
, c
));
36 assert(!job_type_is_mergeable(b
, c
) || job_type_is_mergeable(d
, c
));
38 /* Verify that if a merged
39 * with b is not mergable with
40 * c then either a or b is not
41 * mergeable with c either. */
42 assert(job_type_is_mergeable(d
, c
) || !job_type_is_mergeable(a
, c
) || !job_type_is_mergeable(b
, c
));
45 if (job_type_merge(&e
, c
) >= 0) {
47 /* Verify associativity */
50 assert(job_type_merge(&f
, c
) == 0);
53 assert(job_type_merge(&g
, a
) == 0);
57 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
));