1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#######################################################
#
# Test classesmatching()
#
#######################################################
body common control
{
inputs => { "../../default.cf.sub" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}
#######################################################
bundle agent init
{
vars:
"known" slist => { "cfengine", "cfengine_3", "agent", "any", $(dow), $(dow) };
"known_str" string => join(" ", "known");
Monday::
"dow" string => "Monday";
Tuesday::
"dow" string => "Tuesday";
Wednesday::
"dow" string => "Wednesday";
Thursday::
"dow" string => "Thursday";
Friday::
"dow" string => "Friday";
Saturday::
"dow" string => "Saturday";
Sunday::
"dow" string => "Sunday";
}
#######################################################
bundle agent test
{
vars:
"matched" slist => { classesmatching("^cfengine$"), # static string
# range of multiples
classesmatching("^cfengine_[0-9]$"),
# alternation/capture of single
classesmatching("^a(g)ent$"),
# range of single
classesmatching("^a[n]y$"),
# alternation of multiples
classesmatching("^(Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day$"),
# interpolation
classesmatching("^$(init.dow)$"),
};
"matched_str" string => join(" ", "matched");
}
#######################################################
bundle agent check
{
classes:
"ok" expression => strcmp($(init.known_str), $(test.matched_str));
reports:
ok::
"$(this.promise_filename) Pass";
!ok::
"$(this.promise_filename) FAIL";
DEBUG.!ok::
"$(this.promise_filename) expected '$(init.known_str)', got '$(test.matched_str)'";
}
|