1body common control
2{
3      inputs => { "../../default.cf.sub" };
4      bundlesequence  => { default("$(this.promise_filename)") };
5      version => "1.0";
6}
7
8bundle agent test
9{
10  meta:
11
12      "description"
13        string => "Test that variable class expressions and the if alias work together as expected.",
14        meta => { "CFE-2615" };
15
16  vars:
17      "x" string => "x";
18
19  classes:
20      "DEBUG" expression => "any";
21      "one$(x)" expression => "any";
22
23      # These expressions are here purely for illustration. The classes two and
24      # three are never set.
25
26      "two" expression => "!any";
27      "three" expression => "!any";
28
29 # Here, after the variable class expression "one$(x)":: is where all of the
30 # test cases are described.
31
32    "one$(x)"::
33
34      "FAIL_if"
35        expression => "any",
36        meta => { "failtest" },
37        if => "two|three",
38        comment => "We expect the class 'onex' to be defined, but since neither
39                   'two' nor 'three' are defined this class should not be set.
40                   This seems to have something to do with the combination of a
41                   variable class expression AND the use of the if attribute.
42                   Note, ifvarclass does not seem to be affected.";
43
44      "FAIL_ifvarclass"
45        expression => "any",
46        meta => { "failtest" },
47        ifvarclass => "two|three";
48
49      "FAIL_if_or"
50        expression => "any",
51        meta => { "failtest" },
52        if => or("two", "three");
53
54      "FAIL_ifvarclass_or"
55        expression => "any",
56        meta => { "failtest" },
57        ifvarclass => or("two", "three");
58
59      "FAIL_unless"
60        expression => "any",
61        meta => { "failtest" },
62        unless => "!two.!three";
63
64      "FAIL_unless_not"
65        expression => "any",
66        meta => { "failtest" },
67        unless => not("two|three");
68
69  vars:
70     "FAIL_classes" slist => classesmatching( ".*", "failtest" );
71
72  commands:
73
74     "/bin/true"
75       handle => "delay",
76       comment => "This is a benign promise that is used to delay detection of
77                   failure classes until after normal order begins.";
78
79  classes:
80     "no_FAIL_classes"
81       expression => none(".*", FAIL_classes),
82       depends_on => { "delay" };
83
84     "FAIL_classes"
85       expression => some(".*", FAIL_classes);
86
87
88  reports:
89    DEBUG|EXTRA::
90      "CFEngine $(sys.cf_version)";
91      "Found class indicating failure '$(FAIL_classes)'";
92
93    FAIL_classes::
94      "$(this.promise_filename) FAIL";
95
96    no_FAIL_classes::
97      "$(this.promise_filename) Pass";
98}
99