1#######################################################
2#
3# Test returnszero()
4#
5#######################################################
6
7body common control
8{
9      inputs => { "../../default.cf.sub" };
10      bundlesequence  => { default("$(this.promise_filename)") };
11      version => "1.0";
12}
13
14bundle common g
15{
16  vars:
17      "dummy" string => "dummy";
18}
19
20#######################################################
21
22bundle agent init
23{
24  vars:
25      "dummy" string => "dummy";
26}
27
28#######################################################
29
30bundle agent test
31{
32  vars:
33      "dummy" string => "dummy";
34}
35
36#######################################################
37
38bundle agent check
39{
40  vars:
41      "cwd" string => dirname("$(this.promise_filename)");
42
43    windows::
44      "zero_rel" string => "type $(cwd)$(const.dirsep)text.txt";
45      "one_rel" string => "type $(cwd)$(const.dirsep)text.txt.doesnotexist";
46      "nxe_rel" string => "nosuchprogramexists";
47      "zero_abs" string => "c:\windows\system32\cmd.exe /C type $(cwd)$(const.dirsep)text.txt";
48      "one_abs" string => "c:\windows\system32\cmd.exe /C type $(cwd)$(const.dirsep)text.txt.doesnotexist";
49      "nxe_abs" string => "c:\xbin\nosuchprogramexists";
50      "zero_powershell" string => "Get-Content $(cwd)$(const.dirsep)text.txt";
51      "one_powershell" string => "Get-Content $(cwd)$(const.dirsep)text.txt.doesnotexist";
52      "nxe_powershell" string => "nosuchprogramexists";
53    !windows::
54      "zero_rel" string => "cat $(cwd)$(const.dirsep)text.txt";
55      "one_rel" string => "cat $(cwd)$(const.dirsep)text.txt.doesnotexist";
56      "nxe_rel" string => "nosuchprogramexists";
57      "zero_abs" string => "/bin/cat $(cwd)$(const.dirsep)text.txt";
58      "one_abs" string => "/bin/cat $(cwd)$(const.dirsep)text.txt.doesnotexist";
59      "nxe_abs" string => "/xbin/nosuchprogramexists";
60
61  classes:
62      # Test whether we extracted the expected string.
63      "zero_noshell_rel" expression => regcmp(".*Succeeded.*", execresult("$(zero_rel)", "noshell"));
64      "zero_useshell_rel" expression => regcmp(".*Succeeded.*", execresult("$(zero_rel)", "useshell"));
65      "zero_noshell_abs" expression => regcmp(".*Succeeded.*", execresult("$(zero_abs)", "noshell"));
66      "zero_useshell_abs" expression => regcmp(".*Succeeded.*", execresult("$(zero_abs)", "useshell"));
67
68      "one_noshell_rel" expression => regcmp(".*Succeeded.*", execresult("$(one_rel)", "noshell"));
69      "one_useshell_rel" expression => regcmp(".*Succeeded.*", execresult("$(one_rel)", "useshell"));
70      "one_noshell_abs" expression => regcmp(".*Succeeded.*", execresult("$(one_abs)", "noshell"));
71      "one_useshell_abs" expression => regcmp(".*Succeeded.*", execresult("$(one_abs)", "useshell"));
72
73      "nxe_noshell_rel" expression => regcmp(".*Succeeded.*", execresult("$(nxe_rel)", "noshell"));
74      "nxe_useshell_rel" expression => regcmp(".*Succeeded.*", execresult("$(nxe_rel)", "useshell"));
75      "nxe_noshell_abs" expression => regcmp(".*Succeeded.*", execresult("$(nxe_abs)", "noshell"));
76      "nxe_useshell_abs" expression => regcmp(".*Succeeded.*", execresult("$(nxe_abs)", "useshell"));
77
78      # Test whether any assignment happens at all.
79      "does_assign_zero_noshell_rel" expression => regcmp(".*", execresult("$(zero_rel)", "noshell"));
80      "does_assign_zero_useshell_rel" expression => regcmp(".*", execresult("$(zero_rel)", "useshell"));
81      "does_assign_zero_noshell_abs" expression => regcmp(".*", execresult("$(zero_abs)", "noshell"));
82      "does_assign_zero_useshell_abs" expression => regcmp(".*", execresult("$(zero_abs)", "useshell"));
83
84      "does_assign_one_noshell_rel" expression => regcmp(".*", execresult("$(one_rel)", "noshell"));
85      "does_assign_one_useshell_rel" expression => regcmp(".*", execresult("$(one_rel)", "useshell"));
86      "does_assign_one_noshell_abs" expression => regcmp(".*", execresult("$(one_abs)", "noshell"));
87      "does_assign_one_useshell_abs" expression => regcmp(".*", execresult("$(one_abs)", "useshell"));
88
89      "does_assign_nxe_noshell_rel" expression => regcmp(".*", execresult("$(nxe_rel)", "noshell"));
90      "does_assign_nxe_useshell_rel" expression => regcmp(".*", execresult("$(nxe_rel)", "useshell"));
91      "does_assign_nxe_noshell_abs" expression => regcmp(".*", execresult("$(nxe_abs)", "noshell"));
92      "does_assign_nxe_useshell_abs" expression => regcmp(".*", execresult("$(nxe_abs)", "useshell"));
93
94    windows::
95      # Test whether we extracted the expected string.
96      "zero_powershell" expression => regcmp(".*Succeeded.*", execresult("$(zero_powershell)", "powershell"));
97      "one_powershell" expression => regcmp(".*Succeeded.*", execresult("$(one_powershell)", "powershell"));
98      "nxe_powershell" expression => regcmp(".*Succeeded.*", execresult("$(nxe_powershell)", "powershell"));
99
100      # Test whether any assignment happens at all.
101      "does_assign_zero_powershell" expression => regcmp(".*", execresult("$(zero_powershell)", "powershell"));
102      "does_assign_one_powershell" expression => regcmp(".*", execresult("$(one_powershell)", "powershell"));
103      "does_assign_nxe_powershell" expression => regcmp(".*", execresult("$(nxe_powershell)", "powershell"));
104
105    any::
106      "ok_common" and => {
107			   "!zero_noshell_rel", "zero_useshell_rel", "zero_noshell_abs", "zero_useshell_abs",
108			   "!one_noshell_rel", "!one_useshell_rel", "!one_noshell_abs", "!one_useshell_abs",
109			   "!nxe_noshell_rel", "!nxe_useshell_rel", "!nxe_noshell_abs", "!nxe_useshell_abs",
110			   "!does_assign_zero_noshell_rel", "does_assign_zero_useshell_rel", "does_assign_zero_noshell_abs", "does_assign_zero_useshell_abs",
111			   "!does_assign_one_noshell_rel", "does_assign_one_useshell_rel", "does_assign_one_noshell_abs", "does_assign_one_useshell_abs",
112			   "!does_assign_nxe_noshell_rel", "does_assign_nxe_useshell_rel", "!does_assign_nxe_noshell_abs", "!does_assign_nxe_useshell_abs",
113      };
114    windows::
115      "ok_windows" and => {
116			    "zero_powershell", "!one_powershell", "!nxe_powershell",
117			    "does_assign_zero_powershell", "does_assign_one_powershell", "does_assign_nxe_powershell",
118      };
119      "ok" and => {
120                    "ok_common", "ok_windows",
121      };
122
123    !windows::
124      "ok" and => { "ok_common" };
125
126  reports:
127    DEBUG.zero_noshell_rel::
128      "'$(zero_rel)' executes command successfully with noshell";
129
130    DEBUG.!zero_useshell_rel::
131      "'$(zero_rel)' executes command unsuccessfully with useshell";
132
133
134    DEBUG.one_noshell_rel::
135      "'$(one_rel)' executes command successfully with noshell";
136
137    DEBUG.one_useshell_rel::
138      "'$(one_rel)' executes command successfully with useshell";
139
140
141    DEBUG.nxe_noshell_rel::
142      "'$(nxe_rel)' executes command successfully with noshell";
143
144    DEBUG.nxe_useshell_rel::
145      "'$(nxe_rel)' executes command successfully with useshell";
146
147    DEBUG.!zero_noshell_abs::
148      "'$(zero_abs)' executes command unsuccessfully with noshell";
149
150    DEBUG.!zero_useshell_abs::
151      "'$(zero_abs)' executes command unsuccessfully with useshell";
152
153
154    DEBUG.one_noshell_abs::
155      "'$(one_abs)' executes command successfully with noshell";
156
157    DEBUG.one_useshell_abs::
158      "'$(one_abs)' executes command successfully with useshell";
159
160
161    DEBUG.nxe_noshell_abs::
162      "'$(nxe_abs)' executes command successfully with noshell";
163
164    DEBUG.nxe_useshell_abs::
165      "'$(nxe_abs)' executes command successfully with useshell";
166
167
168    DEBUG.does_assign_zero_noshell_rel::
169      "'$(zero_rel)' executes command with noshell";
170
171    DEBUG.!does_assign_zero_useshell_rel::
172      "'$(zero_rel)' does not execute command with useshell";
173
174
175    DEBUG.does_assign_one_noshell_rel::
176      "'$(one_rel)' executes command with noshell";
177
178    DEBUG.!does_assign_one_useshell_rel::
179      "'$(one_rel)' does not execute command with useshell";
180
181
182    DEBUG.does_assign_nxe_noshell_rel::
183      "'$(nxe_rel)' executes command with noshell";
184
185    DEBUG.!does_assign_nxe_useshell_rel::
186      "'$(nxe_rel)' does not execute command with useshell";
187
188    DEBUG.!does_assign_zero_noshell_abs::
189      "'$(zero_abs)' does not execute command with noshell";
190
191    DEBUG.!does_assign_zero_useshell_abs::
192      "'$(zero_abs)' does not execute command with useshell";
193
194
195    DEBUG.!does_assign_one_noshell_abs::
196      "'$(one_abs)' does not execute command with noshell";
197
198    DEBUG.!does_assign_one_useshell_abs::
199      "'$(one_abs)' does not execute command with useshell";
200
201
202    DEBUG.does_assign_nxe_noshell_abs::
203      "'$(nxe_abs)' executes command with noshell";
204
205    DEBUG.does_assign_nxe_useshell_abs::
206      "'$(nxe_abs)' executes command with useshell";
207
208    windows.DEBUG.!zero_powershell::
209      "'$(zero_powershell)' executes command unsuccessfully with powershell";
210
211    windows.DEBUG.one_powershell::
212      "'$(one_powershell)' executes command successfully with powershell";
213
214    windows.DEBUG.nxe_powershell::
215      "'$(nxe_powershell)' executes command successfully with powershell";
216
217    windows.DEBUG.!does_assign_zero_powershell::
218      "'$(zero_powershell)' does not execute command with powershell";
219
220    windows.DEBUG.!does_assign_one_powershell::
221      "'$(one_powershell)' does not execute command with powershell";
222
223    windows.DEBUG.!does_assign_nxe_powershell::
224      "'$(nxe_powershell)' does not execute command with powershell";
225
226    ok::
227      "$(this.promise_filename) Pass";
228    !ok::
229      "$(this.promise_filename) FAIL";
230}
231