1#######################################################
2#
3# Test packagesmatching() and that the env prefix is stripped
4#
5#######################################################
6
7body common control
8{
9      inputs => { "../../default.cf.sub" };
10      bundlesequence  => { default("$(this.promise_filename)") };
11      version => "1.0";
12}
13
14#######################################################
15
16bundle agent init
17{
18  packages:
19      "cfe-no-such-package"
20      package_policy => "add",
21      package_method => mock1;
22
23      "cfe-no-such-package"
24      package_policy => "add",
25      package_method => mock2;
26
27      # the parsing of env X="y z" fails
28
29      # "cfe-no-such-package"
30      # package_policy => "add",
31      # package_method => mock3;
32
33      "cfe-no-such-package"
34      package_policy => "add",
35      package_method => mock4;
36}
37
38body package_method mock1
39{
40      package_changes => "individual";
41
42      package_list_command => "$(G.printf) 'bfoobar-1-besm6'";
43      package_list_name_regex => "^([^-]+)";
44      package_list_version_regex => "^[^-]+-([^-]+)";
45      package_list_arch_regex => "^[^-]+-[^-]+-([\S]+)";
46
47      package_installed_regex => ".*";
48
49      package_add_command => "$(G.false)";
50      package_update_command => "$(G.false)";
51      package_delete_command => "$(G.false)";
52      package_verify_command => "$(G.false)";
53}
54
55body package_method mock2
56{
57      package_changes => "individual";
58
59      package_list_command => "/usr/bin/env $(G.printf) 'bfoobar-1-besm6'";
60      package_list_name_regex => "^([^-]+)";
61      package_list_version_regex => "^[^-]+-([^-]+)";
62      package_list_arch_regex => "^[^-]+-[^-]+-([\S]+)";
63
64      package_installed_regex => ".*";
65
66      package_add_command => "$(G.false)";
67      package_update_command => "$(G.false)";
68      package_delete_command => "$(G.false)";
69      package_verify_command => "$(G.false)";
70}
71
72body package_method mock3
73{
74      package_changes => "individual";
75
76      package_list_command => '/usr/bin/env X="y z" $(G.printf) "bfoobar-1-besm6"';
77      package_list_name_regex => "^([^-]+)";
78      package_list_version_regex => "^[^-]+-([^-]+)";
79      package_list_arch_regex => "^[^-]+-[^-]+-([\S]+)";
80
81      package_installed_regex => ".*";
82
83      package_add_command => "$(G.false)";
84      package_update_command => "$(G.false)";
85      package_delete_command => "$(G.false)";
86      package_verify_command => "$(G.false)";
87}
88
89body package_method mock4
90{
91      package_changes => "individual";
92
93      package_list_command => "/usr/bin/env X=Y $(G.printf) 'bfoobar-1-besm6'";
94      package_list_name_regex => "^([^-]+)";
95      package_list_version_regex => "^[^-]+-([^-]+)";
96      package_list_arch_regex => "^[^-]+-[^-]+-([\S]+)";
97
98      package_installed_regex => ".*";
99
100      package_add_command => "$(G.false)";
101      package_update_command => "$(G.false)";
102      package_delete_command => "$(G.false)";
103      package_verify_command => "$(G.false)";
104}
105
106#######################################################
107
108bundle agent test
109{
110  meta:
111      "test_suppress_fail" string => "windows",
112        meta => { "redmine4741" };
113
114  vars:
115      "all_packages" data => packagesmatching(".*", ".*", ".*", ".*");
116      "all_string" string => format("packages = %S", all_packages);
117}
118
119#######################################################
120
121bundle agent check
122{
123  vars:
124      "e" string => '{"arch":"besm6","method":"printf","name":"bfoobar","version":"1"}';
125  methods:
126      "" usebundle => dcs_check_strcmp($(test.all_string),
127                                       'packages = [$(e)]',
128                                       $(this.promise_filename),
129                                       "no");
130}
131