body file control
{
  inputs => { "$(sys.policy_entry_dirname)/../common_soft_fail.cf.sub" };
}

bundle common testcase
{
  vars:
    "filename" string => "$(this.promise_filename)";
}

bundle agent setup
{
  files:
    "$(G.testfile)"
      edit_xml => xml_insert_tree_nopath("<Root/>"),
      create => "true";
}

bundle agent main
{
  files:
    "$(G.testfile)"
      edit_xml => xml_set_attribute("my_attr", "my_value", "//Root");
}

bundle agent teardown
{
  reports:
    "Edited file has contents: " printfile => my_cat($(G.testfile));
}

body printfile my_cat(file)
# @brief Report the contents of a file
# @param file The full path of the file to report
{
  file_to_print => "$(file)";
  number_of_lines => "inf";
}

bundle edit_xml xml_insert_tree_nopath(treestring)
{
  insert_tree:
    '$(treestring)';
}

bundle edit_xml xml_set_attribute(attr, value, xpath)
{
  set_attribute:
    "$(attr)"
      attribute_value => "$(value)",
      select_xpath => "$(xpath)";
}
