|
| 1 | +############################################################################## |
| 2 | +# |
| 3 | +# Test that agent reports the immutable bit in the error message when it |
| 4 | +# cannot write to an immutable file via copy_from (no override). |
| 5 | +# |
| 6 | +# copy_from writes a temporary file and renames it over the target, so the |
| 7 | +# failure surfaces from OverrideImmutableRename(). The whole scenario (create |
| 8 | +# source + immutable destination, then fail to copy) runs in a self-contained |
| 9 | +# sub policy: its setup happens in its own agent process, so it does not depend |
| 10 | +# on this test's evaluation order, and its non-zero exit does not fail this |
| 11 | +# test. We only assert on the captured error output. Teardown clears the |
| 12 | +# immutable bit natively via body fsattrs. |
| 13 | +# |
| 14 | +############################################################################## |
| 15 | +body common control |
| 16 | +{ |
| 17 | + inputs => { "../../default.sub.cf" }; |
| 18 | + bundlesequence => { default("$(this.promise_filename)") }; |
| 19 | + version => "1.0"; |
| 20 | +} |
| 21 | + |
| 22 | +bundle agent global |
| 23 | +{ |
| 24 | + vars: |
| 25 | + "source" string => "/tmp/16_immutable.src"; |
| 26 | + "testfile" string => "/tmp/16_immutable.txt"; |
| 27 | +} |
| 28 | + |
| 29 | +body fsattrs clear_immutable |
| 30 | +{ |
| 31 | + immutable => "false"; |
| 32 | +} |
| 33 | + |
| 34 | +bundle agent test |
| 35 | +{ |
| 36 | + meta: |
| 37 | + "description" -> { "ENT-14297" } |
| 38 | + string => "Test that copy_from onto an immutable file names the immutable bit in the error"; |
| 39 | + |
| 40 | + "test_skip_unsupported" string => "hpux|aix|solaris|windows"; |
| 41 | +} |
| 42 | + |
| 43 | +bundle agent check |
| 44 | +{ |
| 45 | + vars: |
| 46 | + "run" |
| 47 | + data => execresult_as_data( |
| 48 | + "$(sys.cf_agent) -KI -f $(with)", "noshell", "both" |
| 49 | + ), |
| 50 | + with => regex_replace("$(this.promise_filename)", "\.cf$", ".sub.cf", ""); |
| 51 | + |
| 52 | + classes: |
| 53 | + "ok" |
| 54 | + expression => regcmp( |
| 55 | + ".*Failed to replace.*the immutable bit is set.*", "$(run[output])" |
| 56 | + ); |
| 57 | + |
| 58 | + reports: |
| 59 | + ok:: |
| 60 | + "$(this.promise_filename) Pass"; |
| 61 | + |
| 62 | + !ok:: |
| 63 | + "$(this.promise_filename) FAIL"; |
| 64 | + |
| 65 | + DEBUG:: |
| 66 | + "$(this.bundle): agent exited '$(run[exit_code])', output was:"; |
| 67 | + "$(run[output])"; |
| 68 | +} |
| 69 | + |
| 70 | +bundle agent destroy |
| 71 | +{ |
| 72 | + files: |
| 73 | + "$(global.testfile)" |
| 74 | + delete => tidy, |
| 75 | + fsattrs => clear_immutable; |
| 76 | + |
| 77 | + "$(global.source)" delete => tidy; |
| 78 | +} |
0 commit comments