#######################################################
#
# Test countlinesmatching() with some kind of failure expected
#
#######################################################
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

#######################################################
bundle agent init
{
  vars:
    "dummy" string => "dummy";
}

#######################################################
bundle agent test
{
  meta:
    "description" -> { "Mantis 320", "CFE-3234" }
      string => "Test that countlinesmatching() returns 0 when the file is inaccessible.";

  vars:
    "zero_regex" string => "impossible line";
    "fail" int => countlinesmatching("$(zero_regex)", "/asd/fgh/qwertyio0p");
}

#######################################################
bundle agent check
{
  classes:
    "ok" and => { strcmp("$(test.fail)", "0") };

  reports:
    DEBUG::
      "Expected 0 matches to '$(test.zero_regex)', found $(test.fail)";

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

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