File: selectlinematching.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 (96 lines) | stat: -rw-r--r-- 3,172 bytes parent folder | download | duplicates (7)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
##############################################################################
#
# Redmine #2778
#   3.5.x: incorrect output of:
#    "insert_lines promise uses the same select_line_matching anchor [...]"
#
# This test is loosely modelled on "execresult_multiples.cf" (post-3.5.x).
#
# The original Redmine 2778 report concerned editing a "sendmail.mc" file.
# But in developing this acceptance test, I discovered that some existing
# tests in this area also exhibit this behaviour, such as "009.cf".
#
# This test has two subtests:
#   o  a copy of "009.cf";
#   o  the "sendmail.mc" edit from the original report.
#
# The subtests functionally pass but exhibit the incorrect output.
#
# Our intention is to fail if any of:
#   o  incorrect output is seen (our prime concern)
#   o  subtest itself functionally fails (its problem, not ours)
#
# David Lee <david.lee@ecmwf.int>
# December 2013
#
##############################################################################

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

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

bundle agent init
{

}

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

bundle agent test
{
  vars:
    any::
      # Run subtests.  Need to be in verbose mode to see the output.
      # The full verbose output is too big for variable assignment here.
      # So extract (grep) only potentially interesting lines.
      "subout_1" string => execresult("$(sys.cf_agent) -Kv -f $(this.promise_filename).sub_1 2>&1 | $(G.egrep) -i 'select_line_matching'", "useshell");
      "subout_2" string => execresult("$(sys.cf_agent) -Kv -f $(this.promise_filename).sub_2 2>&1 | $(G.egrep) -i 'select_line_matching'", "useshell");

  reports:
    DEBUG::
      "bundle test: this.promise_filename: $(this.promise_filename)";
      "bundle test: subtest_1: $(this.promise_filename).sub_1";
      "bundle test: subout_1:  $(subout_1)";
      "bundle test: subtest_2: $(this.promise_filename).sub_2";
      "bundle test: subout_2:  $(subout_2)";
}


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

bundle agent check
{
  vars:
    any::
      # These patterns spell trouble.
      "pattern_fail" string => ".*select_line_matching anchor.*";

  # Examine output from 'test' to decide whether good or bad.
  classes:
    any::
      "ok_pattern_1" not => regcmp("$(pattern_fail)", "$(test.subout_1)");
      "ok_pattern_2" not => regcmp("$(pattern_fail)", "$(test.subout_2)");

  reports:
    DEBUG::
      "Attempted subtest '$(this.promise_filename).sub_1' in verbose mode.";
      "Significant output of sub_1 was '$(test.subout_1)'.";
      "Attempted subtest '$(this.promise_filename).sub_2' in verbose mode.";
      "Significant output of sub_2 was '$(test.subout_2)'.";

    DEBUG.!ok_pattern_1::
      "failing: pattern '$(pattern_fail)' in subtest_1";

    DEBUG.!ok_pattern_2::
      "failing: pattern '$(pattern_fail)' in subtest_2";

    ok_pattern_1.ok_pattern_2::
      "$(this.promise_filename) Pass";
    !(ok_pattern_1.ok_pattern_2)::
      "$(this.promise_filename) FAIL";
}