Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions tests/acceptance/21_methods/array_reset.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
# Redmine 6369 - make sure that arrays don't accumulate
#
#######################################################

body common control
{
inputs => { "../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { "../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

bundle agent test
{
vars:
"key_value" slist => { 1, 2, 3 };
"key_value" slist => { 1, 2, 3 };

methods:
"in" usebundle => test_method($(key_value), $(key_value));
"in" usebundle => test_method($(key_value), $(key_value));
}

bundle agent test_method(key, value)
{
vars:
"array[$(key)]" string => "$(value)";
"array[$(key)]" string => "$(value)";
}

bundle agent check
{
vars:
"indices" slist => getindices("test_method.array");
"dim" int => length("indices");
"indices" slist => getindices("test_method.array");
"dim" int => length("indices");

classes:
"ok" expression => strcmp("$(dim)", "1");
"ok" expression => strcmp("$(dim)", "1");

reports:
ok::
"$(this.promise_filename) Pass";

!ok::
"$(this.promise_filename) FAIL";

Expand Down
56 changes: 25 additions & 31 deletions tests/acceptance/21_methods/call_methods_using_array_expansion.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
# Redmine 6369 - make sure that arrays don't accumulate
#
#######################################################

body common control
{
inputs => { "../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { "../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

bundle agent init
Expand All @@ -18,53 +17,48 @@ bundle agent init
"$(G.dos2unix) $(this.promise_filename).expected.txt" -> { "ENT-10433" };

files:
"$(G.testdir)/reports.txt"
delete => tidy;
"$(G.testdir)/reports.txt" delete => tidy;
}

bundle agent test
{
meta:

"description" -> { "CFE-636" }
string => "Check that methods can be called by expanding classic
"description" -> { "CFE-636" }
string => "Check that methods can be called by expanding classic
arrays";
Comment thread
olehermanse marked this conversation as resolved.

vars:

"b1" string => "b1";
"b2" string => "b2";
"b[b2]" string => "b2";
"b1" string => "b1";
"b2" string => "b2";
"b[b2]" string => "b2";

methods:

"${b1}"
usebundle => ${b1};
"${b[b2]}"
usebundle => ${b[b2]}("param");
"${b[b2]}"
usebundle => ${b[${b2}]}("param2");
"${b1}" usebundle => ${b1};
"${b[b2]}" usebundle => ${b[b2]}("param");
"${b[b2]}" usebundle => ${b[${b2}]}("param2");
}

bundle agent check
{
methods:

"Pass/Fail"
usebundle => dcs_check_diff( "$(G.testdir)/reports.txt",
"$(this.promise_filename).expected.txt",
$(this.promise_filename));
"Pass/Fail"
usebundle => dcs_check_diff(
"$(G.testdir)/reports.txt",
"$(this.promise_filename).expected.txt",
$(this.promise_filename)
);
}

bundle agent b1{
bundle agent b1
{
reports:
cfengine::
"Bundle b1"
report_to_file => "$(G.testdir)/reports.txt";
"Bundle b1" report_to_file => "$(G.testdir)/reports.txt";
}

bundle agent b2(ref){
bundle agent b2(ref)
{
reports:
cfengine::
"Bundle b2 ${ref}"
report_to_file => "$(G.testdir)/reports.txt";
"Bundle b2 ${ref}" report_to_file => "$(G.testdir)/reports.txt";
}
42 changes: 24 additions & 18 deletions tests/acceptance/21_methods/callers/callers_directly.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,63 @@
# Test the variable this.callers_promisers with one bundle
#
#######################################################

body common control
{
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

#######################################################

bundle agent init {
bundle agent init
{
}

bundle agent test {
bundle agent test
{
methods:
"test" usebundle => "caller";
}

bundle agent check {
bundle agent check
{
vars:
"callers_expect" string => "agent";
# Due to the 4K variable limit we cannot test the whole structure, so
# just test one element within it. At least it's not completely broken
# if we find it.
"callers_actual" string => "$(dummy.callers[0][bundle][bundleType])";
"callers_expect" string => "agent";

# Due to the 4K variable limit we cannot test the whole structure, so
# just test one element within it. At least it's not completely broken
# if we find it.
"callers_actual" string => "$(dummy.callers[0][bundle][bundleType])";

classes:
"success" expression => strcmp("${callers_expect}", "${callers_actual}"),
scope => "namespace";
"success"
expression => strcmp("${callers_expect}", "${callers_actual}"),
scope => "namespace";

reports:
success::
"$(this.promise_filename) Pass";

!success::
"$(this.promise_filename) FAIL";

methods:
"any" usebundle => file_make($(G.testfile), $(callers_actual));
"any" usebundle => file_make($(G.testfile), $(callers_actual));

reports:
DEBUG::
"EXPECT: callers_string = ${callers_expect}";
"ACTUAL: callers_string = $(callers_actual)";
}

bundle agent caller {
bundle agent caller
{
methods:
"first call" usebundle => dummy;
}

bundle agent dummy {
bundle agent dummy
{
vars:
"callers" data => callstack_callers();
}
30 changes: 18 additions & 12 deletions tests/acceptance/21_methods/callers/promisers_directly.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,52 @@
# Test the variable this.callers_promisers with one bundle
#
#######################################################

body common control
{
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

#######################################################

bundle agent init {
bundle agent init
{
}

bundle agent test {
bundle agent test
{
methods:
"test" usebundle => "caller";
}

bundle agent check {
bundle agent check
{
reports:
success::
"$(this.promise_filename) Pass";

!success::
"$(this.promise_filename) FAIL";
}

bundle agent caller {
bundle agent caller
{
methods:
"first call" usebundle => dummy;
}

bundle agent dummy {
bundle agent dummy
{
vars:
"callers_promisers" slist => callstack_promisers();

"callers_promisers_expect" string => "any, any, test, first call";
"callers_promisers_actual" string => join(", ", "callers_promisers");

classes:
"success" expression => strcmp("${callers_promisers_expect}", "${callers_promisers_actual}"),
"success"
expression => strcmp(
"${callers_promisers_expect}", "${callers_promisers_actual}"
),
scope => "namespace";

reports:
Expand Down
50 changes: 29 additions & 21 deletions tests/acceptance/21_methods/callers/promisers_indirectly.cf
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,76 @@
# Test the variable this.callers_promisers with one bundle called twice
#
#######################################################

body common control
{
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

#######################################################

bundle agent init {
bundle agent init
{
}

bundle agent test {
bundle agent test
{
methods:
"test" usebundle => "caller";
}

bundle agent check {
bundle agent check
{
reports:
success_first.success_second::
"$(this.promise_filename) Pass";

!(success_first.success_second)::
"$(this.promise_filename) FAIL";
}

bundle agent caller {

bundle agent caller
{
methods:
"first call" usebundle => dummy;
"second call" usebundle => dummy_inter;

}

bundle agent dummy_inter {

bundle agent dummy_inter
{
methods:
"inter" usebundle => dummy;

}

bundle agent dummy {

bundle agent dummy
{
vars:
# This bundle gets called twice, once directly, and once via dummy_inter
"callers_promisers" slist => callstack_promisers();

"callers_promisers_expect_first" string => "any, any, test, first call";
"callers_promisers_expect_second" string => "any, any, test, second call, inter";

"callers_promisers_expect_second"
string => "any, any, test, second call, inter";

"callers_promisers_actual" string => join(", ", "callers_promisers");

classes:
"success_first" expression => strcmp("${callers_promisers_expect_first}", "${callers_promisers_actual}"),
"success_first"
expression => strcmp(
"${callers_promisers_expect_first}", "${callers_promisers_actual}"
),
scope => "namespace";
"success_second" expression => strcmp("${callers_promisers_expect_second}", "${callers_promisers_actual}"),

"success_second"
expression => strcmp(
"${callers_promisers_expect_second}", "${callers_promisers_actual}"
),
scope => "namespace";

reports:
DEBUG::
"EXPECT (first in ${this.bundle}): callers_promisers_string = ${callers_promisers_expect_first}";
"ACTUAL (first in ${this.bundle}): callers_promisers_string = ${callers_promisers_actual}";

"EXPECT (second in ${this.bundle}): callers_promisers_string = ${callers_promisers_expect_second}";
"ACTUAL (second in ${this.bundle}): callers_promisers_string = ${callers_promisers_actual}";
}
Loading
Loading