#######################################################
#
# Test execresult() of large files
#
#######################################################
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

#######################################################
bundle agent init
{
}

#######################################################
bundle agent test
{
}

#######################################################
bundle agent check
{
  vars:
    "testlengths" ilist => { "1024", "4096", "100000", "500000" };

    "result_$(testlengths)"
      string => execresult(
        "$(G.perl) -e 'my $x = qw/x/ x $(testlengths); print $x;'", "useshell"
      );

    "length_$(testlengths)" int => string_length("$(result_$(testlengths))");

  classes:
    "ok_$(testlengths)"
      expression => strcmp("$(length_$(testlengths))", $(testlengths));

    "ok" and => { "ok_1024", "ok_4096", "ok_100000", "ok_500000" };

  reports:
    DEBUG::
      "the read of $(testlengths) bytes gave $(length_$(testlengths)) bytes";

      "the read of $(testlengths) bytes failed to match the expected $(testlengths) bytes, actual = $(length_$(testlengths))"
        if => "!ok_$(testlengths)";

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

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