File: string.cf

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (57 lines) | stat: -rw-r--r-- 2,600 bytes parent folder | download | duplicates (3)
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
body common control
{
        inputs => { "../../default.cf.sub" };
        bundlesequence => { default( "$(this.promise_filename)" ) };
}

bundle agent init
{
  classes:
      "ExistingClass";

  vars:
      "a_int" int => "1k";
      "a_real" real => "6.066";
      "a_string" string => "Really interesting string";
      "a_data_container_1" data => '{"foo": "bar"}';
      "a_data_container_2" data => '[1, 2, 3]';
      "a_data_container_3" data => '{"list": [1, 2, 3, 4], "obj": {"key": ["b", "a", "r"]}}';

      "string_of_int" string => string("$(a_int)");
      "string_of_real" string => string("$(a_real)");
      "string_of_string" string => string("$(a_string)");
      "string_of_bool_true" string => string(and("ExistingClass"));
      "string_of_bool_false" string => string(and("NonExistingClass"));
      "string_of_data_container_1" string => string(a_data_container_1);  # Strings not interpretted as references
      "string_of_data_container_2" string => string("a_data_container_2");  # Strings not interpretted as references
      "string_of_data_container_3" string => string(@(a_data_container_3));

      #    "test_args" string => string();  # This is caught by the parser
}

bundle agent check
{
  meta:
      "description" -> { "CFE-3476" }
        string => "Test whether string() properly converts argument to string
                   or string-serialises JSON *only* when explicitely passed as a '@()' reference";

  classes:
      "ok_int" expression => strcmp("1000", "$(init.string_of_int)");
      "ok_real" expression => strcmp("6.066000", "$(init.string_of_real)");
      "ok_string" expression => strcmp("Really interesting string", "$(init.string_of_string)");
      "ok_bool_true" expression => strcmp("any", "$(init.string_of_bool_true)");
      "ok_bool_false" expression => strcmp("!any", "$(init.string_of_bool_false)");
      "ok_data_container_1" expression => strcmp("a_data_container_1", "$(init.string_of_data_container_1)");
      "ok_data_container_2" expression => strcmp("a_data_container_2", "$(init.string_of_data_container_2)");
      "ok_data_container_3" expression => strcmp('{"list":[1,2,3,4],"obj":{"key":["b","a","r"]}}',
                                                 "$(init.string_of_data_container_3)");

      "ok" expression => and("ok_int", "ok_real", "ok_string", "ok_bool_true",
                             "ok_bool_false", "ok_data_container_1", "ok_data_container_2", "ok_data_container_3");

  methods:
      "Pass/Fail"
        usebundle => dcs_passif( "ok", "$(this.promise_filename)" ),
        inherit => "true";
}