파일 게시 회귀 계약과 시험을 추가함
- 작성자
- 코노모리 카논
- 작성 시각
- 커밋
1c16f1bffd79129dc1dbd4df4f5a3433f1ccbf65- 부모
- 10dc446
변경된 파일 16개
+1,886-0| @@ -0,0 +1,24 @@ | ||
| 1 | 추가: # This file is automatically @generated by Cargo. | |
| 2 | 추가: # It is not intended for manual editing. | |
| 3 | 추가: version = 4 | |
| 4 | 추가: | |
| 5 | 추가: [[package]] | |
| 6 | 추가: name = "libc" | |
| 7 | 추가: version = "0.2.191" | |
| 8 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 9 | 추가: checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" | |
| 10 | 추가: | |
| 11 | 추가: [[package]] | |
| 12 | 추가: name = "zipelo-file-publication" | |
| 13 | 추가: version = "0.1.0" | |
| 14 | 추가: dependencies = [ | |
| 15 | 추가: "libc", | |
| 16 | 추가: ] | |
| 17 | 추가: | |
| 18 | 추가: [[package]] | |
| 19 | 추가: name = "zipelo-file-publication-regressions" | |
| 20 | 추가: version = "0.1.0" | |
| 21 | 추가: dependencies = [ | |
| 22 | 추가: "libc", | |
| 23 | 추가: "zipelo-file-publication", | |
| 24 | 추가: ] |
| @@ -0,0 +1,20 @@ | ||
| 1 | 추가: [package] | |
| 2 | 추가: name = "zipelo-file-publication-regressions" | |
| 3 | 추가: version = "0.1.0" | |
| 4 | 추가: edition = "2024" | |
| 5 | 추가: rust-version = "1.99" | |
| 6 | 추가: license = "MIT" | |
| 7 | 추가: publish = false | |
| 8 | 추가: autotests = false | |
| 9 | 추가: autoexamples = false | |
| 10 | 추가: autobenches = false | |
| 11 | 추가: | |
| 12 | 추가: [[test]] | |
| 13 | 추가: name = "publication_public_api" | |
| 14 | 추가: path = "main.rs" | |
| 15 | 추가: | |
| 16 | 추가: [dependencies] | |
| 17 | 추가: publication = { package = "zipelo-file-publication", path = "../../experiments/rust-file-publication" } | |
| 18 | 추가: libc = { version = "=0.2.191", default-features = false, features = ["std"] } | |
| 19 | 추가: | |
| 20 | 추가: [workspace] |
| @@ -0,0 +1,15 @@ | ||
| 1 | 추가: 7c69de86f84acb7a335c713067ee49f8e094e4c74e6efcca10e0305fa63d5339 Cargo.lock | |
| 2 | 추가: 713d89eb8e474cce49a1e2843aac8275a2aad664f7967d5ea959082eb659fc03 Cargo.toml | |
| 3 | 추가: 60c29c5ff2d3373f80b72e23c0e8016cf13cc1fc579a5df399b1b0dda2636d69 boundaries.rs | |
| 4 | 추가: 4534a3cb59cf7f34793ec12e84664eb8433dffaab2f2fd39657f764519a44793 concurrency.rs | |
| 5 | 추가: 6b9a56f1c4c3cbbb4669e939da359929d77cd3fa2468191ba74611f5d1183d87 contract.json | |
| 6 | 추가: 79c8db9a22758092d72aeba8fd9a067c0658aab62dceef117f556873b244313c control.rs | |
| 7 | 추가: 883cced6a09c7bda45255c4b18829b64f9ac834dd00c28578daf9eb2430be02a main.rs | |
| 8 | 추가: c04a1c5e83ab7dcbe5eda7a17e62e40ec15f0cfb1255b19cdca8ec18ea8b2a20 models.rs | |
| 9 | 추가: 561d6d778a117dae3803a0c61fffcdc660fcd9b8e3732dec1df97e85e233e948 namespace.rs | |
| 10 | 추가: 4b12d23abbbca10fd4efb863085292445357e85d118026cc4104ea035b0fdf9a paths.rs | |
| 11 | 추가: 22db9550c49f73ac61efe27dd46a1a90ca7072fea0408c7134a217bdf2f561ff run-plan.json | |
| 12 | 추가: 004d847ca5e258e461de570cb8f1c187b807c94457816f7756c1388531a37c6a source-pins.json | |
| 13 | 추가: 856c0f14e3e8cab10dd626af85059983869dc822c3f951965090992a4725d52f static_check.py | |
| 14 | 추가: 53a7bc6d4cadf3c69c13440d79288b424e9ac1f1873984fba550e7b78664a3f6 static_check_helper_tests.py | |
| 15 | 추가: 57dcc3e198e0f7d35e61d134dd908be1d72cc2dba534ee2767452f94edab44ba support.rs |
| @@ -0,0 +1,230 @@ | ||
| 1 | 추가: use crate::support::*; | |
| 2 | 추가: use publication::{ | |
| 3 | 추가: Error, Limits, MAX_BYTES, MAX_IO_BYTES, MAX_IO_CALLS, Publication, Request, Stop, Usage, | |
| 4 | 추가: }; | |
| 5 | 추가: use std::{ffi::OsStr, path::Path, time::Duration}; | |
| 6 | 추가: | |
| 7 | 추가: fn boundary(length: usize) { | |
| 8 | 추가: let sandbox = Sandbox::new(); | |
| 9 | 추가: let bytes = pattern(length); | |
| 10 | 추가: let before = bytes.clone(); | |
| 11 | 추가: let parent = sandbox.parent(); | |
| 12 | 추가: let report = publish(&parent, OsStr::new("output"), &bytes, Limits::default()); | |
| 13 | 추가: committed(report, &parent, OsStr::new("output"), &before); | |
| 14 | 추가: assert_eq!(bytes, before); | |
| 15 | 추가: sandbox.finish(); | |
| 16 | 추가: } | |
| 17 | 추가: | |
| 18 | 추가: #[test] | |
| 19 | 추가: fn empty() { | |
| 20 | 추가: boundary(0); | |
| 21 | 추가: } | |
| 22 | 추가: #[test] | |
| 23 | 추가: fn one() { | |
| 24 | 추가: boundary(1); | |
| 25 | 추가: } | |
| 26 | 추가: #[test] | |
| 27 | 추가: fn chunk_minus_one() { | |
| 28 | 추가: boundary(65_535); | |
| 29 | 추가: } | |
| 30 | 추가: #[test] | |
| 31 | 추가: fn chunk() { | |
| 32 | 추가: boundary(65_536); | |
| 33 | 추가: } | |
| 34 | 추가: #[test] | |
| 35 | 추가: fn chunk_plus_one() { | |
| 36 | 추가: boundary(65_537); | |
| 37 | 추가: } | |
| 38 | 추가: #[test] | |
| 39 | 추가: fn maximum_minus_one() { | |
| 40 | 추가: boundary(16_777_215); | |
| 41 | 추가: } | |
| 42 | 추가: #[test] | |
| 43 | 추가: fn maximum() { | |
| 44 | 추가: boundary(16_777_216); | |
| 45 | 추가: } | |
| 46 | 추가: | |
| 47 | 추가: #[test] | |
| 48 | 추가: fn invalid_limits_precede_paths_and_callback() { | |
| 49 | 추가: for limits in [ | |
| 50 | 추가: Limits { | |
| 51 | 추가: max_bytes: MAX_BYTES + 1, | |
| 52 | 추가: ..Limits::default() | |
| 53 | 추가: }, | |
| 54 | 추가: Limits { | |
| 55 | 추가: max_io_bytes: MAX_IO_BYTES + 1, | |
| 56 | 추가: ..Limits::default() | |
| 57 | 추가: }, | |
| 58 | 추가: Limits { | |
| 59 | 추가: max_io_calls: MAX_IO_CALLS + 1, | |
| 60 | 추가: ..Limits::default() | |
| 61 | 추가: }, | |
| 62 | 추가: Limits { | |
| 63 | 추가: max_duration: Duration::ZERO, | |
| 64 | 추가: ..Limits::default() | |
| 65 | 추가: }, | |
| 66 | 추가: Limits { | |
| 67 | 추가: max_duration: Duration::from_secs(301), | |
| 68 | 추가: ..Limits::default() | |
| 69 | 추가: }, | |
| 70 | 추가: ] { | |
| 71 | 추가: let (task, cancel) = Publication::new(); | |
| 72 | 추가: let report = task.publish( | |
| 73 | 추가: Request { | |
| 74 | 추가: parent: Path::new("invalid"), | |
| 75 | 추가: leaf: OsStr::new(""), | |
| 76 | 추가: bytes: &[], | |
| 77 | 추가: limits, | |
| 78 | 추가: }, | |
| 79 | 추가: |_| -> Result<(), Stop<()>> { panic!("callback must not run") }, | |
| 80 | 추가: ); | |
| 81 | 추가: let (error, usage, closed) = not_committed(report); | |
| 82 | 추가: assert!(matches!(error, Error::InvalidLimits)); | |
| 83 | 추가: assert_eq!(usage, Usage::default()); | |
| 84 | 추가: cleanup(&closed, 0); | |
| 85 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 86 | 추가: } | |
| 87 | 추가: } | |
| 88 | 추가: | |
| 89 | 추가: #[test] | |
| 90 | 추가: fn oversized_input_rejected_without_io() { | |
| 91 | 추가: let bytes = pattern(MAX_BYTES as usize + 1); | |
| 92 | 추가: let report = publish( | |
| 93 | 추가: Path::new("invalid"), | |
| 94 | 추가: OsStr::new("output"), | |
| 95 | 추가: &bytes, | |
| 96 | 추가: Limits::default(), | |
| 97 | 추가: ); | |
| 98 | 추가: let (error, usage, closed) = not_committed(report); | |
| 99 | 추가: assert!(matches!(error, Error::LimitExceeded)); | |
| 100 | 추가: assert_eq!(usage, Usage::default()); | |
| 101 | 추가: cleanup(&closed, 0); | |
| 102 | 추가: } | |
| 103 | 추가: | |
| 104 | 추가: #[test] | |
| 105 | 추가: fn zero_byte_limit_accepts_empty_with_exact_eof_budget() { | |
| 106 | 추가: let sandbox = Sandbox::new(); | |
| 107 | 추가: let parent = sandbox.parent(); | |
| 108 | 추가: let limits = Limits { | |
| 109 | 추가: max_bytes: 0, | |
| 110 | 추가: max_io_bytes: 1, | |
| 111 | 추가: max_io_calls: 1, | |
| 112 | 추가: ..Limits::default() | |
| 113 | 추가: }; | |
| 114 | 추가: committed( | |
| 115 | 추가: publish(&parent, OsStr::new("output"), &[], limits), | |
| 116 | 추가: &parent, | |
| 117 | 추가: OsStr::new("output"), | |
| 118 | 추가: &[], | |
| 119 | 추가: ); | |
| 120 | 추가: sandbox.finish(); | |
| 121 | 추가: } | |
| 122 | 추가: | |
| 123 | 추가: #[test] | |
| 124 | 추가: fn zero_byte_limit_rejects_payload_before_path_validation() { | |
| 125 | 추가: let (error, usage, closed) = not_committed(publish( | |
| 126 | 추가: Path::new("invalid"), | |
| 127 | 추가: OsStr::new("output"), | |
| 128 | 추가: b"x", | |
| 129 | 추가: Limits { | |
| 130 | 추가: max_bytes: 0, | |
| 131 | 추가: ..Limits::default() | |
| 132 | 추가: }, | |
| 133 | 추가: )); | |
| 134 | 추가: assert!(matches!(error, Error::LimitExceeded)); | |
| 135 | 추가: assert_eq!(usage, Usage::default()); | |
| 136 | 추가: cleanup(&closed, 0); | |
| 137 | 추가: } | |
| 138 | 추가: | |
| 139 | 추가: fn empty_budget(limits: Limits) { | |
| 140 | 추가: let sandbox = Sandbox::new(); | |
| 141 | 추가: let (error, usage, closed) = not_committed(publish( | |
| 142 | 추가: &sandbox.parent(), | |
| 143 | 추가: OsStr::new("output"), | |
| 144 | 추가: &[], | |
| 145 | 추가: limits, | |
| 146 | 추가: )); | |
| 147 | 추가: assert!(matches!(error, Error::LimitExceeded)); | |
| 148 | 추가: assert_eq!(usage.open_calls, 2); | |
| 149 | 추가: assert_eq!(usage.metadata_calls, 3); | |
| 150 | 추가: assert_eq!(usage.sync_calls, 1); | |
| 151 | 추가: assert_eq!( | |
| 152 | 추가: usage.write_calls + usage.read_calls + usage.reserved_io_bytes + usage.link_calls, | |
| 153 | 추가: 0 | |
| 154 | 추가: ); | |
| 155 | 추가: cleanup(&closed, 2); | |
| 156 | 추가: assert!(names(&sandbox.parent()).is_empty()); | |
| 157 | 추가: sandbox.finish(); | |
| 158 | 추가: } | |
| 159 | 추가: | |
| 160 | 추가: #[test] | |
| 161 | 추가: fn zero_io_budget_fails_eof_without_refund() { | |
| 162 | 추가: empty_budget(Limits { | |
| 163 | 추가: max_io_bytes: 0, | |
| 164 | 추가: ..Limits::default() | |
| 165 | 추가: }); | |
| 166 | 추가: } | |
| 167 | 추가: | |
| 168 | 추가: #[test] | |
| 169 | 추가: fn zero_call_budget_is_valid_but_cannot_probe_eof() { | |
| 170 | 추가: empty_budget(Limits { | |
| 171 | 추가: max_io_calls: 0, | |
| 172 | 추가: ..Limits::default() | |
| 173 | 추가: }); | |
| 174 | 추가: } | |
| 175 | 추가: | |
| 176 | 추가: #[test] | |
| 177 | 추가: fn exact_io_and_call_budget_includes_eof() { | |
| 178 | 추가: let sandbox = Sandbox::new(); | |
| 179 | 추가: let parent = sandbox.parent(); | |
| 180 | 추가: let bytes = pattern(65_537); | |
| 181 | 추가: let limits = Limits { | |
| 182 | 추가: max_io_bytes: 131_075, | |
| 183 | 추가: max_io_calls: 5, | |
| 184 | 추가: ..Limits::default() | |
| 185 | 추가: }; | |
| 186 | 추가: committed( | |
| 187 | 추가: publish(&parent, OsStr::new("output"), &bytes, limits), | |
| 188 | 추가: &parent, | |
| 189 | 추가: OsStr::new("output"), | |
| 190 | 추가: &bytes, | |
| 191 | 추가: ); | |
| 192 | 추가: sandbox.finish(); | |
| 193 | 추가: } | |
| 194 | 추가: | |
| 195 | 추가: fn last_eof_limit(limits: Limits) { | |
| 196 | 추가: let sandbox = Sandbox::new(); | |
| 197 | 추가: let (error, usage, closed) = not_committed(publish( | |
| 198 | 추가: &sandbox.parent(), | |
| 199 | 추가: OsStr::new("output"), | |
| 200 | 추가: &pattern(65_537), | |
| 201 | 추가: limits, | |
| 202 | 추가: )); | |
| 203 | 추가: assert!(matches!(error, Error::LimitExceeded)); | |
| 204 | 추가: assert_eq!(usage.write_calls, 2); | |
| 205 | 추가: assert_eq!(usage.read_calls, 2); | |
| 206 | 추가: assert_eq!(usage.reserved_io_bytes, 131_074); | |
| 207 | 추가: assert_eq!(usage.actual_written_bytes, 65_537); | |
| 208 | 추가: assert_eq!(usage.actual_read_bytes, 65_537); | |
| 209 | 추가: assert_eq!(usage.link_calls, 0); | |
| 210 | 추가: assert_eq!(usage.sync_calls, 1); | |
| 211 | 추가: cleanup(&closed, 2); | |
| 212 | 추가: assert!(names(&sandbox.parent()).is_empty()); | |
| 213 | 추가: sandbox.finish(); | |
| 214 | 추가: } | |
| 215 | 추가: | |
| 216 | 추가: #[test] | |
| 217 | 추가: fn one_less_io_budget_stops_before_last_eof() { | |
| 218 | 추가: last_eof_limit(Limits { | |
| 219 | 추가: max_io_bytes: 131_074, | |
| 220 | 추가: ..Limits::default() | |
| 221 | 추가: }); | |
| 222 | 추가: } | |
| 223 | 추가: | |
| 224 | 추가: #[test] | |
| 225 | 추가: fn one_less_call_budget_stops_before_last_eof() { | |
| 226 | 추가: last_eof_limit(Limits { | |
| 227 | 추가: max_io_calls: 4, | |
| 228 | 추가: ..Limits::default() | |
| 229 | 추가: }); | |
| 230 | 추가: } |
| @@ -0,0 +1,125 @@ | ||
| 1 | 추가: use crate::support::*; | |
| 2 | 추가: use publication::{CancelDecision, Error, Limits, Outcome, Publication, Request, Stage, Stop}; | |
| 3 | 추가: use std::{ffi::OsStr, sync::mpsc, thread, time::Duration}; | |
| 4 | 추가: | |
| 5 | 추가: const WAIT: Duration = Duration::from_secs(5); | |
| 6 | 추가: | |
| 7 | 추가: #[test] | |
| 8 | 추가: fn two_prepared_publishers_have_exactly_one_complete_winner() { | |
| 9 | 추가: let sandbox = Sandbox::new(); | |
| 10 | 추가: let parent = sandbox.parent(); | |
| 11 | 추가: let (ready_tx, ready_rx) = mpsc::sync_channel(2); | |
| 12 | 추가: let (done_tx, done_rx) = mpsc::sync_channel(2); | |
| 13 | 추가: let mut releases = Vec::new(); | |
| 14 | 추가: let mut handles = Vec::new(); | |
| 15 | 추가: for marker in [65_u8, 66_u8] { | |
| 16 | 추가: let (release_tx, release_rx) = mpsc::sync_channel(1); | |
| 17 | 추가: releases.push(release_tx); | |
| 18 | 추가: let ready = ready_tx.clone(); | |
| 19 | 추가: let done = done_tx.clone(); | |
| 20 | 추가: let parent = parent.clone(); | |
| 21 | 추가: handles.push(thread::spawn(move || { | |
| 22 | 추가: let bytes = vec![marker; 65_537]; | |
| 23 | 추가: let (task, cancel) = Publication::new(); | |
| 24 | 추가: let report = task.publish( | |
| 25 | 추가: Request { | |
| 26 | 추가: parent: &parent, | |
| 27 | 추가: leaf: OsStr::new("output"), | |
| 28 | 추가: bytes: &bytes, | |
| 29 | 추가: limits: Limits::default(), | |
| 30 | 추가: }, | |
| 31 | 추가: |point| { | |
| 32 | 추가: if point.stage == Stage::BeforeCommit { | |
| 33 | 추가: ready.send(marker).unwrap(); | |
| 34 | 추가: release_rx | |
| 35 | 추가: .recv_timeout(WAIT) | |
| 36 | 추가: .expect("게시 해제 신호 시간 초과"); | |
| 37 | 추가: } | |
| 38 | 추가: Ok::<_, Stop<()>>(()) | |
| 39 | 추가: }, | |
| 40 | 추가: ); | |
| 41 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 42 | 추가: assert!(done.send((marker, report)).is_ok()); | |
| 43 | 추가: })); | |
| 44 | 추가: } | |
| 45 | 추가: drop(ready_tx); | |
| 46 | 추가: drop(done_tx); | |
| 47 | 추가: let mut ready = vec![ | |
| 48 | 추가: ready_rx.recv_timeout(WAIT).unwrap(), | |
| 49 | 추가: ready_rx.recv_timeout(WAIT).unwrap(), | |
| 50 | 추가: ]; | |
| 51 | 추가: ready.sort(); | |
| 52 | 추가: assert_eq!(ready, [65, 66]); | |
| 53 | 추가: assert!(names(&parent).is_empty()); | |
| 54 | 추가: for release in releases { | |
| 55 | 추가: release.send(()).unwrap(); | |
| 56 | 추가: } | |
| 57 | 추가: let results = [ | |
| 58 | 추가: done_rx.recv_timeout(WAIT).unwrap(), | |
| 59 | 추가: done_rx.recv_timeout(WAIT).unwrap(), | |
| 60 | 추가: ]; | |
| 61 | 추가: for handle in handles { | |
| 62 | 추가: handle.join().expect("게시 스레드 실패"); | |
| 63 | 추가: } | |
| 64 | 추가: assert_eq!( | |
| 65 | 추가: results | |
| 66 | 추가: .iter() | |
| 67 | 추가: .filter(|(_, r)| matches!(&r.outcome, Outcome::Committed { .. })) | |
| 68 | 추가: .count(), | |
| 69 | 추가: 1 | |
| 70 | 추가: ); | |
| 71 | 추가: for (marker, report) in results { | |
| 72 | 추가: if matches!(&report.outcome, Outcome::Committed { .. }) { | |
| 73 | 추가: committed(report, &parent, OsStr::new("output"), &vec![marker; 65_537]); | |
| 74 | 추가: } else { | |
| 75 | 추가: conflict(report, 65_537); | |
| 76 | 추가: } | |
| 77 | 추가: } | |
| 78 | 추가: sandbox.finish(); | |
| 79 | 추가: } | |
| 80 | 추가: | |
| 81 | 추가: #[test] | |
| 82 | 추가: fn acknowledged_cancellation_before_commit_prevents_link() { | |
| 83 | 추가: let sandbox = Sandbox::new(); | |
| 84 | 추가: let parent = sandbox.parent(); | |
| 85 | 추가: let worker_parent = parent.clone(); | |
| 86 | 추가: let (task, cancel) = Publication::new(); | |
| 87 | 추가: let (ready_tx, ready_rx) = mpsc::sync_channel(1); | |
| 88 | 추가: let (release_tx, release_rx) = mpsc::sync_channel(1); | |
| 89 | 추가: let (done_tx, done_rx) = mpsc::sync_channel(1); | |
| 90 | 추가: let handle = thread::spawn(move || { | |
| 91 | 추가: let report = task.publish( | |
| 92 | 추가: Request { | |
| 93 | 추가: parent: &worker_parent, | |
| 94 | 추가: leaf: OsStr::new("output"), | |
| 95 | 추가: bytes: b"abc", | |
| 96 | 추가: limits: Limits::default(), | |
| 97 | 추가: }, | |
| 98 | 추가: |point| { | |
| 99 | 추가: if point.stage == Stage::BeforeCommit { | |
| 100 | 추가: ready_tx.send(()).unwrap(); | |
| 101 | 추가: release_rx | |
| 102 | 추가: .recv_timeout(WAIT) | |
| 103 | 추가: .expect("취소 확인 신호 시간 초과"); | |
| 104 | 추가: } | |
| 105 | 추가: Ok::<_, Stop<()>>(()) | |
| 106 | 추가: }, | |
| 107 | 추가: ); | |
| 108 | 추가: assert!(done_tx.send(report).is_ok()); | |
| 109 | 추가: }); | |
| 110 | 추가: ready_rx.recv_timeout(WAIT).unwrap(); | |
| 111 | 추가: assert_eq!(cancel.request(), CancelDecision::Requested); | |
| 112 | 추가: assert_eq!(cancel.request(), CancelDecision::AlreadyRequested); | |
| 113 | 추가: release_tx.send(()).unwrap(); | |
| 114 | 추가: let report = done_rx.recv_timeout(WAIT).unwrap(); | |
| 115 | 추가: handle.join().expect("취소 스레드 실패"); | |
| 116 | 추가: let (error, usage, closed) = not_committed(report); | |
| 117 | 추가: assert!(matches!(error, Error::Cancelled)); | |
| 118 | 추가: assert_eq!(usage.link_calls, 0); | |
| 119 | 추가: assert_eq!(usage.actual_written_bytes, 3); | |
| 120 | 추가: assert_eq!(usage.actual_read_bytes, 3); | |
| 121 | 추가: cleanup(&closed, 4); | |
| 122 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 123 | 추가: assert!(names(&parent).is_empty()); | |
| 124 | 추가: sandbox.finish(); | |
| 125 | 추가: } |
| @@ -0,0 +1,164 @@ | ||
| 1 | 추가: { | |
| 2 | 추가: "schema": "zipelo.file-publication.regressions.v1", | |
| 3 | 추가: "source_head": "10dc446c90d3527437298cff270b26d2e196a748", | |
| 4 | 추가: "source_manifest_sha256": "cc4e4cc64a8f3b537df554c7d2895ea3722fbfb0906f1ada767d5cf9b5d8bbc6", | |
| 5 | 추가: "branch": "fix/rust-file-publication-regressions", | |
| 6 | 추가: "scope": "Source/static candidate. Rust compilation, discovery and runtime have not been performed. Frozen production path dependency; no private access, include!, copied implementation or syscall interposition.", | |
| 7 | 추가: "declared_test_count": 54, | |
| 8 | 추가: "test_names": [ | |
| 9 | 추가: "boundaries::chunk", | |
| 10 | 추가: "boundaries::chunk_minus_one", | |
| 11 | 추가: "boundaries::chunk_plus_one", | |
| 12 | 추가: "boundaries::empty", | |
| 13 | 추가: "boundaries::exact_io_and_call_budget_includes_eof", | |
| 14 | 추가: "boundaries::invalid_limits_precede_paths_and_callback", | |
| 15 | 추가: "boundaries::maximum", | |
| 16 | 추가: "boundaries::maximum_minus_one", | |
| 17 | 추가: "boundaries::one", | |
| 18 | 추가: "boundaries::one_less_call_budget_stops_before_last_eof", | |
| 19 | 추가: "boundaries::one_less_io_budget_stops_before_last_eof", | |
| 20 | 추가: "boundaries::oversized_input_rejected_without_io", | |
| 21 | 추가: "boundaries::zero_byte_limit_accepts_empty_with_exact_eof_budget", | |
| 22 | 추가: "boundaries::zero_byte_limit_rejects_payload_before_path_validation", | |
| 23 | 추가: "boundaries::zero_call_budget_is_valid_but_cannot_probe_eof", | |
| 24 | 추가: "boundaries::zero_io_budget_fails_eof_without_refund", | |
| 25 | 추가: "concurrency::acknowledged_cancellation_before_commit_prevents_link", | |
| 26 | 추가: "concurrency::two_prepared_publishers_have_exactly_one_complete_winner", | |
| 27 | 추가: "control::callback_cancel_precedes_expired_deadline", | |
| 28 | 추가: "control::callback_error_precedes_expired_deadline", | |
| 29 | 추가: "control::callback_panic_has_no_report_or_named_output", | |
| 30 | 추가: "control::callback_preserves_non_send_error_and_wins_over_cancel", | |
| 31 | 추가: "control::cancel_after_first_chunk_preserves_reservations", | |
| 32 | 추가: "control::cancel_before_commit_closes_four_handles_without_link", | |
| 33 | 추가: "control::cancel_before_sync_preserves_written_usage", | |
| 34 | 추가: "control::cancel_before_write_closes_anonymous_temp", | |
| 35 | 추가: "control::cancel_first_opening_has_no_handles", | |
| 36 | 추가: "control::cancel_second_opening_closes_parent", | |
| 37 | 추가: "control::cancellation_after_return_preserves_committed_output", | |
| 38 | 추가: "control::checkpoints_keep_output_absent_and_close_owned_descriptors", | |
| 39 | 추가: "control::dropping_unused_publication_marks_finished_without_io", | |
| 40 | 추가: "control::natural_elapsed_deadline_stops_before_open", | |
| 41 | 추가: "control::pre_requested_cancel_is_idempotent_and_stops_before_open", | |
| 42 | 추가: "models::constructed_cleanup_failures_are_never_all_successful", | |
| 43 | 추가: "models::public_types_support_transfer_without_forging_receipts", | |
| 44 | 추가: "namespace::destination_created_at_last_checkpoint_is_preserved", | |
| 45 | 추가: "namespace::parent_replaced_after_open_commits_to_held_directory", | |
| 46 | 추가: "namespace::parent_replaced_before_commit_keeps_receipt_on_old_parent", | |
| 47 | 추가: "namespace::removed_parent_returns_uncertain_original_errno_without_receipt", | |
| 48 | 추가: "paths::dangling_symlink_preserved", | |
| 49 | 추가: "paths::existing_directory_and_child_preserved", | |
| 50 | 추가: "paths::existing_fifo_preserved_without_opening_it", | |
| 51 | 추가: "paths::existing_hard_links_preserved", | |
| 52 | 추가: "paths::existing_regular_file_preserved", | |
| 53 | 추가: "paths::existing_socket_preserved_without_accepting_connections", | |
| 54 | 추가: "paths::existing_symlink_and_target_preserved", | |
| 55 | 추가: "paths::invalid_leaf_forms_rejected_before_callback", | |
| 56 | 추가: "paths::invalid_parent_forms_rejected_before_callback", | |
| 57 | 추가: "paths::linux_backslash_and_colon_are_leaf_bytes", | |
| 58 | 추가: "paths::maximum_leaf_length_is_supported", | |
| 59 | 추가: "paths::missing_and_regular_parent_preserve_errno", | |
| 60 | 추가: "paths::non_utf8_leaf_and_parent_are_supported", | |
| 61 | 추가: "paths::parent_and_ancestor_symlinks_rejected", | |
| 62 | 추가: "paths::root_parent_is_lexically_valid_without_opening_root" | |
| 63 | 추가: ], | |
| 64 | 추가: "evidence_classes": { | |
| 65 | 추가: "boundaries::chunk": "real-file-public-api", | |
| 66 | 추가: "boundaries::chunk_minus_one": "real-file-public-api", | |
| 67 | 추가: "boundaries::chunk_plus_one": "real-file-public-api", | |
| 68 | 추가: "boundaries::empty": "real-file-public-api", | |
| 69 | 추가: "boundaries::exact_io_and_call_budget_includes_eof": "real-file-public-api", | |
| 70 | 추가: "boundaries::invalid_limits_precede_paths_and_callback": "public-validation-no-file", | |
| 71 | 추가: "boundaries::maximum": "real-file-public-api", | |
| 72 | 추가: "boundaries::maximum_minus_one": "real-file-public-api", | |
| 73 | 추가: "boundaries::one": "real-file-public-api", | |
| 74 | 추가: "boundaries::one_less_call_budget_stops_before_last_eof": "real-file-public-api", | |
| 75 | 추가: "boundaries::one_less_io_budget_stops_before_last_eof": "real-file-public-api", | |
| 76 | 추가: "boundaries::oversized_input_rejected_without_io": "public-validation-no-file", | |
| 77 | 추가: "boundaries::zero_byte_limit_accepts_empty_with_exact_eof_budget": "real-file-public-api", | |
| 78 | 추가: "boundaries::zero_byte_limit_rejects_payload_before_path_validation": "public-validation-no-file", | |
| 79 | 추가: "boundaries::zero_call_budget_is_valid_but_cannot_probe_eof": "real-file-public-api", | |
| 80 | 추가: "boundaries::zero_io_budget_fails_eof_without_refund": "real-file-public-api", | |
| 81 | 추가: "concurrency::acknowledged_cancellation_before_commit_prevents_link": "real-file-bounded-thread-handshake", | |
| 82 | 추가: "concurrency::two_prepared_publishers_have_exactly_one_complete_winner": "real-file-bounded-thread-handshake", | |
| 83 | 추가: "control::callback_cancel_precedes_expired_deadline": "natural-elapsed-callback-no-file", | |
| 84 | 추가: "control::callback_error_precedes_expired_deadline": "natural-elapsed-callback-no-file", | |
| 85 | 추가: "control::callback_panic_has_no_report_or_named_output": "real-file-callback-control", | |
| 86 | 추가: "control::callback_preserves_non_send_error_and_wins_over_cancel": "real-file-callback-control", | |
| 87 | 추가: "control::cancel_after_first_chunk_preserves_reservations": "real-file-callback-control", | |
| 88 | 추가: "control::cancel_before_commit_closes_four_handles_without_link": "real-file-callback-control", | |
| 89 | 추가: "control::cancel_before_sync_preserves_written_usage": "real-file-callback-control", | |
| 90 | 추가: "control::cancel_before_write_closes_anonymous_temp": "real-file-callback-control", | |
| 91 | 추가: "control::cancel_first_opening_has_no_handles": "real-file-callback-control", | |
| 92 | 추가: "control::cancel_second_opening_closes_parent": "real-file-callback-control", | |
| 93 | 추가: "control::cancellation_after_return_preserves_committed_output": "real-file-callback-control", | |
| 94 | 추가: "control::checkpoints_keep_output_absent_and_close_owned_descriptors": "real-file-callback-control", | |
| 95 | 추가: "control::dropping_unused_publication_marks_finished_without_io": "public-state-no-file", | |
| 96 | 추가: "control::natural_elapsed_deadline_stops_before_open": "natural-elapsed-callback-no-file", | |
| 97 | 추가: "control::pre_requested_cancel_is_idempotent_and_stops_before_open": "public-state-no-file", | |
| 98 | 추가: "models::constructed_cleanup_failures_are_never_all_successful": "constructed-cleanup-value-only", | |
| 99 | 추가: "models::public_types_support_transfer_without_forging_receipts": "compile-bound-assertions", | |
| 100 | 추가: "namespace::destination_created_at_last_checkpoint_is_preserved": "real-file-checkpoint-namespace-mutation", | |
| 101 | 추가: "namespace::parent_replaced_after_open_commits_to_held_directory": "real-file-checkpoint-namespace-mutation", | |
| 102 | 추가: "namespace::parent_replaced_before_commit_keeps_receipt_on_old_parent": "real-file-checkpoint-namespace-mutation", | |
| 103 | 추가: "namespace::removed_parent_returns_uncertain_original_errno_without_receipt": "real-file-checkpoint-namespace-mutation", | |
| 104 | 추가: "paths::dangling_symlink_preserved": "real-file-public-api", | |
| 105 | 추가: "paths::existing_directory_and_child_preserved": "real-file-public-api", | |
| 106 | 추가: "paths::existing_fifo_preserved_without_opening_it": "real-file-public-api", | |
| 107 | 추가: "paths::existing_hard_links_preserved": "real-file-public-api", | |
| 108 | 추가: "paths::existing_regular_file_preserved": "real-file-public-api", | |
| 109 | 추가: "paths::existing_socket_preserved_without_accepting_connections": "real-file-public-api", | |
| 110 | 추가: "paths::existing_symlink_and_target_preserved": "real-file-public-api", | |
| 111 | 추가: "paths::invalid_leaf_forms_rejected_before_callback": "public-validation-no-file", | |
| 112 | 추가: "paths::invalid_parent_forms_rejected_before_callback": "public-validation-no-file", | |
| 113 | 추가: "paths::linux_backslash_and_colon_are_leaf_bytes": "real-file-public-api", | |
| 114 | 추가: "paths::maximum_leaf_length_is_supported": "real-file-public-api", | |
| 115 | 추가: "paths::missing_and_regular_parent_preserve_errno": "real-file-public-api", | |
| 116 | 추가: "paths::non_utf8_leaf_and_parent_are_supported": "real-file-public-api", | |
| 117 | 추가: "paths::parent_and_ancestor_symlinks_rejected": "real-file-public-api", | |
| 118 | 추가: "paths::root_parent_is_lexically_valid_without_opening_root": "public-validation-no-file" | |
| 119 | 추가: }, | |
| 120 | 추가: "fixture_provenance": { | |
| 121 | 추가: "inputs": "Only source-defined pattern(i)=(i*37+11)%251, fixed literals and bounded repeated bytes. No archive or user-file inputs.", | |
| 122 | 추가: "paths": "Future approved runner exclusively creates mode-0700 tests/rust-file-publication/runs. Each case creates exclusive case-PID-counter and a mode-0700 parent. Tests may only publish/create/move/remove their own synthetic paths. No global cwd, environment, umask, permission or ownership changes.", | |
| 123 | 추가: "special_files": "Synthetic FIFO through existing libc::mkfifo, unconnected local Unix socket, symlinks and hard links. No device nodes, mounts or system special-file writes.", | |
| 124 | 추가: "filesystem": "Linux magic ef53 (ext family) or 58465342 (XFS), exclusively managed by effective UID. The current tests directory reports ef53 in read-only stat inspection; O_TMPFILE/linkat/fsync are unverified until execution. Unsupported environment must stop, not skip or silently fall back.", | |
| 125 | 추가: "boundaries": [ | |
| 126 | 추가: 0, | |
| 127 | 추가: 1, | |
| 128 | 추가: 65535, | |
| 129 | 추가: 65536, | |
| 130 | 추가: 65537, | |
| 131 | 추가: 16777215, | |
| 132 | 추가: 16777216, | |
| 133 | 추가: 16777217 | |
| 134 | 추가: ] | |
| 135 | 추가: }, | |
| 136 | 추가: "acceptance": { | |
| 137 | 추가: "committed": "Actual file-layer receipt, matching held parent/file identity and length, exact complete output bytes, nlink=1, no group/other permissions, two successful fsync returns and four reported closes. This is not worker, archive, product Published or crash-recovery proof.", | |
| 138 | 추가: "accounting": "For normal full transfers: write calls ceil(N/65536), read calls ceil(N/65536)+1, reserved bytes 2*N+1, actual read/write N each, open 4, metadata 5, link 1. Conflict/uncertain link has sync 1; committed normal path sync 2. Checks cover observed full transfers, not proof all syscalls always transfer fully.", | |
| 139 | 추가: "collision": "Existing regular file, directory child, symlink/target, dangling symlink, hard link, FIFO and Unix socket preserve identity/type/link count/size and applicable bytes. Late checkpoint insertion is also EEXIST. No overwrite/unlink/copy fallback.", | |
| 140 | 추가: "concurrent_publishers": "Two real std threads both reach BeforeCommit before release; one complete payload and one native EEXIST. Winner not predetermined. Bounded independent channels replace unbounded Barrier. No OS worker or product isolation.", | |
| 141 | 추가: "cancel": "Pre-request and repeated request; cancellation at each stage and after first chunk; acknowledged cancellation before commit via actual channel handshake has link_calls=0. Cancel after returned report is Finished and cannot remove output. Callback errors preserve non-Send Rc identity and beat simultaneous cancellation.", | |
| 142 | 추가: "namespace": "Rename/replacement at second Opening and BeforeCommit publishes into held old directory and preserves the replacement parent's output. Removing the empty held parent at BeforeCommit expects CommitUncertain(ENOENT), no receipt, one link attempt and no retry.", | |
| 143 | 추가: "cleanup": "Normal returns assert close attempt counts and no recorded close errors. /proc/self/fd inspection observes no remaining descriptors whose targets are below the owned sandbox; it does not independently identify every procfs descriptor or prove physical storage deletion. Anonymous temp names are never treated as named output.", | |
| 144 | 추가: "failure_preservation": "Every assertion completes before explicit Sandbox::finish. No Drop cleanup. Any panic/error/timeout leaves synthetic paths for inspection and halts subsequent cases. finish verifies original directory identity and absence of owned-target fd references before removing only that case root.", | |
| 145 | 추가: "panic": "One intentionally caught callback panic observes Finished, no output and no owned-target fd references. No Report exists; RAII close errors and procfs fd cleanup remain unverified.", | |
| 146 | 추가: "models": "Constructed Cleanup failures test only value/API interpretation. EIO/EINTR values are synthetic, never actual close failures. all_close_calls_succeeded with attempted=0 is vacuously true, not work completion evidence.", | |
| 147 | 추가: "deadline": "Three callback cases sleep 10 ms against 1 ms cooperative budget. Natural elapsed behavior only; no injected clock, hard I/O deadline or timing-race guarantee.", | |
| 148 | 추가: "old_results": "PR48 a02146e1 72-pass evidence and existing 16 comparison failures/seven unverified results remain intact, outside this count." | |
| 149 | 추가: }, | |
| 150 | 추가: "unverified": [ | |
| 151 | 추가: "Positive short/zero write, read short/zero/corruption/EINTR/EIO, lseek failure and allocator failure: no public raw-I/O injection boundary.", | |
| 152 | 추가: "File fsync failure, parent fsync failure after successful link, close failure/EINTR and exact close order with actual failing syscalls. Constructed Cleanup values are not adapter evidence.", | |
| 153 | 추가: "CancelDecision::TooLate inside Committing and cancellation in the final-check-to-CAS race. Public checkpoints do not occur after CAS; no artificial proof is inserted.", | |
| 154 | 추가: "UntrustedParent from foreign UID or writable mode, hostile same-UID actors, ACL/LSM policies, procfs substitution, unsupported filesystem/kernel, EXDEV and arbitrary commit errors. No chown/chmod/mount/environment changes.", | |
| 155 | 추가: "Opaque receipt constructor compile-fail tests, non-Linux runtime, Windows/VM, all-descriptor leaks, physical temp deletion, arbitrary crash consistency and original-path persistence.", | |
| 156 | 추가: "OS worker launch/identity/EOF/reap, execveat EACCES retry/bypass, publication of real archives or product UI. Existing held probes stay deferred." | |
| 157 | 추가: ], | |
| 158 | 추가: "execution_plan": "run-plan.json", | |
| 159 | 추가: "preserved_snapshot_evidence": { | |
| 160 | 추가: "result-audit.json": "4fa9c54270af4a71f7cc0f8e5ece8ea89df11176b9fc5793bdbd8ef118437661", | |
| 161 | 추가: "verification.json": "6ea314425b09266b1487ccecf5de4ebb2359f0875fe2d52c01eb32644e582658", | |
| 162 | 추가: "evidence-sha256sums": "5cce3913aa81aec56196111ca023698272c75275414b61a9eec0b89dca886108" | |
| 163 | 추가: } | |
| 164 | 추가: } |
| @@ -0,0 +1,305 @@ | ||
| 1 | 추가: use crate::support::*; | |
| 2 | 추가: use publication::{ | |
| 3 | 추가: CancelDecision, Checkpoint, Error, Limits, Publication, Request, Stage, Stop, Usage, | |
| 4 | 추가: }; | |
| 5 | 추가: use std::{ | |
| 6 | 추가: ffi::OsStr, | |
| 7 | 추가: panic::{AssertUnwindSafe, catch_unwind}, | |
| 8 | 추가: path::Path, | |
| 9 | 추가: rc::Rc, | |
| 10 | 추가: time::Duration, | |
| 11 | 추가: }; | |
| 12 | 추가: | |
| 13 | 추가: #[test] | |
| 14 | 추가: fn pre_requested_cancel_is_idempotent_and_stops_before_open() { | |
| 15 | 추가: let (task, cancel) = Publication::new(); | |
| 16 | 추가: assert_eq!(cancel.request(), CancelDecision::Requested); | |
| 17 | 추가: assert_eq!(cancel.clone().request(), CancelDecision::AlreadyRequested); | |
| 18 | 추가: let mut callbacks = 0; | |
| 19 | 추가: let (error, usage, closed) = not_committed(task.publish( | |
| 20 | 추가: Request { | |
| 21 | 추가: parent: Path::new("/owned"), | |
| 22 | 추가: leaf: OsStr::new("unused"), | |
| 23 | 추가: bytes: b"x", | |
| 24 | 추가: limits: Limits::default(), | |
| 25 | 추가: }, | |
| 26 | 추가: |_| { | |
| 27 | 추가: callbacks += 1; | |
| 28 | 추가: Ok::<_, Stop<()>>(()) | |
| 29 | 추가: }, | |
| 30 | 추가: )); | |
| 31 | 추가: assert!(matches!(error, Error::Cancelled)); | |
| 32 | 추가: assert_eq!(callbacks, 1); | |
| 33 | 추가: assert_eq!(usage, Usage::default()); | |
| 34 | 추가: cleanup(&closed, 0); | |
| 35 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 36 | 추가: } | |
| 37 | 추가: | |
| 38 | 추가: fn cancel_at(stage: Stage, occurrence: usize, closes: u8, writes: u64, reads: u64) { | |
| 39 | 추가: let sandbox = Sandbox::new(); | |
| 40 | 추가: let parent = sandbox.parent(); | |
| 41 | 추가: let (task, cancel) = Publication::new(); | |
| 42 | 추가: let mut count = 0; | |
| 43 | 추가: let mut requested = false; | |
| 44 | 추가: let (error, usage, closed) = not_committed(task.publish( | |
| 45 | 추가: Request { | |
| 46 | 추가: parent: &parent, | |
| 47 | 추가: leaf: OsStr::new("output"), | |
| 48 | 추가: bytes: b"abc", | |
| 49 | 추가: limits: Limits::default(), | |
| 50 | 추가: }, | |
| 51 | 추가: |point| { | |
| 52 | 추가: if point.stage == stage { | |
| 53 | 추가: count += 1; | |
| 54 | 추가: if count == occurrence { | |
| 55 | 추가: assert_eq!(cancel.request(), CancelDecision::Requested); | |
| 56 | 추가: requested = true; | |
| 57 | 추가: } | |
| 58 | 추가: } | |
| 59 | 추가: Ok::<_, Stop<()>>(()) | |
| 60 | 추가: }, | |
| 61 | 추가: )); | |
| 62 | 추가: assert!(requested); | |
| 63 | 추가: assert!(matches!(error, Error::Cancelled)); | |
| 64 | 추가: assert_eq!(usage.link_calls, 0); | |
| 65 | 추가: assert_eq!(usage.write_calls, writes); | |
| 66 | 추가: assert_eq!(usage.read_calls, reads); | |
| 67 | 추가: cleanup(&closed, closes); | |
| 68 | 추가: assert!(names(&parent).is_empty()); | |
| 69 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 70 | 추가: sandbox.finish(); | |
| 71 | 추가: } | |
| 72 | 추가: | |
| 73 | 추가: #[test] | |
| 74 | 추가: fn cancel_first_opening_has_no_handles() { | |
| 75 | 추가: cancel_at(Stage::Opening, 1, 0, 0, 0); | |
| 76 | 추가: } | |
| 77 | 추가: #[test] | |
| 78 | 추가: fn cancel_second_opening_closes_parent() { | |
| 79 | 추가: cancel_at(Stage::Opening, 2, 1, 0, 0); | |
| 80 | 추가: } | |
| 81 | 추가: #[test] | |
| 82 | 추가: fn cancel_before_write_closes_anonymous_temp() { | |
| 83 | 추가: cancel_at(Stage::Writing, 1, 2, 0, 0); | |
| 84 | 추가: } | |
| 85 | 추가: #[test] | |
| 86 | 추가: fn cancel_before_sync_preserves_written_usage() { | |
| 87 | 추가: cancel_at(Stage::Verifying, 1, 2, 1, 0); | |
| 88 | 추가: } | |
| 89 | 추가: #[test] | |
| 90 | 추가: fn cancel_before_commit_closes_four_handles_without_link() { | |
| 91 | 추가: cancel_at(Stage::BeforeCommit, 1, 4, 1, 2); | |
| 92 | 추가: } | |
| 93 | 추가: | |
| 94 | 추가: #[test] | |
| 95 | 추가: fn cancel_after_first_chunk_preserves_reservations() { | |
| 96 | 추가: let sandbox = Sandbox::new(); | |
| 97 | 추가: let parent = sandbox.parent(); | |
| 98 | 추가: let (task, _) = Publication::new(); | |
| 99 | 추가: let bytes = pattern(65_537); | |
| 100 | 추가: let (error, usage, closed) = not_committed(task.publish( | |
| 101 | 추가: Request { | |
| 102 | 추가: parent: &parent, | |
| 103 | 추가: leaf: OsStr::new("output"), | |
| 104 | 추가: bytes: &bytes, | |
| 105 | 추가: limits: Limits::default(), | |
| 106 | 추가: }, | |
| 107 | 추가: |point| { | |
| 108 | 추가: if point.stage == Stage::Writing && point.offset == 65_536 { | |
| 109 | 추가: Err(Stop::<()>::Cancelled) | |
| 110 | 추가: } else { | |
| 111 | 추가: Ok(()) | |
| 112 | 추가: } | |
| 113 | 추가: }, | |
| 114 | 추가: )); | |
| 115 | 추가: assert!(matches!(error, Error::Cancelled)); | |
| 116 | 추가: assert_eq!(usage.write_calls, 1); | |
| 117 | 추가: assert_eq!(usage.reserved_io_bytes, 65_536); | |
| 118 | 추가: assert_eq!(usage.actual_written_bytes, 65_536); | |
| 119 | 추가: assert_eq!(usage.read_calls + usage.link_calls + usage.sync_calls, 0); | |
| 120 | 추가: cleanup(&closed, 2); | |
| 121 | 추가: assert!(names(&parent).is_empty()); | |
| 122 | 추가: sandbox.finish(); | |
| 123 | 추가: } | |
| 124 | 추가: | |
| 125 | 추가: #[test] | |
| 126 | 추가: fn callback_preserves_non_send_error_and_wins_over_cancel() { | |
| 127 | 추가: let sandbox = Sandbox::new(); | |
| 128 | 추가: let parent = sandbox.parent(); | |
| 129 | 추가: let marker = Rc::new(String::from("typed-callback")); | |
| 130 | 추가: let (task, cancel) = Publication::new(); | |
| 131 | 추가: let (error, usage, closed) = not_committed(task.publish( | |
| 132 | 추가: Request { | |
| 133 | 추가: parent: &parent, | |
| 134 | 추가: leaf: OsStr::new("output"), | |
| 135 | 추가: bytes: b"abc", | |
| 136 | 추가: limits: Limits::default(), | |
| 137 | 추가: }, | |
| 138 | 추가: |point| { | |
| 139 | 추가: if point.stage == Stage::BeforeCommit { | |
| 140 | 추가: assert_eq!(cancel.request(), CancelDecision::Requested); | |
| 141 | 추가: Err(Stop::Callback(marker.clone())) | |
| 142 | 추가: } else { | |
| 143 | 추가: Ok(()) | |
| 144 | 추가: } | |
| 145 | 추가: }, | |
| 146 | 추가: )); | |
| 147 | 추가: match error { | |
| 148 | 추가: Error::Callback(value) => assert!(Rc::ptr_eq(&value, &marker)), | |
| 149 | 추가: other => panic!("callback error replaced: {other:?}"), | |
| 150 | 추가: } | |
| 151 | 추가: assert_eq!(usage.link_calls, 0); | |
| 152 | 추가: assert_eq!(usage.actual_read_bytes, 3); | |
| 153 | 추가: assert_eq!(usage.actual_written_bytes, 3); | |
| 154 | 추가: cleanup(&closed, 4); | |
| 155 | 추가: assert!(names(&parent).is_empty()); | |
| 156 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 157 | 추가: sandbox.finish(); | |
| 158 | 추가: } | |
| 159 | 추가: | |
| 160 | 추가: #[test] | |
| 161 | 추가: fn callback_panic_has_no_report_or_named_output() { | |
| 162 | 추가: let sandbox = Sandbox::new(); | |
| 163 | 추가: let parent = sandbox.parent(); | |
| 164 | 추가: let (task, cancel) = Publication::new(); | |
| 165 | 추가: let panicked = catch_unwind(AssertUnwindSafe(|| { | |
| 166 | 추가: task.publish( | |
| 167 | 추가: Request { | |
| 168 | 추가: parent: &parent, | |
| 169 | 추가: leaf: OsStr::new("output"), | |
| 170 | 추가: bytes: b"abc", | |
| 171 | 추가: limits: Limits::default(), | |
| 172 | 추가: }, | |
| 173 | 추가: |point| { | |
| 174 | 추가: if point.stage == Stage::BeforeCommit { | |
| 175 | 추가: panic!("intentional-publication-callback-panic"); | |
| 176 | 추가: } | |
| 177 | 추가: Ok::<_, Stop<()>>(()) | |
| 178 | 추가: }, | |
| 179 | 추가: ) | |
| 180 | 추가: })); | |
| 181 | 추가: assert!(panicked.is_err()); | |
| 182 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 183 | 추가: assert!(names(&parent).is_empty()); | |
| 184 | 추가: assert!(owned_descriptors(&sandbox.root).is_empty()); | |
| 185 | 추가: sandbox.finish(); | |
| 186 | 추가: } | |
| 187 | 추가: | |
| 188 | 추가: fn expired(stop: Option<Stop<u16>>) -> Error<u16> { | |
| 189 | 추가: let (task, _) = Publication::new(); | |
| 190 | 추가: let mut stop = Some(stop); | |
| 191 | 추가: let (error, usage, closed) = not_committed(task.publish( | |
| 192 | 추가: Request { | |
| 193 | 추가: parent: Path::new("/owned"), | |
| 194 | 추가: leaf: OsStr::new("unused"), | |
| 195 | 추가: bytes: &[], | |
| 196 | 추가: limits: Limits { | |
| 197 | 추가: max_duration: Duration::from_millis(1), | |
| 198 | 추가: ..Limits::default() | |
| 199 | 추가: }, | |
| 200 | 추가: }, | |
| 201 | 추가: |_| { | |
| 202 | 추가: std::thread::sleep(Duration::from_millis(10)); | |
| 203 | 추가: match stop.take().unwrap() { | |
| 204 | 추가: Some(value) => Err(value), | |
| 205 | 추가: None => Ok(()), | |
| 206 | 추가: } | |
| 207 | 추가: }, | |
| 208 | 추가: )); | |
| 209 | 추가: assert_eq!(usage, Usage::default()); | |
| 210 | 추가: cleanup(&closed, 0); | |
| 211 | 추가: error | |
| 212 | 추가: } | |
| 213 | 추가: | |
| 214 | 추가: #[test] | |
| 215 | 추가: fn natural_elapsed_deadline_stops_before_open() { | |
| 216 | 추가: assert!(matches!(expired(None), Error::DeadlineExceeded)); | |
| 217 | 추가: } | |
| 218 | 추가: #[test] | |
| 219 | 추가: fn callback_cancel_precedes_expired_deadline() { | |
| 220 | 추가: assert!(matches!(expired(Some(Stop::Cancelled)), Error::Cancelled)); | |
| 221 | 추가: } | |
| 222 | 추가: #[test] | |
| 223 | 추가: fn callback_error_precedes_expired_deadline() { | |
| 224 | 추가: assert!(matches!( | |
| 225 | 추가: expired(Some(Stop::Callback(91))), | |
| 226 | 추가: Error::Callback(91) | |
| 227 | 추가: )); | |
| 228 | 추가: } | |
| 229 | 추가: | |
| 230 | 추가: #[test] | |
| 231 | 추가: fn cancellation_after_return_preserves_committed_output() { | |
| 232 | 추가: let sandbox = Sandbox::new(); | |
| 233 | 추가: let parent = sandbox.parent(); | |
| 234 | 추가: let (task, cancel) = Publication::new(); | |
| 235 | 추가: let report = task.publish( | |
| 236 | 추가: Request { | |
| 237 | 추가: parent: &parent, | |
| 238 | 추가: leaf: OsStr::new("output"), | |
| 239 | 추가: bytes: b"abc", | |
| 240 | 추가: limits: Limits::default(), | |
| 241 | 추가: }, | |
| 242 | 추가: |_| Ok::<_, Stop<()>>(()), | |
| 243 | 추가: ); | |
| 244 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 245 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 246 | 추가: committed(report, &parent, OsStr::new("output"), b"abc"); | |
| 247 | 추가: sandbox.finish(); | |
| 248 | 추가: } | |
| 249 | 추가: | |
| 250 | 추가: #[test] | |
| 251 | 추가: fn checkpoints_keep_output_absent_and_close_owned_descriptors() { | |
| 252 | 추가: let sandbox = Sandbox::new(); | |
| 253 | 추가: let parent = sandbox.parent(); | |
| 254 | 추가: let (task, _) = Publication::new(); | |
| 255 | 추가: let mut points: Vec<Checkpoint> = Vec::new(); | |
| 256 | 추가: let report = task.publish( | |
| 257 | 추가: Request { | |
| 258 | 추가: parent: &parent, | |
| 259 | 추가: leaf: OsStr::new("output"), | |
| 260 | 추가: bytes: b"abc", | |
| 261 | 추가: limits: Limits::default(), | |
| 262 | 추가: }, | |
| 263 | 추가: |point| { | |
| 264 | 추가: assert!(names(&parent).is_empty()); | |
| 265 | 추가: if point.stage == Stage::BeforeCommit { | |
| 266 | 추가: assert_eq!(owned_descriptors(&sandbox.root).len(), 2); | |
| 267 | 추가: assert_eq!(point.usage.link_calls, 0); | |
| 268 | 추가: assert_eq!(point.usage.reserved_io_bytes, 7); | |
| 269 | 추가: } | |
| 270 | 추가: points.push(point); | |
| 271 | 추가: Ok::<_, Stop<()>>(()) | |
| 272 | 추가: }, | |
| 273 | 추가: ); | |
| 274 | 추가: assert_eq!( | |
| 275 | 추가: points | |
| 276 | 추가: .iter() | |
| 277 | 추가: .map(|p| (p.stage, p.offset)) | |
| 278 | 추가: .collect::<Vec<_>>(), | |
| 279 | 추가: vec![ | |
| 280 | 추가: (Stage::Opening, 0), | |
| 281 | 추가: (Stage::Opening, 0), | |
| 282 | 추가: (Stage::Writing, 0), | |
| 283 | 추가: (Stage::Verifying, 0), | |
| 284 | 추가: (Stage::Verifying, 0), | |
| 285 | 추가: (Stage::Verifying, 3), | |
| 286 | 추가: (Stage::BeforeCommit, 3), | |
| 287 | 추가: ] | |
| 288 | 추가: ); | |
| 289 | 추가: assert!(points.iter().all(|p| p.length == 3)); | |
| 290 | 추가: for pair in points.windows(2) { | |
| 291 | 추가: assert!(pair[0].usage.reserved_io_bytes <= pair[1].usage.reserved_io_bytes); | |
| 292 | 추가: assert!(pair[0].usage.actual_written_bytes <= pair[1].usage.actual_written_bytes); | |
| 293 | 추가: assert!(pair[0].usage.actual_read_bytes <= pair[1].usage.actual_read_bytes); | |
| 294 | 추가: } | |
| 295 | 추가: assert!(owned_descriptors(&sandbox.root).is_empty()); | |
| 296 | 추가: committed(report, &parent, OsStr::new("output"), b"abc"); | |
| 297 | 추가: sandbox.finish(); | |
| 298 | 추가: } | |
| 299 | 추가: | |
| 300 | 추가: #[test] | |
| 301 | 추가: fn dropping_unused_publication_marks_finished_without_io() { | |
| 302 | 추가: let (task, cancel) = Publication::new(); | |
| 303 | 추가: drop(task); | |
| 304 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 305 | 추가: } |
| @@ -0,0 +1,9 @@ | ||
| 1 | 추가: #![cfg(target_os = "linux")] | |
| 2 | 추가: | |
| 3 | 추가: mod boundaries; | |
| 4 | 추가: mod concurrency; | |
| 5 | 추가: mod control; | |
| 6 | 추가: mod models; | |
| 7 | 추가: mod namespace; | |
| 8 | 추가: mod paths; | |
| 9 | 추가: mod support; |
| @@ -0,0 +1,52 @@ | ||
| 1 | 추가: use publication::{ | |
| 2 | 추가: Cancellation, Cleanup, CloseFailure, FileCommitReceipt, Publication, Report, Resource, | |
| 3 | 추가: }; | |
| 4 | 추가: use std::io; | |
| 5 | 추가: | |
| 6 | 추가: #[test] | |
| 7 | 추가: fn constructed_cleanup_failures_are_never_all_successful() { | |
| 8 | 추가: let cleanup = Cleanup { | |
| 9 | 추가: attempted: 2, | |
| 10 | 추가: failures: [ | |
| 11 | 추가: Some(CloseFailure { | |
| 12 | 추가: resource: Resource::TemporaryFile, | |
| 13 | 추가: source: io::Error::from_raw_os_error(libc::EIO), | |
| 14 | 추가: }), | |
| 15 | 추가: Some(CloseFailure { | |
| 16 | 추가: resource: Resource::ParentDirectory, | |
| 17 | 추가: source: io::Error::from_raw_os_error(libc::EINTR), | |
| 18 | 추가: }), | |
| 19 | 추가: None, | |
| 20 | 추가: None, | |
| 21 | 추가: ], | |
| 22 | 추가: }; | |
| 23 | 추가: assert!(!cleanup.all_close_calls_succeeded()); | |
| 24 | 추가: assert_eq!(cleanup.attempted, 2); | |
| 25 | 추가: assert_eq!( | |
| 26 | 추가: cleanup.failures[0].as_ref().unwrap().resource, | |
| 27 | 추가: Resource::TemporaryFile | |
| 28 | 추가: ); | |
| 29 | 추가: assert_eq!( | |
| 30 | 추가: cleanup.failures[0].as_ref().unwrap().source.raw_os_error(), | |
| 31 | 추가: Some(libc::EIO) | |
| 32 | 추가: ); | |
| 33 | 추가: assert_eq!( | |
| 34 | 추가: cleanup.failures[1].as_ref().unwrap().source.raw_os_error(), | |
| 35 | 추가: Some(libc::EINTR) | |
| 36 | 추가: ); | |
| 37 | 추가: let empty = Cleanup { | |
| 38 | 추가: attempted: 0, | |
| 39 | 추가: failures: [None, None, None, None], | |
| 40 | 추가: }; | |
| 41 | 추가: assert!(empty.all_close_calls_succeeded()); | |
| 42 | 추가: assert_eq!(empty.attempted, 0); | |
| 43 | 추가: } | |
| 44 | 추가: | |
| 45 | 추가: #[test] | |
| 46 | 추가: fn public_types_support_transfer_without_forging_receipts() { | |
| 47 | 추가: fn send<T: Send>() {} | |
| 48 | 추가: send::<Publication>(); | |
| 49 | 추가: send::<Cancellation>(); | |
| 50 | 추가: send::<Report<()>>(); | |
| 51 | 추가: send::<FileCommitReceipt>(); | |
| 52 | 추가: } |
| @@ -0,0 +1,122 @@ | ||
| 1 | 추가: use crate::support::*; | |
| 2 | 추가: use publication::{CancelDecision, Limits, Outcome, Publication, Request, Stage, Stop}; | |
| 3 | 추가: use std::{ffi::OsStr, fs, os::unix::fs::MetadataExt}; | |
| 4 | 추가: | |
| 5 | 추가: fn replace_parent(stage: Stage) { | |
| 6 | 추가: let sandbox = Sandbox::new(); | |
| 7 | 추가: let parent = sandbox.parent(); | |
| 8 | 추가: let before = fs::metadata(&parent).unwrap(); | |
| 9 | 추가: let moved = sandbox.path("moved"); | |
| 10 | 추가: let mut opening = 0; | |
| 11 | 추가: let mut changed = false; | |
| 12 | 추가: let (task, _) = Publication::new(); | |
| 13 | 추가: let report = task.publish( | |
| 14 | 추가: Request { | |
| 15 | 추가: parent: &parent, | |
| 16 | 추가: leaf: OsStr::new("output"), | |
| 17 | 추가: bytes: b"new-output", | |
| 18 | 추가: limits: Limits::default(), | |
| 19 | 추가: }, | |
| 20 | 추가: |point| { | |
| 21 | 추가: if point.stage == Stage::Opening { | |
| 22 | 추가: opening += 1; | |
| 23 | 추가: } | |
| 24 | 추가: if !changed && point.stage == stage && (stage != Stage::Opening || opening == 2) { | |
| 25 | 추가: fs::rename(&parent, &moved).unwrap(); | |
| 26 | 추가: sandbox.dir("parent"); | |
| 27 | 추가: sandbox.file("parent/output", b"replacement-parent"); | |
| 28 | 추가: changed = true; | |
| 29 | 추가: } | |
| 30 | 추가: Ok::<_, Stop<()>>(()) | |
| 31 | 추가: }, | |
| 32 | 추가: ); | |
| 33 | 추가: assert!(changed); | |
| 34 | 추가: assert_eq!( | |
| 35 | 추가: ( | |
| 36 | 추가: fs::metadata(&moved).unwrap().dev(), | |
| 37 | 추가: fs::metadata(&moved).unwrap().ino() | |
| 38 | 추가: ), | |
| 39 | 추가: (before.dev(), before.ino()) | |
| 40 | 추가: ); | |
| 41 | 추가: assert_eq!( | |
| 42 | 추가: fs::read(parent.join("output")).unwrap(), | |
| 43 | 추가: b"replacement-parent" | |
| 44 | 추가: ); | |
| 45 | 추가: committed(report, &moved, OsStr::new("output"), b"new-output"); | |
| 46 | 추가: sandbox.finish(); | |
| 47 | 추가: } | |
| 48 | 추가: | |
| 49 | 추가: #[test] | |
| 50 | 추가: fn parent_replaced_after_open_commits_to_held_directory() { | |
| 51 | 추가: replace_parent(Stage::Opening); | |
| 52 | 추가: } | |
| 53 | 추가: | |
| 54 | 추가: #[test] | |
| 55 | 추가: fn parent_replaced_before_commit_keeps_receipt_on_old_parent() { | |
| 56 | 추가: replace_parent(Stage::BeforeCommit); | |
| 57 | 추가: } | |
| 58 | 추가: | |
| 59 | 추가: #[test] | |
| 60 | 추가: fn destination_created_at_last_checkpoint_is_preserved() { | |
| 61 | 추가: let sandbox = Sandbox::new(); | |
| 62 | 추가: let parent = sandbox.parent(); | |
| 63 | 추가: let (task, _) = Publication::new(); | |
| 64 | 추가: let mut inserted = false; | |
| 65 | 추가: let report = task.publish( | |
| 66 | 추가: Request { | |
| 67 | 추가: parent: &parent, | |
| 68 | 추가: leaf: OsStr::new("output"), | |
| 69 | 추가: bytes: b"new", | |
| 70 | 추가: limits: Limits::default(), | |
| 71 | 추가: }, | |
| 72 | 추가: |point| { | |
| 73 | 추가: if point.stage == Stage::BeforeCommit { | |
| 74 | 추가: sandbox.file("parent/output", b"late-existing"); | |
| 75 | 추가: inserted = true; | |
| 76 | 추가: } | |
| 77 | 추가: Ok::<_, Stop<()>>(()) | |
| 78 | 추가: }, | |
| 79 | 추가: ); | |
| 80 | 추가: assert!(inserted); | |
| 81 | 추가: conflict(report, 3); | |
| 82 | 추가: assert_eq!(fs::read(parent.join("output")).unwrap(), b"late-existing"); | |
| 83 | 추가: sandbox.finish(); | |
| 84 | 추가: } | |
| 85 | 추가: | |
| 86 | 추가: #[test] | |
| 87 | 추가: fn removed_parent_returns_uncertain_original_errno_without_receipt() { | |
| 88 | 추가: let sandbox = Sandbox::new(); | |
| 89 | 추가: let parent = sandbox.parent(); | |
| 90 | 추가: let (task, cancel) = Publication::new(); | |
| 91 | 추가: let mut removed = false; | |
| 92 | 추가: let report = task.publish( | |
| 93 | 추가: Request { | |
| 94 | 추가: parent: &parent, | |
| 95 | 추가: leaf: OsStr::new("output"), | |
| 96 | 추가: bytes: b"abc", | |
| 97 | 추가: limits: Limits::default(), | |
| 98 | 추가: }, | |
| 99 | 추가: |point| { | |
| 100 | 추가: if point.stage == Stage::BeforeCommit { | |
| 101 | 추가: assert!(names(&parent).is_empty()); | |
| 102 | 추가: fs::remove_dir(&parent).unwrap(); | |
| 103 | 추가: removed = true; | |
| 104 | 추가: } | |
| 105 | 추가: Ok::<_, Stop<()>>(()) | |
| 106 | 추가: }, | |
| 107 | 추가: ); | |
| 108 | 추가: assert!(removed); | |
| 109 | 추가: match report.outcome { | |
| 110 | 추가: Outcome::CommitUncertain { source } => { | |
| 111 | 추가: assert_eq!(source.raw_os_error(), Some(libc::ENOENT)) | |
| 112 | 추가: } | |
| 113 | 추가: Outcome::NotCommitted(error) => panic!("uncertainty erased: {error:?}"), | |
| 114 | 추가: Outcome::Committed { .. } => panic!("unexpected receipt"), | |
| 115 | 추가: } | |
| 116 | 추가: full_usage(report.usage, 3, false); | |
| 117 | 추가: cleanup(&report.cleanup, 4); | |
| 118 | 추가: assert_eq!(cancel.request(), CancelDecision::Finished); | |
| 119 | 추가: assert!(!parent.exists()); | |
| 120 | 추가: assert!(names(&sandbox.root).is_empty()); | |
| 121 | 추가: sandbox.finish(); | |
| 122 | 추가: } |
| @@ -0,0 +1,267 @@ | ||
| 1 | 추가: use crate::support::*; | |
| 2 | 추가: use publication::{Error, Limits, Publication, Request, Stop, Usage}; | |
| 3 | 추가: use std::{ | |
| 4 | 추가: ffi::{CString, OsStr, OsString}, | |
| 5 | 추가: fs, | |
| 6 | 추가: os::unix::{ | |
| 7 | 추가: ffi::{OsStrExt, OsStringExt}, | |
| 8 | 추가: fs::{MetadataExt, symlink}, | |
| 9 | 추가: net::UnixListener, | |
| 10 | 추가: }, | |
| 11 | 추가: path::{Path, PathBuf}, | |
| 12 | 추가: }; | |
| 13 | 추가: | |
| 14 | 추가: fn invalid(parent: &Path, leaf: &OsStr) { | |
| 15 | 추가: let (task, _) = Publication::new(); | |
| 16 | 추가: let (error, usage, closed) = not_committed(task.publish( | |
| 17 | 추가: Request { | |
| 18 | 추가: parent, | |
| 19 | 추가: leaf, | |
| 20 | 추가: bytes: b"abc", | |
| 21 | 추가: limits: Limits::default(), | |
| 22 | 추가: }, | |
| 23 | 추가: |_| -> Result<(), Stop<()>> { panic!("invalid path callback") }, | |
| 24 | 추가: )); | |
| 25 | 추가: assert!(matches!(error, Error::InvalidPath)); | |
| 26 | 추가: assert_eq!(usage, Usage::default()); | |
| 27 | 추가: cleanup(&closed, 0); | |
| 28 | 추가: } | |
| 29 | 추가: | |
| 30 | 추가: #[test] | |
| 31 | 추가: fn invalid_parent_forms_rejected_before_callback() { | |
| 32 | 추가: for value in [ | |
| 33 | 추가: "", | |
| 34 | 추가: "relative", | |
| 35 | 추가: "/owned/./x", | |
| 36 | 추가: "/owned/../x", | |
| 37 | 추가: "/owned//x", | |
| 38 | 추가: "/owned/", | |
| 39 | 추가: "/owned/\0x", | |
| 40 | 추가: ] { | |
| 41 | 추가: invalid(Path::new(value), OsStr::new("output")); | |
| 42 | 추가: } | |
| 43 | 추가: invalid( | |
| 44 | 추가: &PathBuf::from(format!("/{}", "x".repeat(4095))), | |
| 45 | 추가: OsStr::new("output"), | |
| 46 | 추가: ); | |
| 47 | 추가: } | |
| 48 | 추가: | |
| 49 | 추가: #[test] | |
| 50 | 추가: fn invalid_leaf_forms_rejected_before_callback() { | |
| 51 | 추가: for value in ["", ".", "..", "a/b", "/absolute", "nul\0byte"] { | |
| 52 | 추가: invalid(Path::new("/owned"), OsStr::new(value)); | |
| 53 | 추가: } | |
| 54 | 추가: invalid(Path::new("/owned"), OsStr::new(&"x".repeat(256))); | |
| 55 | 추가: } | |
| 56 | 추가: | |
| 57 | 추가: #[test] | |
| 58 | 추가: fn root_parent_is_lexically_valid_without_opening_root() { | |
| 59 | 추가: let (task, _) = Publication::new(); | |
| 60 | 추가: let (error, usage, closed) = not_committed(task.publish( | |
| 61 | 추가: Request { | |
| 62 | 추가: parent: Path::new("/"), | |
| 63 | 추가: leaf: OsStr::new("unused"), | |
| 64 | 추가: bytes: &[], | |
| 65 | 추가: limits: Limits::default(), | |
| 66 | 추가: }, | |
| 67 | 추가: |_| Err(Stop::<()>::Cancelled), | |
| 68 | 추가: )); | |
| 69 | 추가: assert!(matches!(error, Error::Cancelled)); | |
| 70 | 추가: assert_eq!(usage, Usage::default()); | |
| 71 | 추가: cleanup(&closed, 0); | |
| 72 | 추가: } | |
| 73 | 추가: | |
| 74 | 추가: fn open_error(parent: &Path, expected: i32) { | |
| 75 | 추가: let (error, usage, closed) = not_committed(publish( | |
| 76 | 추가: parent, | |
| 77 | 추가: OsStr::new("output"), | |
| 78 | 추가: b"abc", | |
| 79 | 추가: Limits::default(), | |
| 80 | 추가: )); | |
| 81 | 추가: match error { | |
| 82 | 추가: Error::Io { operation, source } => { | |
| 83 | 추가: assert_eq!(operation, "openat2"); | |
| 84 | 추가: assert_eq!(source.raw_os_error(), Some(expected)); | |
| 85 | 추가: } | |
| 86 | 추가: other => panic!("unexpected: {other:?}"), | |
| 87 | 추가: } | |
| 88 | 추가: assert_eq!(usage.open_calls, 1); | |
| 89 | 추가: assert_eq!( | |
| 90 | 추가: usage.metadata_calls + usage.link_calls + usage.write_calls + usage.read_calls, | |
| 91 | 추가: 0 | |
| 92 | 추가: ); | |
| 93 | 추가: cleanup(&closed, 0); | |
| 94 | 추가: } | |
| 95 | 추가: | |
| 96 | 추가: #[test] | |
| 97 | 추가: fn missing_and_regular_parent_preserve_errno() { | |
| 98 | 추가: let sandbox = Sandbox::new(); | |
| 99 | 추가: open_error(&sandbox.path("missing"), libc::ENOENT); | |
| 100 | 추가: let regular = sandbox.file("regular", b"untouched"); | |
| 101 | 추가: open_error(®ular, libc::ENOTDIR); | |
| 102 | 추가: assert_eq!(fs::read(regular).unwrap(), b"untouched"); | |
| 103 | 추가: assert!(names(&sandbox.parent()).is_empty()); | |
| 104 | 추가: sandbox.finish(); | |
| 105 | 추가: } | |
| 106 | 추가: | |
| 107 | 추가: #[test] | |
| 108 | 추가: fn parent_and_ancestor_symlinks_rejected() { | |
| 109 | 추가: let sandbox = Sandbox::new(); | |
| 110 | 추가: let link = sandbox.path("alias"); | |
| 111 | 추가: symlink(sandbox.parent(), &link).unwrap(); | |
| 112 | 추가: open_error(&link, libc::ELOOP); | |
| 113 | 추가: let ancestor = sandbox.path("ancestor"); | |
| 114 | 추가: symlink(&sandbox.root, &ancestor).unwrap(); | |
| 115 | 추가: open_error(&ancestor.join("parent"), libc::ELOOP); | |
| 116 | 추가: assert!(names(&sandbox.parent()).is_empty()); | |
| 117 | 추가: sandbox.finish(); | |
| 118 | 추가: } | |
| 119 | 추가: | |
| 120 | 추가: #[test] | |
| 121 | 추가: fn non_utf8_leaf_and_parent_are_supported() { | |
| 122 | 추가: let sandbox = Sandbox::new(); | |
| 123 | 추가: let parent_name = OsString::from_vec(vec![b'p', 0xfe]); | |
| 124 | 추가: let parent = sandbox.dir(Path::new(&parent_name)); | |
| 125 | 추가: let leaf = OsString::from_vec(vec![b'o', 0xff]); | |
| 126 | 추가: committed( | |
| 127 | 추가: publish(&parent, &leaf, b"abc", Limits::default()), | |
| 128 | 추가: &parent, | |
| 129 | 추가: &leaf, | |
| 130 | 추가: b"abc", | |
| 131 | 추가: ); | |
| 132 | 추가: sandbox.finish(); | |
| 133 | 추가: } | |
| 134 | 추가: | |
| 135 | 추가: #[test] | |
| 136 | 추가: fn maximum_leaf_length_is_supported() { | |
| 137 | 추가: let sandbox = Sandbox::new(); | |
| 138 | 추가: let leaf = OsString::from("x".repeat(255)); | |
| 139 | 추가: let parent = sandbox.parent(); | |
| 140 | 추가: committed( | |
| 141 | 추가: publish(&parent, &leaf, b"abc", Limits::default()), | |
| 142 | 추가: &parent, | |
| 143 | 추가: &leaf, | |
| 144 | 추가: b"abc", | |
| 145 | 추가: ); | |
| 146 | 추가: sandbox.finish(); | |
| 147 | 추가: } | |
| 148 | 추가: | |
| 149 | 추가: #[test] | |
| 150 | 추가: fn linux_backslash_and_colon_are_leaf_bytes() { | |
| 151 | 추가: let sandbox = Sandbox::new(); | |
| 152 | 추가: let parent = sandbox.parent(); | |
| 153 | 추가: let leaf = OsStr::new("a\\b:c"); | |
| 154 | 추가: committed( | |
| 155 | 추가: publish(&parent, leaf, b"abc", Limits::default()), | |
| 156 | 추가: &parent, | |
| 157 | 추가: leaf, | |
| 158 | 추가: b"abc", | |
| 159 | 추가: ); | |
| 160 | 추가: sandbox.finish(); | |
| 161 | 추가: } | |
| 162 | 추가: | |
| 163 | 추가: #[derive(Clone, Copy)] | |
| 164 | 추가: enum Existing { | |
| 165 | 추가: Regular, | |
| 166 | 추가: Directory, | |
| 167 | 추가: Symlink, | |
| 168 | 추가: Dangling, | |
| 169 | 추가: HardLink, | |
| 170 | 추가: Fifo, | |
| 171 | 추가: Socket, | |
| 172 | 추가: } | |
| 173 | 추가: | |
| 174 | 추가: fn existing(kind: Existing) { | |
| 175 | 추가: let sandbox = Sandbox::new(); | |
| 176 | 추가: let parent = sandbox.parent(); | |
| 177 | 추가: let leaf = OsStr::new("output"); | |
| 178 | 추가: let output = parent.join(leaf); | |
| 179 | 추가: let sentinel = sandbox.file("sentinel", b"untouched"); | |
| 180 | 추가: let mut listener = None; | |
| 181 | 추가: match kind { | |
| 182 | 추가: Existing::Regular => { | |
| 183 | 추가: sandbox.file("parent/output", b"existing"); | |
| 184 | 추가: } | |
| 185 | 추가: Existing::Directory => { | |
| 186 | 추가: sandbox.dir("parent/output"); | |
| 187 | 추가: sandbox.file("parent/output/child", b"child"); | |
| 188 | 추가: } | |
| 189 | 추가: Existing::Symlink => symlink(&sentinel, &output).unwrap(), | |
| 190 | 추가: Existing::Dangling => symlink(sandbox.path("missing"), &output).unwrap(), | |
| 191 | 추가: Existing::HardLink => fs::hard_link(&sentinel, &output).unwrap(), | |
| 192 | 추가: Existing::Fifo => { | |
| 193 | 추가: let raw = CString::new(output.as_os_str().as_bytes()).unwrap(); | |
| 194 | 추가: // 작업 전용 이름의 합성 FIFO만 생성함. | |
| 195 | 추가: assert_eq!(unsafe { libc::mkfifo(raw.as_ptr(), 0o600) }, 0); | |
| 196 | 추가: } | |
| 197 | 추가: Existing::Socket => { | |
| 198 | 추가: listener = Some(UnixListener::bind(&output).unwrap()); | |
| 199 | 추가: } | |
| 200 | 추가: } | |
| 201 | 추가: let before = fs::symlink_metadata(&output).unwrap(); | |
| 202 | 추가: conflict( | |
| 203 | 추가: publish(&parent, leaf, b"replacement", Limits::default()), | |
| 204 | 추가: 11, | |
| 205 | 추가: ); | |
| 206 | 추가: let after = fs::symlink_metadata(&output).unwrap(); | |
| 207 | 추가: assert_eq!( | |
| 208 | 추가: ( | |
| 209 | 추가: before.dev(), | |
| 210 | 추가: before.ino(), | |
| 211 | 추가: before.mode(), | |
| 212 | 추가: before.nlink(), | |
| 213 | 추가: before.len() | |
| 214 | 추가: ), | |
| 215 | 추가: ( | |
| 216 | 추가: after.dev(), | |
| 217 | 추가: after.ino(), | |
| 218 | 추가: after.mode(), | |
| 219 | 추가: after.nlink(), | |
| 220 | 추가: after.len() | |
| 221 | 추가: ) | |
| 222 | 추가: ); | |
| 223 | 추가: assert_eq!(fs::read(&sentinel).unwrap(), b"untouched"); | |
| 224 | 추가: match kind { | |
| 225 | 추가: Existing::Regular => assert_eq!(fs::read(&output).unwrap(), b"existing"), | |
| 226 | 추가: Existing::Directory => { | |
| 227 | 추가: assert_eq!(names(&output), vec![OsString::from("child")]); | |
| 228 | 추가: assert_eq!(fs::read(output.join("child")).unwrap(), b"child"); | |
| 229 | 추가: } | |
| 230 | 추가: Existing::Symlink => assert_eq!(fs::read_link(&output).unwrap(), sentinel), | |
| 231 | 추가: Existing::Dangling => assert_eq!(fs::read_link(&output).unwrap(), sandbox.path("missing")), | |
| 232 | 추가: Existing::HardLink => assert_eq!(fs::read(&output).unwrap(), b"untouched"), | |
| 233 | 추가: Existing::Fifo | Existing::Socket => {} | |
| 234 | 추가: } | |
| 235 | 추가: assert_eq!(names(&parent), vec![leaf.to_os_string()]); | |
| 236 | 추가: drop(listener); | |
| 237 | 추가: sandbox.finish(); | |
| 238 | 추가: } | |
| 239 | 추가: | |
| 240 | 추가: #[test] | |
| 241 | 추가: fn existing_regular_file_preserved() { | |
| 242 | 추가: existing(Existing::Regular); | |
| 243 | 추가: } | |
| 244 | 추가: #[test] | |
| 245 | 추가: fn existing_directory_and_child_preserved() { | |
| 246 | 추가: existing(Existing::Directory); | |
| 247 | 추가: } | |
| 248 | 추가: #[test] | |
| 249 | 추가: fn existing_symlink_and_target_preserved() { | |
| 250 | 추가: existing(Existing::Symlink); | |
| 251 | 추가: } | |
| 252 | 추가: #[test] | |
| 253 | 추가: fn dangling_symlink_preserved() { | |
| 254 | 추가: existing(Existing::Dangling); | |
| 255 | 추가: } | |
| 256 | 추가: #[test] | |
| 257 | 추가: fn existing_hard_links_preserved() { | |
| 258 | 추가: existing(Existing::HardLink); | |
| 259 | 추가: } | |
| 260 | 추가: #[test] | |
| 261 | 추가: fn existing_fifo_preserved_without_opening_it() { | |
| 262 | 추가: existing(Existing::Fifo); | |
| 263 | 추가: } | |
| 264 | 추가: #[test] | |
| 265 | 추가: fn existing_socket_preserved_without_accepting_connections() { | |
| 266 | 추가: existing(Existing::Socket); | |
| 267 | 추가: } |
| @@ -0,0 +1,54 @@ | ||
| 1 | 추가: { | |
| 2 | 추가: "schema": "zipelo.file-publication.execution-plan.v1", | |
| 3 | 추가: "gate": "Compile/no-run/discovery and any candidate publication execution require separate review of the fixed test head and manifest. No Rust execution at source/static stage.", | |
| 4 | 추가: "target": "publication_public_api", | |
| 5 | 추가: "scope": "Only the new tests/rust-file-publication tree and its synthetic runs. No retained snapshot paths modified. Local raw logs/binary only; no independent transfer.", | |
| 6 | 추가: "preflight": [ | |
| 7 | 추가: "Hold the current room's blocking exclusive flock during every shared build/cache/fixture/log mutation, re-read git status and pinned inputs inside the lock.", | |
| 8 | 추가: "Verify 10 fixed production files, source manifest, test manifest and all deliverables. Pin head, bytes, SHA256, Git blob/mode, environment allowlist and existing toolchain versions.", | |
| 9 | 추가: "Refuse a preexisting nonempty runs path, any symlink/path escape, wrong owner/mode or unknown supported-filesystem status. Fresh run ID and exclusive artifact directory; no reuse after failure.", | |
| 10 | 추가: "Use installed 1.99.1-x86_64-unknown-linux-gnu and existing libc cache, no install/network/fallback. CARGO_NET_OFFLINE=true, dedicated target below this test root.", | |
| 11 | 추가: "Linux ef53/ext-family or XFS magic is a prerequisite only. The first real test may still fail on O_TMPFILE/linkat/fsync; preserve and stop." | |
| 12 | 추가: ], | |
| 13 | 추가: "order": [ | |
| 14 | 추가: "Locked/offline cargo test --no-run for exactly the single explicit test target.", | |
| 15 | 추가: "Extract the unique executable artifact from cargo JSON; require its path below the dedicated target and record SHA256.", | |
| 16 | 추가: "Run --list --format terse once. Validate every nonempty line, unique exact names and complete set of 54.", | |
| 17 | 추가: "Run each sorted name exactly once with --exact NAME --test-threads=1 --nocapture. Each success must have exactly one expected name and 1 passed/0 failed/0 ignored/0 measured/53 filtered.", | |
| 18 | 추가: "After each child: collect wait exit and pipe EOF, rehash frozen inputs and binary, inspect runs without following links or reading special files. Stop on nonzero, unknown result, mismatch, residue or cap.", | |
| 19 | 추가: "Keep raw logs, exact names/classes and source-before/after/binary hashes. Do not rerun or change expectations after first failure." | |
| 20 | 추가: ], | |
| 21 | 추가: "commands": [ | |
| 22 | 추가: "CARGO_TARGET_DIR=tests/rust-file-publication/target cargo test --manifest-path tests/rust-file-publication/Cargo.toml --locked --offline --test publication_public_api --no-run --message-format=json", | |
| 23 | 추가: "<fixed-binary> --list --format terse", | |
| 24 | 추가: "<fixed-binary> --exact <contract-name> --test-threads=1 --nocapture" | |
| 25 | 추가: ], | |
| 26 | 추가: "bounds": { | |
| 27 | 추가: "compile_seconds": 120, | |
| 28 | 추가: "discovery_seconds": 30, | |
| 29 | 추가: "per_case_seconds": 30, | |
| 30 | 추가: "channel_wait_seconds": 5, | |
| 31 | 추가: "cleanup_observation_seconds": 10, | |
| 32 | 추가: "per_command_log_bytes": 8388608, | |
| 33 | 추가: "synthetic_case_bytes": 134217728, | |
| 34 | 추가: "publishers_per_collision_case": 2, | |
| 35 | 추가: "other_cases_parallelism": 1, | |
| 36 | 추가: "termination_grace_seconds": 2, | |
| 37 | 추가: "reap_grace_seconds": 5 | |
| 38 | 추가: }, | |
| 39 | 추가: "enforcement": "Use a parent command supervisor with bounded streaming stdout/stderr, elapsed deadlines and retained prefix on overflow. On failure signal only the harness-owned child/process group, record termination and bounded reap separately. Never assert that timeout interrupts uninterruptible I/O. Logical synthetic sizes can be monitored but are not a filesystem quota.", | |
| 40 | 추가: "cleanup": "All Rust assertions precede Sandbox::finish. Successful case directories removed explicitly; empty runs owner root and evidence/target retained. No cleanup on failed assertions/panic. On interruption or timeout preserve remaining paths; do not remove uncertain/replaced paths. join follows bounded response receipt; external process limit bounds observation if join does not return.", | |
| 41 | 추가: "unsupported": "Fail/stop, not ignore, mock success or weaker fallback. No security/permission changes, mounts, proc substitution, launcher or Windows/VM operations.", | |
| 42 | 추가: "report_fields": [ | |
| 43 | 추가: "head", | |
| 44 | 추가: "manifest SHA256", | |
| 45 | 추가: "commands/cwd/env allowlist", | |
| 46 | 추가: "exact discovered/executed/passed/failed/ignored/filtered names", | |
| 47 | 추가: "evidence classes", | |
| 48 | 추가: "raw stdout/stderr hashes", | |
| 49 | 추가: "binary hash", | |
| 50 | 추가: "input before/after hashes", | |
| 51 | 추가: "residual paths and process/reap state", | |
| 52 | 추가: "unverified boundaries" | |
| 53 | 추가: ] | |
| 54 | 추가: } |
| @@ -0,0 +1,65 @@ | ||
| 1 | 추가: { | |
| 2 | 추가: "head": "10dc446c90d3527437298cff270b26d2e196a748", | |
| 3 | 추가: "files": [ | |
| 4 | 추가: { | |
| 5 | 추가: "path": "experiments/rust-file-publication/Cargo.lock", | |
| 6 | 추가: "mode": "100644", | |
| 7 | 추가: "git_blob": "207c18a163029bf5059414e443d47340f701973e", | |
| 8 | 추가: "sha256": "b38bcde0e0c7286f53254ecbc357a55a0b18e803fd7294dec1025fcb34eb6092" | |
| 9 | 추가: }, | |
| 10 | 추가: { | |
| 11 | 추가: "path": "experiments/rust-file-publication/Cargo.toml", | |
| 12 | 추가: "mode": "100644", | |
| 13 | 추가: "git_blob": "769cad258dde0179ea8e32bd3d13a7579a791497", | |
| 14 | 추가: "sha256": "e6d911fb2c215dcab367116b0eac2544a3e37abe0d69ba6f0323c0d0308b329d" | |
| 15 | 추가: }, | |
| 16 | 추가: { | |
| 17 | 추가: "path": "experiments/rust-file-publication/LICENSE", | |
| 18 | 추가: "mode": "100644", | |
| 19 | 추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc", | |
| 20 | 추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62" | |
| 21 | 추가: }, | |
| 22 | 추가: { | |
| 23 | 추가: "path": "experiments/rust-file-publication/SHA256SUMS", | |
| 24 | 추가: "mode": "100644", | |
| 25 | 추가: "git_blob": "b77cca2d6328d6c4512e3c62a65ca0b032937836", | |
| 26 | 추가: "sha256": "cc4e4cc64a8f3b537df554c7d2895ea3722fbfb0906f1ada767d5cf9b5d8bbc6" | |
| 27 | 추가: }, | |
| 28 | 추가: { | |
| 29 | 추가: "path": "experiments/rust-file-publication/THIRD-PARTY-NOTICES.txt", | |
| 30 | 추가: "mode": "100644", | |
| 31 | 추가: "git_blob": "fba3cf10cd0ff76bb025c1ff9cee6f17b4844197", | |
| 32 | 추가: "sha256": "83bd16a9177040f87f726c5ff9c0e14e7e3fc0096c743abe0d7b1b97ab1fc425" | |
| 33 | 추가: }, | |
| 34 | 추가: { | |
| 35 | 추가: "path": "experiments/rust-file-publication/contract.json", | |
| 36 | 추가: "mode": "100644", | |
| 37 | 추가: "git_blob": "e348369c0f9f0f0bb5bab9b26b4ed4659aac134b", | |
| 38 | 추가: "sha256": "fc091b378311e5a5898f770b4a91317ada5d2daebbb3cfb795e1026736334161" | |
| 39 | 추가: }, | |
| 40 | 추가: { | |
| 41 | 추가: "path": "experiments/rust-file-publication/dependencies.json", | |
| 42 | 추가: "mode": "100644", | |
| 43 | 추가: "git_blob": "85b978be36080547024565031bc6a433e6a4b321", | |
| 44 | 추가: "sha256": "75757b6b770ea09d7b345ca3beaf3d75fdbbe7c792d00d3aec7465b9968ce4f5" | |
| 45 | 추가: }, | |
| 46 | 추가: { | |
| 47 | 추가: "path": "experiments/rust-file-publication/src/lib.rs", | |
| 48 | 추가: "mode": "100644", | |
| 49 | 추가: "git_blob": "19dcc817be97c8cbb18cb863b98ce6524e164406", | |
| 50 | 추가: "sha256": "8304a9c37e8d0a2e21f6657483c58d28c23ba4a4c2ed9ae7e43d389d0f3c2bc3" | |
| 51 | 추가: }, | |
| 52 | 추가: { | |
| 53 | 추가: "path": "experiments/rust-file-publication/src/linux.rs", | |
| 54 | 추가: "mode": "100644", | |
| 55 | 추가: "git_blob": "75a7194329af66458195b08e64d3e96a08495110", | |
| 56 | 추가: "sha256": "75225159189cb2418b24c5e35c4db804dfe2f0171bf957f59578ae284f046d0c" | |
| 57 | 추가: }, | |
| 58 | 추가: { | |
| 59 | 추가: "path": "experiments/rust-file-publication/static-validation.json", | |
| 60 | 추가: "mode": "100644", | |
| 61 | 추가: "git_blob": "7ac04313d01dd90ac905275c2e08cd2991789656", | |
| 62 | 추가: "sha256": "75ed00e7059990abe5c3ba7bc0aae87801e3ffa915824c900d09ed31a61f8159" | |
| 63 | 추가: } | |
| 64 | 추가: ] | |
| 65 | 추가: } |
| @@ -0,0 +1,136 @@ | ||
| 1 | 추가: import argparse | |
| 2 | 추가: import hashlib | |
| 3 | 추가: import json | |
| 4 | 추가: import pathlib | |
| 5 | 추가: import re | |
| 6 | 추가: import stat | |
| 7 | 추가: import sys | |
| 8 | 추가: import tomllib | |
| 9 | 추가: | |
| 10 | 추가: BASE = pathlib.Path(__file__).resolve().parent | |
| 11 | 추가: ROOT = BASE.parents[1] | |
| 12 | 추가: SOURCE = ROOT / "experiments/rust-file-publication" | |
| 13 | 추가: HEAD = "10dc446c90d3527437298cff270b26d2e196a748" | |
| 14 | 추가: SOURCE_MANIFEST = "cc4e4cc64a8f3b537df554c7d2895ea3722fbfb0906f1ada767d5cf9b5d8bbc6" | |
| 15 | 추가: FILES = { | |
| 16 | 추가: "Cargo.toml", "Cargo.lock", "main.rs", "support.rs", "boundaries.rs", | |
| 17 | 추가: "paths.rs", "namespace.rs", "control.rs", "concurrency.rs", "models.rs", | |
| 18 | 추가: "source-pins.json", "contract.json", "run-plan.json", "static_check.py", | |
| 19 | 추가: "static_check_helper_tests.py", | |
| 20 | 추가: } | |
| 21 | 추가: MODULES = ("boundaries", "paths", "namespace", "control", "concurrency", "models") | |
| 22 | 추가: GUARD = "최적화 모드에서는 정적 검사를 실행할 수 없음" | |
| 23 | 추가: | |
| 24 | 추가: def require(condition, message): | |
| 25 | 추가: if not condition: | |
| 26 | 추가: raise RuntimeError(message) | |
| 27 | 추가: | |
| 28 | 추가: def digest(raw): | |
| 29 | 추가: return hashlib.sha256(raw).hexdigest() | |
| 30 | 추가: | |
| 31 | 추가: def parse_manifest(text, expected_paths): | |
| 32 | 추가: rows = {} | |
| 33 | 추가: for line in text.splitlines(): | |
| 34 | 추가: match = re.fullmatch(r"([0-9a-f]{64}) ([A-Za-z0-9_./-]+)", line) | |
| 35 | 추가: require(match is not None, "잘못된 manifest 행") | |
| 36 | 추가: value, name = match.groups() | |
| 37 | 추가: path = pathlib.PurePosixPath(name) | |
| 38 | 추가: require(not path.is_absolute() and ".." not in path.parts | |
| 39 | 추가: and str(path) == name and name not in rows, "중복 또는 잘못된 경로") | |
| 40 | 추가: rows[name] = value | |
| 41 | 추가: require(set(rows) == set(expected_paths), "manifest 경로 불일치") | |
| 42 | 추가: return rows | |
| 43 | 추가: | |
| 44 | 추가: def hashes(): | |
| 45 | 추가: result = {} | |
| 46 | 추가: for name in sorted(FILES | {"SHA256SUMS"}): | |
| 47 | 추가: path = BASE / name | |
| 48 | 추가: require(not path.is_symlink() and stat.S_ISREG(path.lstat().st_mode), "일반 시험 파일 필요") | |
| 49 | 추가: result[name] = digest(path.read_bytes()) | |
| 50 | 추가: return result | |
| 51 | 추가: | |
| 52 | 추가: def verify_sources(): | |
| 53 | 추가: pins = json.loads((BASE / "source-pins.json").read_text()) | |
| 54 | 추가: require(pins["head"] == HEAD and len(pins["files"]) == 10, "고정 source 기준 불일치") | |
| 55 | 추가: names = [row["path"] for row in pins["files"]] | |
| 56 | 추가: require(len(set(names)) == 10, "source 경로 중복") | |
| 57 | 추가: result = {} | |
| 58 | 추가: for row in pins["files"]: | |
| 59 | 추가: path = ROOT / row["path"] | |
| 60 | 추가: require(path.resolve().is_relative_to(SOURCE) and not path.is_symlink(), "source 경로 이탈") | |
| 61 | 추가: info = path.lstat() | |
| 62 | 추가: require(stat.S_ISREG(info.st_mode) and not info.st_mode & 0o111, "source mode 불일치") | |
| 63 | 추가: raw = path.read_bytes() | |
| 64 | 추가: require(digest(raw) == row["sha256"], "source SHA256 불일치") | |
| 65 | 추가: blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() | |
| 66 | 추가: require(blob == row["git_blob"] and row["mode"] == "100644", "source blob 불일치") | |
| 67 | 추가: result[row["path"]] = digest(raw) | |
| 68 | 추가: manifest = (SOURCE / "SHA256SUMS").read_bytes() | |
| 69 | 추가: require(digest(manifest) == SOURCE_MANIFEST, "source manifest 불일치") | |
| 70 | 추가: relative = {str((ROOT / name).relative_to(SOURCE)) for name in names} - {"SHA256SUMS"} | |
| 71 | 추가: entries = parse_manifest(manifest.decode(), relative) | |
| 72 | 추가: for name, value in entries.items(): | |
| 73 | 추가: require(digest((SOURCE / name).read_bytes()) == value, "source manifest 파일 불일치") | |
| 74 | 추가: return result | |
| 75 | 추가: | |
| 76 | 추가: def main(): | |
| 77 | 추가: if sys.flags.optimize: | |
| 78 | 추가: raise RuntimeError(GUARD) | |
| 79 | 추가: parser = argparse.ArgumentParser() | |
| 80 | 추가: parser.add_argument("--manifest-sha256", required=True) | |
| 81 | 추가: parser.add_argument("--metadata", type=pathlib.Path) | |
| 82 | 추가: args = parser.parse_args() | |
| 83 | 추가: before = hashes() | |
| 84 | 추가: require(before["SHA256SUMS"] == args.manifest_sha256, "시험 manifest 불일치") | |
| 85 | 추가: rows = parse_manifest((BASE / "SHA256SUMS").read_text(), FILES) | |
| 86 | 추가: require(all(before[name] == value for name, value in rows.items()), "시험 파일 변경") | |
| 87 | 추가: sources = verify_sources() | |
| 88 | 추가: contract = json.loads((BASE / "contract.json").read_text()) | |
| 89 | 추가: require(contract["source_head"] == HEAD and contract["source_manifest_sha256"] == SOURCE_MANIFEST, "계약 head 불일치") | |
| 90 | 추가: names = [] | |
| 91 | 추가: for module in MODULES: | |
| 92 | 추가: source = (BASE / (module + ".rs")).read_text() | |
| 93 | 추가: found = re.findall(r"#\[test\]\s*fn ([a-z0-9_]+)\(", source) | |
| 94 | 추가: require(len(found) == source.count("#[test]"), "시험 선언 분석 실패") | |
| 95 | 추가: names.extend(module + "::" + name for name in found) | |
| 96 | 추가: require(len(names) == len(set(names)) == contract["declared_test_count"] == 54, "선언 수 불일치") | |
| 97 | 추가: require(sorted(names) == contract["test_names"] == sorted(contract["evidence_classes"]), "이름 집합 불일치") | |
| 98 | 추가: for path in BASE.glob("*.rs"): | |
| 99 | 추가: source = path.read_text() | |
| 100 | 추가: require("#[ignore" not in source and "#[should_panic" not in source, "시험 제외 금지") | |
| 101 | 추가: require(not re.search(r"include!|#\[path|Command::|execveat|\bmknod\b|\bchmod\b|\bchown\b", source), "범위 밖 Rust 경계") | |
| 102 | 추가: require("\u00b7" not in source, "가운뎃점 금지") | |
| 103 | 추가: require("impl Drop for Sandbox" not in (BASE / "support.rs").read_text(), "실패 증거 자동 정리 금지") | |
| 104 | 추가: plan = json.loads((BASE / "run-plan.json").read_text()) | |
| 105 | 추가: require(plan["bounds"]["per_case_seconds"] == 30 and plan["bounds"]["channel_wait_seconds"] == 5, "시간 상한 변경") | |
| 106 | 추가: manifest = tomllib.loads((BASE / "Cargo.toml").read_text()) | |
| 107 | 추가: require(manifest["package"]["autotests"] is False, "자동 시험 발견 금지") | |
| 108 | 추가: require(manifest["test"] == [{"name": "publication_public_api", "path": "main.rs"}], "target 불일치") | |
| 109 | 추가: require(manifest["dependencies"] == { | |
| 110 | 추가: "publication": {"package": "zipelo-file-publication", "path": "../../experiments/rust-file-publication"}, | |
| 111 | 추가: "libc": {"version": "=0.2.191", "default-features": False, "features": ["std"]}, | |
| 112 | 추가: }, "직접 의존성 변경") | |
| 113 | 추가: normal = lambda rows: sorted(rows, key=lambda row: (row["name"], row["version"])) | |
| 114 | 추가: original = tomllib.loads((SOURCE / "Cargo.lock").read_text())["package"] | |
| 115 | 추가: locked = tomllib.loads((BASE / "Cargo.lock").read_text())["package"] | |
| 116 | 추가: package = {"name": "zipelo-file-publication-regressions", "version": "0.1.0", "dependencies": ["libc", "zipelo-file-publication"]} | |
| 117 | 추가: require(normal(locked) == normal(original + [package]), "기존 lock graph 변경") | |
| 118 | 추가: if args.metadata: | |
| 119 | 추가: require(args.metadata.resolve().is_relative_to(BASE), "metadata 위치 이탈") | |
| 120 | 추가: metadata = json.loads(args.metadata.read_text()) | |
| 121 | 추가: packages = {p["id"]: p for p in metadata["packages"]} | |
| 122 | 추가: root_package = packages[metadata["resolve"]["root"]] | |
| 123 | 추가: require(root_package["name"] == package["name"], "metadata root 불일치") | |
| 124 | 추가: require(len(root_package["targets"]) == 1 and root_package["targets"][0]["kind"] == ["test"], "target 추가") | |
| 125 | 추가: registry = {(p["name"], p["version"], p["checksum"]) for p in locked if "source" in p} | |
| 126 | 추가: expected = {(p["name"], p["version"], p["checksum"]) for p in json.loads((SOURCE / "dependencies.json").read_text())["direct"]} | |
| 127 | 추가: require(registry == expected, "registry graph 변경") | |
| 128 | 추가: for node in metadata["resolve"]["nodes"]: | |
| 129 | 추가: if packages[node["id"]]["name"] == "libc": | |
| 130 | 추가: require(sorted(node["features"]) == ["std"], "libc feature 변경") | |
| 131 | 추가: require(verify_sources() == sources and hashes() == before, "검사 중 입력 변경") | |
| 132 | 추가: print(json.dumps({"head": HEAD, "source_files": 10, "declared": len(names), | |
| 133 | 추가: "rust_compiled": False, "rust_executed": 0, "inputs_unchanged": True})) | |
| 134 | 추가: | |
| 135 | 추가: if __name__ == "__main__": | |
| 136 | 추가: main() |
| @@ -0,0 +1,102 @@ | ||
| 1 | 추가: import json | |
| 2 | 추가: import os | |
| 3 | 추가: import pathlib | |
| 4 | 추가: import runpy | |
| 5 | 추가: import subprocess | |
| 6 | 추가: import sys | |
| 7 | 추가: import unittest | |
| 8 | 추가: | |
| 9 | 추가: BASE = pathlib.Path(__file__).resolve().parent | |
| 10 | 추가: CHECKER = BASE / "static_check.py" | |
| 11 | 추가: CODE = """ | |
| 12 | 추가: import json, pathlib, runpy, sys | |
| 13 | 추가: from unittest.mock import patch | |
| 14 | 추가: scope = runpy.run_path(sys.argv[1]) | |
| 15 | 추가: calls = [] | |
| 16 | 추가: def blocked(*args, **kwargs): | |
| 17 | 추가: calls.append("side_effect") | |
| 18 | 추가: raise RuntimeError("side_effect") | |
| 19 | 추가: with patch("argparse.ArgumentParser", blocked), \ | |
| 20 | 추가: patch.object(pathlib.Path, "read_bytes", blocked), \ | |
| 21 | 추가: patch.object(pathlib.Path, "read_text", blocked), \ | |
| 22 | 추가: patch.object(runpy, "run_path", blocked): | |
| 23 | 추가: try: | |
| 24 | 추가: scope["main"]() | |
| 25 | 추가: except RuntimeError as error: | |
| 26 | 추가: print(json.dumps({"message": str(error), "calls": calls, "optimize": sys.flags.optimize})) | |
| 27 | 추가: """ | |
| 28 | 추가: | |
| 29 | 추가: | |
| 30 | 추가: class StaticHelperTests(unittest.TestCase): | |
| 31 | 추가: def child(self, environment_mode=False, flag=False, cli=False): | |
| 32 | 추가: environment = os.environ.copy() | |
| 33 | 추가: environment.pop("PYTHONOPTIMIZE", None) | |
| 34 | 추가: environment["PYTHONDONTWRITEBYTECODE"] = "1" | |
| 35 | 추가: if environment_mode: | |
| 36 | 추가: environment["PYTHONOPTIMIZE"] = "1" | |
| 37 | 추가: command = [sys.executable, "-B"] + (["-O"] if flag else []) | |
| 38 | 추가: command += [str(CHECKER)] if cli else ["-c", CODE, str(CHECKER)] | |
| 39 | 추가: return subprocess.run(command, env=environment, cwd=BASE, | |
| 40 | 추가: capture_output=True, text=True, timeout=10) | |
| 41 | 추가: | |
| 42 | 추가: def probe(self, **mode): | |
| 43 | 추가: result = self.child(**mode) | |
| 44 | 추가: self.assertEqual(result.returncode, 0, result.stderr) | |
| 45 | 추가: self.assertEqual(result.stderr, "") | |
| 46 | 추가: self.assertEqual(json.loads(result.stdout), { | |
| 47 | 추가: "message": "최적화 모드에서는 정적 검사를 실행할 수 없음", | |
| 48 | 추가: "calls": [], "optimize": 1, | |
| 49 | 추가: }) | |
| 50 | 추가: | |
| 51 | 추가: def test_flag_stops_before_reads_arguments_and_generation(self): | |
| 52 | 추가: self.probe(flag=True) | |
| 53 | 추가: | |
| 54 | 추가: def test_environment_stops_before_reads_arguments_and_generation(self): | |
| 55 | 추가: self.probe(environment_mode=True) | |
| 56 | 추가: | |
| 57 | 추가: def test_normal_mode_reaches_parser(self): | |
| 58 | 추가: result = self.child() | |
| 59 | 추가: self.assertEqual(result.returncode, 0, result.stderr) | |
| 60 | 추가: self.assertEqual(json.loads(result.stdout), { | |
| 61 | 추가: "message": "side_effect", "calls": ["side_effect"], "optimize": 0, | |
| 62 | 추가: }) | |
| 63 | 추가: | |
| 64 | 추가: def test_flag_cli_fails_before_required_arguments(self): | |
| 65 | 추가: result = self.child(flag=True, cli=True) | |
| 66 | 추가: self.assertNotEqual(result.returncode, 0) | |
| 67 | 추가: self.assertEqual(result.stdout, "") | |
| 68 | 추가: self.assertIn("RuntimeError: 최적화 모드", result.stderr) | |
| 69 | 추가: self.assertNotIn("arguments are required", result.stderr) | |
| 70 | 추가: | |
| 71 | 추가: def test_environment_cli_fails_before_required_arguments(self): | |
| 72 | 추가: result = self.child(environment_mode=True, cli=True) | |
| 73 | 추가: self.assertNotEqual(result.returncode, 0) | |
| 74 | 추가: self.assertEqual(result.stdout, "") | |
| 75 | 추가: self.assertIn("RuntimeError: 최적화 모드", result.stderr) | |
| 76 | 추가: | |
| 77 | 추가: def reject(self, content, paths): | |
| 78 | 추가: parse = runpy.run_path(str(CHECKER))["parse_manifest"] | |
| 79 | 추가: with self.assertRaises(RuntimeError): | |
| 80 | 추가: parse(content, paths) | |
| 81 | 추가: | |
| 82 | 추가: def test_duplicate_manifest_rows_rejected(self): | |
| 83 | 추가: line = "a" * 64 + " main.rs\n" | |
| 84 | 추가: self.reject(line + line, {"main.rs"}) | |
| 85 | 추가: | |
| 86 | 추가: def test_missing_manifest_path_rejected(self): | |
| 87 | 추가: self.reject("a" * 64 + " main.rs\n", {"main.rs", "support.rs"}) | |
| 88 | 추가: | |
| 89 | 추가: def test_parent_path_rejected(self): | |
| 90 | 추가: self.reject("a" * 64 + " ../main.rs\n", {"../main.rs"}) | |
| 91 | 추가: | |
| 92 | 추가: def test_repository_relative_source_manifest_path(self): | |
| 93 | 추가: parse = runpy.run_path(str(CHECKER))["parse_manifest"] | |
| 94 | 추가: name = "experiments/rust-file-publication/src/lib.rs" | |
| 95 | 추가: self.assertEqual(parse("a" * 64 + " " + name + "\n", {name}), {name: "a" * 64}) | |
| 96 | 추가: | |
| 97 | 추가: def test_malformed_digest_rejected(self): | |
| 98 | 추가: self.reject("g" * 64 + " main.rs\n", {"main.rs"}) | |
| 99 | 추가: | |
| 100 | 추가: | |
| 101 | 추가: if __name__ == "__main__": | |
| 102 | 추가: unittest.main(verbosity=2) |
| @@ -0,0 +1,196 @@ | ||
| 1 | 추가: use publication::{ | |
| 2 | 추가: Cleanup, Durability, Error, Limits, Outcome, Publication, Report, Request, Stop, Usage, | |
| 3 | 추가: }; | |
| 4 | 추가: use std::{ | |
| 5 | 추가: ffi::{OsStr, OsString}, | |
| 6 | 추가: fs::{self, DirBuilder, OpenOptions}, | |
| 7 | 추가: io::Write, | |
| 8 | 추가: os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt}, | |
| 9 | 추가: path::{Path, PathBuf}, | |
| 10 | 추가: sync::atomic::{AtomicU64, Ordering}, | |
| 11 | 추가: }; | |
| 12 | 추가: | |
| 13 | 추가: static NEXT: AtomicU64 = AtomicU64::new(1); | |
| 14 | 추가: | |
| 15 | 추가: pub struct Sandbox { | |
| 16 | 추가: pub root: PathBuf, | |
| 17 | 추가: identity: (u64, u64), | |
| 18 | 추가: } | |
| 19 | 추가: | |
| 20 | 추가: impl Sandbox { | |
| 21 | 추가: pub fn new() -> Self { | |
| 22 | 추가: let runs = Path::new(env!("CARGO_MANIFEST_DIR")).join("runs"); | |
| 23 | 추가: let info = fs::symlink_metadata(&runs).expect("runner가 전용 runs를 준비해야 함"); | |
| 24 | 추가: assert!(info.is_dir() && !info.file_type().is_symlink()); | |
| 25 | 추가: assert_eq!(info.mode() & 0o777, 0o700); | |
| 26 | 추가: assert_eq!(info.uid(), unsafe { libc::geteuid() }); | |
| 27 | 추가: assert_eq!(runs.canonicalize().unwrap(), runs); | |
| 28 | 추가: let root = runs.join(format!( | |
| 29 | 추가: "case-{}-{}", | |
| 30 | 추가: std::process::id(), | |
| 31 | 추가: NEXT.fetch_add(1, Ordering::Relaxed) | |
| 32 | 추가: )); | |
| 33 | 추가: DirBuilder::new().mode(0o700).create(&root).unwrap(); | |
| 34 | 추가: let info = fs::symlink_metadata(&root).unwrap(); | |
| 35 | 추가: let sandbox = Self { | |
| 36 | 추가: root, | |
| 37 | 추가: identity: (info.dev(), info.ino()), | |
| 38 | 추가: }; | |
| 39 | 추가: sandbox.dir("parent"); | |
| 40 | 추가: sandbox | |
| 41 | 추가: } | |
| 42 | 추가: | |
| 43 | 추가: pub fn path(&self, name: impl AsRef<Path>) -> PathBuf { | |
| 44 | 추가: self.root.join(name) | |
| 45 | 추가: } | |
| 46 | 추가: | |
| 47 | 추가: pub fn parent(&self) -> PathBuf { | |
| 48 | 추가: self.path("parent") | |
| 49 | 추가: } | |
| 50 | 추가: | |
| 51 | 추가: pub fn dir(&self, name: impl AsRef<Path>) -> PathBuf { | |
| 52 | 추가: let path = self.path(name); | |
| 53 | 추가: DirBuilder::new().mode(0o700).create(&path).unwrap(); | |
| 54 | 추가: path | |
| 55 | 추가: } | |
| 56 | 추가: | |
| 57 | 추가: pub fn file(&self, name: impl AsRef<Path>, bytes: &[u8]) -> PathBuf { | |
| 58 | 추가: let path = self.path(name); | |
| 59 | 추가: let mut handle = OpenOptions::new() | |
| 60 | 추가: .write(true) | |
| 61 | 추가: .create_new(true) | |
| 62 | 추가: .mode(0o600) | |
| 63 | 추가: .open(&path) | |
| 64 | 추가: .unwrap(); | |
| 65 | 추가: handle.write_all(bytes).unwrap(); | |
| 66 | 추가: handle.sync_all().unwrap(); | |
| 67 | 추가: path | |
| 68 | 추가: } | |
| 69 | 추가: | |
| 70 | 추가: pub fn finish(self) { | |
| 71 | 추가: assert!( | |
| 72 | 추가: owned_descriptors(&self.root).is_empty(), | |
| 73 | 추가: "작업 디렉터리의 열린 fd가 남아 있음" | |
| 74 | 추가: ); | |
| 75 | 추가: let info = fs::symlink_metadata(&self.root).unwrap(); | |
| 76 | 추가: assert!(info.is_dir() && !info.file_type().is_symlink()); | |
| 77 | 추가: assert_eq!((info.dev(), info.ino()), self.identity); | |
| 78 | 추가: fs::remove_dir_all(&self.root).unwrap(); | |
| 79 | 추가: assert!(!self.root.exists()); | |
| 80 | 추가: } | |
| 81 | 추가: } | |
| 82 | 추가: | |
| 83 | 추가: pub fn pattern(length: usize) -> Vec<u8> { | |
| 84 | 추가: (0..length).map(|i| ((i * 37 + 11) % 251) as u8).collect() | |
| 85 | 추가: } | |
| 86 | 추가: | |
| 87 | 추가: pub fn names(parent: &Path) -> Vec<OsString> { | |
| 88 | 추가: let mut result: Vec<_> = fs::read_dir(parent) | |
| 89 | 추가: .unwrap() | |
| 90 | 추가: .map(|e| e.unwrap().file_name()) | |
| 91 | 추가: .collect(); | |
| 92 | 추가: result.sort(); | |
| 93 | 추가: result | |
| 94 | 추가: } | |
| 95 | 추가: | |
| 96 | 추가: pub fn owned_descriptors(root: &Path) -> Vec<u32> { | |
| 97 | 추가: let mut result = Vec::new(); | |
| 98 | 추가: for item in fs::read_dir("/proc/self/fd").unwrap() { | |
| 99 | 추가: let item = item.unwrap(); | |
| 100 | 추가: if let Ok(target) = fs::read_link(item.path()) { | |
| 101 | 추가: if target.starts_with(root) { | |
| 102 | 추가: result.push(item.file_name().to_str().unwrap().parse().unwrap()); | |
| 103 | 추가: } | |
| 104 | 추가: } | |
| 105 | 추가: } | |
| 106 | 추가: result.sort(); | |
| 107 | 추가: result | |
| 108 | 추가: } | |
| 109 | 추가: | |
| 110 | 추가: pub fn publish(parent: &Path, leaf: &OsStr, bytes: &[u8], limits: Limits) -> Report<()> { | |
| 111 | 추가: let (task, cancel) = Publication::new(); | |
| 112 | 추가: let report = task.publish( | |
| 113 | 추가: Request { | |
| 114 | 추가: parent, | |
| 115 | 추가: leaf, | |
| 116 | 추가: bytes, | |
| 117 | 추가: limits, | |
| 118 | 추가: }, | |
| 119 | 추가: |_| Ok::<_, Stop<()>>(()), | |
| 120 | 추가: ); | |
| 121 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 122 | 추가: report | |
| 123 | 추가: } | |
| 124 | 추가: | |
| 125 | 추가: pub fn not_committed<E>(report: Report<E>) -> (Error<E>, Usage, Cleanup) { | |
| 126 | 추가: let Report { | |
| 127 | 추가: outcome, | |
| 128 | 추가: usage, | |
| 129 | 추가: cleanup, | |
| 130 | 추가: } = report; | |
| 131 | 추가: match outcome { | |
| 132 | 추가: Outcome::NotCommitted(error) => (error, usage, cleanup), | |
| 133 | 추가: Outcome::CommitUncertain { source } => panic!("unexpected uncertain commit: {source}"), | |
| 134 | 추가: Outcome::Committed { .. } => panic!("unexpected committed result"), | |
| 135 | 추가: } | |
| 136 | 추가: } | |
| 137 | 추가: | |
| 138 | 추가: pub fn cleanup(cleanup: &Cleanup, attempts: u8) { | |
| 139 | 추가: assert_eq!(cleanup.attempted, attempts); | |
| 140 | 추가: assert!(cleanup.all_close_calls_succeeded(), "{cleanup:?}"); | |
| 141 | 추가: assert!(cleanup.failures.iter().all(Option::is_none)); | |
| 142 | 추가: } | |
| 143 | 추가: | |
| 144 | 추가: pub fn full_usage(usage: Usage, length: usize, linked: bool) { | |
| 145 | 추가: let chunks = (length as u64).div_ceil(65_536); | |
| 146 | 추가: assert_eq!(usage.open_calls, 4); | |
| 147 | 추가: assert_eq!(usage.metadata_calls, 5); | |
| 148 | 추가: assert_eq!(usage.write_calls, chunks); | |
| 149 | 추가: assert_eq!(usage.read_calls, chunks + 1); | |
| 150 | 추가: assert_eq!(usage.actual_written_bytes, length as u64); | |
| 151 | 추가: assert_eq!(usage.actual_read_bytes, length as u64); | |
| 152 | 추가: assert_eq!(usage.reserved_io_bytes, 2 * length as u64 + 1); | |
| 153 | 추가: assert_eq!(usage.link_calls, 1); | |
| 154 | 추가: assert_eq!(usage.sync_calls, if linked { 2 } else { 1 }); | |
| 155 | 추가: } | |
| 156 | 추가: | |
| 157 | 추가: pub fn committed(report: Report<()>, parent: &Path, leaf: &OsStr, bytes: &[u8]) { | |
| 158 | 추가: cleanup(&report.cleanup, 4); | |
| 159 | 추가: full_usage(report.usage, bytes.len(), true); | |
| 160 | 추가: let (receipt, durability) = match report.outcome { | |
| 161 | 추가: Outcome::Committed { | |
| 162 | 추가: receipt, | |
| 163 | 추가: durability, | |
| 164 | 추가: } => (receipt, durability), | |
| 165 | 추가: Outcome::NotCommitted(error) => panic!("unexpected noncommit: {error:?}"), | |
| 166 | 추가: Outcome::CommitUncertain { source } => panic!("unexpected uncertain commit: {source}"), | |
| 167 | 추가: }; | |
| 168 | 추가: assert!(matches!(durability, Durability::FileAndParentSynced)); | |
| 169 | 추가: let parent_meta = fs::metadata(parent).unwrap(); | |
| 170 | 추가: let path = parent.join(leaf); | |
| 171 | 추가: let file_meta = fs::symlink_metadata(&path).unwrap(); | |
| 172 | 추가: assert!(file_meta.is_file() && !file_meta.file_type().is_symlink()); | |
| 173 | 추가: assert_eq!(file_meta.nlink(), 1); | |
| 174 | 추가: assert_eq!(file_meta.mode() & 0o077, 0); | |
| 175 | 추가: assert_eq!(file_meta.uid(), unsafe { libc::geteuid() }); | |
| 176 | 추가: assert_eq!(receipt.length(), bytes.len() as u64); | |
| 177 | 추가: assert_eq!(receipt.parent_identity().device(), parent_meta.dev()); | |
| 178 | 추가: assert_eq!(receipt.parent_identity().inode(), parent_meta.ino()); | |
| 179 | 추가: assert_eq!(receipt.file_identity().device(), file_meta.dev()); | |
| 180 | 추가: assert_eq!(receipt.file_identity().inode(), file_meta.ino()); | |
| 181 | 추가: assert_eq!(fs::read(path).unwrap(), bytes); | |
| 182 | 추가: assert_eq!(names(parent), vec![leaf.to_os_string()]); | |
| 183 | 추가: } | |
| 184 | 추가: | |
| 185 | 추가: pub fn conflict(report: Report<()>, length: usize) { | |
| 186 | 추가: let (error, usage, closed) = not_committed(report); | |
| 187 | 추가: match error { | |
| 188 | 추가: Error::Io { operation, source } => { | |
| 189 | 추가: assert_eq!(operation, "linkat_conflict"); | |
| 190 | 추가: assert_eq!(source.raw_os_error(), Some(libc::EEXIST)); | |
| 191 | 추가: } | |
| 192 | 추가: other => panic!("unexpected: {other:?}"), | |
| 193 | 추가: } | |
| 194 | 추가: full_usage(usage, length, false); | |
| 195 | 추가: cleanup(&closed, 4); | |
| 196 | 추가: } |