body common control
{
  bundlesequence => { "setup", "try_modify" };
}

body fsattrs set_immutable
{
  immutable => "true";
}

bundle edit_xml set_foo
{
  set_text:
    "a value the agent tries to write" select_xpath => "/foo";
}

bundle agent setup
{
  files:
    # Create the immutable XML target. This runs in its own agent process
    # (invoked from the test's check bundle), so setup is ordered before the
    # edit below and does not depend on the parent test.
    "/tmp/19_immutable.xml"
      content => '<foo>original</foo>',
      fsattrs => set_immutable;
}

bundle agent try_modify
{
  files:
    # No fsattrs => ... immutable, so the immutable bit is not overridden.
    # The edit changes the document, so the agent writes a temporary file and
    # renames it over the immutable target, which fails.
    "/tmp/19_immutable.xml" edit_xml => set_foo;
}
