File: module-array-allows-at.cf

package info (click to toggle)
cfengine3 3.15.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 34,456 kB
  • sloc: ansic: 145,932; sh: 8,550; makefile: 1,558; yacc: 1,192; python: 1,056; lex: 758; perl: 211; pascal: 149; awk: 58; xml: 21; sed: 13
file content (62 lines) | stat: -rw-r--r-- 1,746 bytes parent folder | download | duplicates (2)
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
body common control
{
      inputs => { "../../default.cf.sub" };
      bundlesequence  => { default("$(this.promise_filename)") };
      version => "1.0";
}

bundle agent test
{
  meta:
      "description" -> { "CFE-3099" }
        string => "Test that arrays defined by modules can contain @ just like classic arrays.";

  commands:

    # Define a simple classic array using the module protocol.

      "$(G.echo)"
        args => "=array[key]=array_key_value",
        module => "true";

    # Define a classic array where the key contains an @ using the module protocol.

      "$(G.echo)"
        args => "=array[key@1]=array_path_key_value",
        module => "true";

  vars:

    # Define a classic array where the key contains an @.

    "array[key@1]" string => "another_array_path_key_value";

    #Find all the array entries defined by the module commands.
    "v" slist => variablesmatching("default:echo\.*array.*");

  reports:
    DEBUG::
     "Found variable '$(v)'";
}

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

bundle agent check
{
  vars:
    # Construct strings from the array values for comparison and test pass/fail
    "expected" string => "array_key_value array_path_key_value another_array_path_key_value";
    "actual" string => "$(echo.array[key]) $(echo.array[key@1]) $(test.array[key@1])";

  methods:
      "" usebundle => dcs_check_strcmp($(expected),
                                       $(actual),
                                       $(this.promise_filename),
                                       "no");

  reports:
    DEBUG::
      "module array[key] = '$(echo.array[key])'";
      "module array[key@1] = '$(echo.array[key@1])'";
      "classic array[key@1] = '$(test.array[key@1])'";
}