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

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

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

bundle agent try_modify
{
  files:
    # No fsattrs => ... immutable, so the immutable bit is not overridden.
    # The content differs from what setup wrote, so the agent tries to open the
    # immutable file for writing and fails.
    "/tmp/14_immutable.txt"
      content => "the agent tries to modify an immutable file";
}
