GZip 파일 작업 연결 회귀 시험을 추가함
- 작성자
- 코노모리 카논
- 작성 시각
- 커밋
287aaeb93f7e362d3b87354e8e372fcdd3ade146- 부모
- 4c6ae4b
변경된 파일 17개
+2,413-0| @@ -0,0 +1,132 @@ | ||
| 1 | 추가: # This file is automatically @generated by Cargo. | |
| 2 | 추가: # It is not intended for manual editing. | |
| 3 | 추가: version = 4 | |
| 4 | 추가: | |
| 5 | 추가: [[package]] | |
| 6 | 추가: name = "block-buffer" | |
| 7 | 추가: version = "0.10.4" | |
| 8 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 9 | 추가: checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" | |
| 10 | 추가: dependencies = [ | |
| 11 | 추가: "generic-array", | |
| 12 | 추가: ] | |
| 13 | 추가: | |
| 14 | 추가: [[package]] | |
| 15 | 추가: name = "cfg-if" | |
| 16 | 추가: version = "1.0.5" | |
| 17 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 18 | 추가: checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" | |
| 19 | 추가: | |
| 20 | 추가: [[package]] | |
| 21 | 추가: name = "cpufeatures" | |
| 22 | 추가: version = "0.2.17" | |
| 23 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 24 | 추가: checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" | |
| 25 | 추가: dependencies = [ | |
| 26 | 추가: "libc", | |
| 27 | 추가: ] | |
| 28 | 추가: | |
| 29 | 추가: [[package]] | |
| 30 | 추가: name = "crypto-common" | |
| 31 | 추가: version = "0.1.7" | |
| 32 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 33 | 추가: checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" | |
| 34 | 추가: dependencies = [ | |
| 35 | 추가: "generic-array", | |
| 36 | 추가: "typenum", | |
| 37 | 추가: ] | |
| 38 | 추가: | |
| 39 | 추가: [[package]] | |
| 40 | 추가: name = "digest" | |
| 41 | 추가: version = "0.10.7" | |
| 42 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 43 | 추가: checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" | |
| 44 | 추가: dependencies = [ | |
| 45 | 추가: "block-buffer", | |
| 46 | 추가: "crypto-common", | |
| 47 | 추가: ] | |
| 48 | 추가: | |
| 49 | 추가: [[package]] | |
| 50 | 추가: name = "generic-array" | |
| 51 | 추가: version = "0.14.7" | |
| 52 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 53 | 추가: checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" | |
| 54 | 추가: dependencies = [ | |
| 55 | 추가: "typenum", | |
| 56 | 추가: "version_check", | |
| 57 | 추가: ] | |
| 58 | 추가: | |
| 59 | 추가: [[package]] | |
| 60 | 추가: name = "libc" | |
| 61 | 추가: version = "0.2.191" | |
| 62 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 63 | 추가: checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" | |
| 64 | 추가: | |
| 65 | 추가: [[package]] | |
| 66 | 추가: name = "sha2" | |
| 67 | 추가: version = "0.10.9" | |
| 68 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 69 | 추가: checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" | |
| 70 | 추가: dependencies = [ | |
| 71 | 추가: "cfg-if", | |
| 72 | 추가: "cpufeatures", | |
| 73 | 추가: "digest", | |
| 74 | 추가: ] | |
| 75 | 추가: | |
| 76 | 추가: [[package]] | |
| 77 | 추가: name = "typenum" | |
| 78 | 추가: version = "1.20.1" | |
| 79 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 80 | 추가: checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" | |
| 81 | 추가: | |
| 82 | 추가: [[package]] | |
| 83 | 추가: name = "version_check" | |
| 84 | 추가: version = "0.9.5" | |
| 85 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 86 | 추가: checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" | |
| 87 | 추가: | |
| 88 | 추가: [[package]] | |
| 89 | 추가: name = "zipelo-file-publication" | |
| 90 | 추가: version = "0.1.0" | |
| 91 | 추가: dependencies = [ | |
| 92 | 추가: "libc", | |
| 93 | 추가: ] | |
| 94 | 추가: | |
| 95 | 추가: [[package]] | |
| 96 | 추가: name = "zipelo-file-snapshot" | |
| 97 | 추가: version = "0.1.0" | |
| 98 | 추가: dependencies = [ | |
| 99 | 추가: "libc", | |
| 100 | 추가: "sha2", | |
| 101 | 추가: ] | |
| 102 | 추가: | |
| 103 | 추가: [[package]] | |
| 104 | 추가: name = "zipelo-gzip-file-job" | |
| 105 | 추가: version = "0.1.0" | |
| 106 | 추가: dependencies = [ | |
| 107 | 추가: "zipelo-file-publication", | |
| 108 | 추가: "zipelo-file-snapshot", | |
| 109 | 추가: "zipelo-memory-gzip-reader", | |
| 110 | 추가: ] | |
| 111 | 추가: | |
| 112 | 추가: [[package]] | |
| 113 | 추가: name = "zipelo-gzip-file-job-regressions" | |
| 114 | 추가: version = "0.1.0" | |
| 115 | 추가: dependencies = [ | |
| 116 | 추가: "libc", | |
| 117 | 추가: "sha2", | |
| 118 | 추가: "zipelo-gzip-file-job", | |
| 119 | 추가: ] | |
| 120 | 추가: | |
| 121 | 추가: [[package]] | |
| 122 | 추가: name = "zipelo-memory-gzip-reader" | |
| 123 | 추가: version = "0.1.0" | |
| 124 | 추가: dependencies = [ | |
| 125 | 추가: "zlib-rs", | |
| 126 | 추가: ] | |
| 127 | 추가: | |
| 128 | 추가: [[package]] | |
| 129 | 추가: name = "zlib-rs" | |
| 130 | 추가: version = "0.6.8" | |
| 131 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 132 | 추가: checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| @@ -0,0 +1,21 @@ | ||
| 1 | 추가: [package] | |
| 2 | 추가: name = "zipelo-gzip-file-job-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 = "file_job_public_api" | |
| 14 | 추가: path = "main.rs" | |
| 15 | 추가: | |
| 16 | 추가: [dependencies] | |
| 17 | 추가: job = { package = "zipelo-gzip-file-job", path = "../../experiments/rust-gzip-file-job" } | |
| 18 | 추가: libc = { version = "=0.2.191", default-features = false, features = ["std"] } | |
| 19 | 추가: sha2 = { version = "=0.10.9", default-features = false, features = ["std", "force-soft"] } | |
| 20 | 추가: | |
| 21 | 추가: [workspace] |
| @@ -0,0 +1,16 @@ | ||
| 1 | 추가: e291067ef69ee6b11deb7c03e0a961609f456ff3185563aa7d2d0c31cf3e8936 Cargo.lock | |
| 2 | 추가: 90bc3eb6c50d661df2d6b88a7a89a6a46aee61d3f082e6910638a4c7fb6cced5 Cargo.toml | |
| 3 | 추가: 543ac298aec6727618d3e161261da91e2ddd04bd136583f2aa640a71bec4deda concurrency.rs | |
| 4 | 추가: 9807046c32796e11ac670c5f7c153b8e6c6c8cd20b75bde8aeea46e7842ac185 contract.json | |
| 5 | 추가: c5bb942083045c9f16394be31bbc36117cc1d0fae04745a9e05dfcf06ba548fd control.rs | |
| 6 | 추가: b7eef4ba661501b2da6b87994509cbc398b5c1095112e2609a8275fcc814374c fixtures.rs | |
| 7 | 추가: 609cefa6e310a8da08c4a97fec9b7d59904e096d5754bd9845669f8815a285ac invalid.rs | |
| 8 | 추가: aae6c696bd85e5e173b51f27df310e78c4a6a7340649cba7f01035aa0a6c948a limits.rs | |
| 9 | 추가: eadaf17070d3b5344f07f83c1d62782f56f267c4e458acd9f1525274efa3dcca main.rs | |
| 10 | 추가: f3507dc9f91af604c779ad30f46c59b69a6e0b45eb354fcceee724987d2231a0 namespace.rs | |
| 11 | 추가: 3f04482a9f9cbe3dc37be183dd6ace67d30ee680447e773321e73b97034420d0 run-plan.json | |
| 12 | 추가: 40403433dea41d9ff685aff2e0391af1515272771243be03d485b2f2b40857d2 source-pins.json | |
| 13 | 추가: b88bd70cef787a0a5397de363dfb09bb5aa7610ba698c8c2f836a718b3ff6114 static_check.py | |
| 14 | 추가: 53a7bc6d4cadf3c69c13440d79288b424e9ac1f1873984fba550e7b78664a3f6 static_check_helper_tests.py | |
| 15 | 추가: ff7f8d2f4b178eab74faa40d70a55c51b84da504eaa087f17ab310fdc9560e45 success.rs | |
| 16 | 추가: 7879f24248beba8694504c276dc24d15a33dd7d491f7edf168ea20a6b41c9f60 support.rs |
| @@ -0,0 +1,134 @@ | ||
| 1 | 추가: use crate::{fixtures::*, support::*}; | |
| 2 | 추가: use job::{Event, FileJob, Limits, Outcome, Stop, publication}; | |
| 3 | 추가: use std::{sync::mpsc, thread, time::Duration}; | |
| 4 | 추가: | |
| 5 | 추가: const WAIT: Duration = Duration::from_secs(5); | |
| 6 | 추가: | |
| 7 | 추가: #[test] | |
| 8 | 추가: fn two_file_jobs_for_one_name_have_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 | 추가: let mut inputs = Vec::new(); | |
| 16 | 추가: for marker in [65_u8, 66_u8] { | |
| 17 | 추가: let archive = stored(&vec![marker; 65_537]); | |
| 18 | 추가: let input = sandbox.file(format!("input-{marker}.gz"), &archive); | |
| 19 | 추가: inputs.push((input.clone(), identity(&input), archive)); | |
| 20 | 추가: let (release_tx, release_rx) = mpsc::sync_channel(1); | |
| 21 | 추가: releases.push(release_tx); | |
| 22 | 추가: let ready = ready_tx.clone(); | |
| 23 | 추가: let done = done_tx.clone(); | |
| 24 | 추가: let parent = parent.clone(); | |
| 25 | 추가: handles.push(thread::spawn(move || { | |
| 26 | 추가: let (task, cancel) = FileJob::new(); | |
| 27 | 추가: let mut trace = Trace::default(); | |
| 28 | 추가: let report = task.run(request(&input, &parent, Limits::default()), |point| { | |
| 29 | 추가: trace.push(point); | |
| 30 | 추가: if matches!(point.event, Event::Publication(native) if native.stage == publication::Stage::BeforeCommit) { | |
| 31 | 추가: ready.send(marker).unwrap(); | |
| 32 | 추가: release_rx.recv_timeout(WAIT).expect("게시 해제 신호 시간 초과"); | |
| 33 | 추가: } | |
| 34 | 추가: Ok::<_, Stop<()>>(()) | |
| 35 | 추가: }); | |
| 36 | 추가: trace.finish(&report); | |
| 37 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 38 | 추가: assert!(done.send((marker, report)).is_ok()); | |
| 39 | 추가: })); | |
| 40 | 추가: } | |
| 41 | 추가: drop(ready_tx); | |
| 42 | 추가: drop(done_tx); | |
| 43 | 추가: let mut ready = vec![ | |
| 44 | 추가: ready_rx.recv_timeout(WAIT).unwrap(), | |
| 45 | 추가: ready_rx.recv_timeout(WAIT).unwrap(), | |
| 46 | 추가: ]; | |
| 47 | 추가: ready.sort(); | |
| 48 | 추가: assert_eq!(ready, [65, 66]); | |
| 49 | 추가: assert!(names(&parent).is_empty()); | |
| 50 | 추가: for release in releases { | |
| 51 | 추가: release.send(()).unwrap(); | |
| 52 | 추가: } | |
| 53 | 추가: let results = [ | |
| 54 | 추가: done_rx.recv_timeout(WAIT).unwrap(), | |
| 55 | 추가: done_rx.recv_timeout(WAIT).unwrap(), | |
| 56 | 추가: ]; | |
| 57 | 추가: for handle in handles { | |
| 58 | 추가: handle.join().expect("파일 작업 스레드 실패"); | |
| 59 | 추가: } | |
| 60 | 추가: assert_eq!(results.iter().filter(|(_, report)| matches!( | |
| 61 | 추가: &report.outcome, Outcome::Publication(native) if matches!(&native.outcome, publication::Outcome::Committed { .. }) | |
| 62 | 추가: )).count(), 1); | |
| 63 | 추가: for (marker, report) in results { | |
| 64 | 추가: let (_, before, archive) = &inputs[(marker - 65) as usize]; | |
| 65 | 추가: observations( | |
| 66 | 추가: &report, | |
| 67 | 추가: (before.0, before.1), | |
| 68 | 추가: archive, | |
| 69 | 추가: &vec![marker; 65_537], | |
| 70 | 추가: 10, | |
| 71 | 추가: ); | |
| 72 | 추가: if matches!(&report.outcome, Outcome::Publication(native) if matches!(&native.outcome, publication::Outcome::Committed { .. })) | |
| 73 | 추가: { | |
| 74 | 추가: committed(&report, &parent, &vec![marker; 65_537]); | |
| 75 | 추가: } else { | |
| 76 | 추가: conflict(&report, 65_537); | |
| 77 | 추가: } | |
| 78 | 추가: } | |
| 79 | 추가: for (input, before, archive) in inputs { | |
| 80 | 추가: assert_eq!(identity(&input), before); | |
| 81 | 추가: assert_eq!(std::fs::read(input).unwrap(), archive); | |
| 82 | 추가: } | |
| 83 | 추가: sandbox.finish(); | |
| 84 | 추가: } | |
| 85 | 추가: | |
| 86 | 추가: #[test] | |
| 87 | 추가: fn acknowledged_external_cancel_before_commit_prevents_publication() { | |
| 88 | 추가: let sandbox = Sandbox::new(); | |
| 89 | 추가: let input = sandbox.file("input.gz", &stored(b"abc")); | |
| 90 | 추가: let parent = sandbox.parent(); | |
| 91 | 추가: let worker_parent = parent.clone(); | |
| 92 | 추가: let (task, cancel) = FileJob::new(); | |
| 93 | 추가: let (ready_tx, ready_rx) = mpsc::sync_channel(1); | |
| 94 | 추가: let (release_tx, release_rx) = mpsc::sync_channel(1); | |
| 95 | 추가: let (done_tx, done_rx) = mpsc::sync_channel(1); | |
| 96 | 추가: let handle = thread::spawn(move || { | |
| 97 | 추가: let mut trace = Trace::default(); | |
| 98 | 추가: let report = task.run(request(&input, &worker_parent, Limits::default()), |point| { | |
| 99 | 추가: trace.push(point); | |
| 100 | 추가: if matches!(point.event, Event::Publication(native) if native.stage == publication::Stage::BeforeCommit) { | |
| 101 | 추가: ready_tx.send(()).unwrap(); | |
| 102 | 추가: release_rx.recv_timeout(WAIT).expect("취소 확인 신호 시간 초과"); | |
| 103 | 추가: } | |
| 104 | 추가: Ok::<_, Stop<()>>(()) | |
| 105 | 추가: }); | |
| 106 | 추가: trace.finish(&report); | |
| 107 | 추가: assert!(done_tx.send(report).is_ok()); | |
| 108 | 추가: }); | |
| 109 | 추가: ready_rx.recv_timeout(WAIT).unwrap(); | |
| 110 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Requested); | |
| 111 | 추가: assert_eq!( | |
| 112 | 추가: cancel.clone().request(), | |
| 113 | 추가: publication::CancelDecision::AlreadyRequested | |
| 114 | 추가: ); | |
| 115 | 추가: release_tx.send(()).unwrap(); | |
| 116 | 추가: let report = done_rx.recv_timeout(WAIT).unwrap(); | |
| 117 | 추가: handle.join().expect("취소 스레드 실패"); | |
| 118 | 추가: match &report.outcome { | |
| 119 | 추가: Outcome::Publication(native) => { | |
| 120 | 추가: assert!(matches!( | |
| 121 | 추가: native.outcome, | |
| 122 | 추가: publication::Outcome::NotCommitted(publication::Error::Cancelled) | |
| 123 | 추가: )); | |
| 124 | 추가: assert_eq!(native.usage.link_calls, 0); | |
| 125 | 추가: assert_eq!(native.usage.actual_written_bytes, 3); | |
| 126 | 추가: assert_eq!(native.usage.actual_read_bytes, 3); | |
| 127 | 추가: cleanup(&native.cleanup, 4); | |
| 128 | 추가: } | |
| 129 | 추가: _ => panic!("게시 전 취소가 보존되지 않음"), | |
| 130 | 추가: } | |
| 131 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 132 | 추가: assert!(names(&parent).is_empty()); | |
| 133 | 추가: sandbox.finish(); | |
| 134 | 추가: } |
| @@ -0,0 +1,190 @@ | ||
| 1 | 추가: { | |
| 2 | 추가: "schema": "zipelo.gzip-file-job-regressions.v1", | |
| 3 | 추가: "source_head": "4c6ae4b3a7ab12a992598e94e7b02f3a167fbbd4", | |
| 4 | 추가: "source_tree": "9a01a37623b163c35ca4ff25963b2e11c61a0c35", | |
| 5 | 추가: "source_manifest_sha256": "ef32ad5306d2d98751836846f631f66c562e4b55caf5d3422e120305aa78b37f", | |
| 6 | 추가: "branch": "features/rust-gzip-file-job-regressions", | |
| 7 | 추가: "stage": "Source/static only. Rust compilation, discovery and execution have not been performed.", | |
| 8 | 추가: "scope": "New root tests only; frozen FileJob and native snapshot/GZip/publication sources, lockfiles and private receipt constructors remain unchanged.", | |
| 9 | 추가: "declared_test_count": 62, | |
| 10 | 추가: "test_names": [ | |
| 11 | 추가: "concurrency::acknowledged_external_cancel_before_commit_prevents_publication", | |
| 12 | 추가: "concurrency::two_file_jobs_for_one_name_have_one_complete_winner", | |
| 13 | 추가: "control::cancel_decode_after_inflate", | |
| 14 | 추가: "control::cancel_decode_after_output", | |
| 15 | 추가: "control::cancel_decode_before_inflate", | |
| 16 | 추가: "control::cancel_decode_before_return", | |
| 17 | 추가: "control::cancel_decode_header", | |
| 18 | 추가: "control::cancel_decode_start", | |
| 19 | 추가: "control::cancel_decode_trailer", | |
| 20 | 추가: "control::cancel_publication_before_commit", | |
| 21 | 추가: "control::cancel_publication_opening", | |
| 22 | 추가: "control::cancel_publication_verifying", | |
| 23 | 추가: "control::cancel_publication_writing", | |
| 24 | 추가: "control::cancel_snapshot_comparing", | |
| 25 | 추가: "control::cancel_snapshot_copying", | |
| 26 | 추가: "control::cancel_snapshot_finalizing", | |
| 27 | 추가: "control::cancel_snapshot_opening", | |
| 28 | 추가: "control::cancel_snapshot_pinned", | |
| 29 | 추가: "control::cancellation_after_return_preserves_committed_bytes", | |
| 30 | 추가: "control::decode_observer_error_beats_accepted_cancel", | |
| 31 | 추가: "control::dropping_unused_job_finishes_its_gate", | |
| 32 | 추가: "control::local_decode_stop_does_not_need_cancel_request", | |
| 33 | 추가: "control::local_publication_stop_does_not_need_cancel_request", | |
| 34 | 추가: "control::local_snapshot_stop_does_not_need_cancel_request", | |
| 35 | 추가: "control::pre_cancel_stops_before_snapshot_open", | |
| 36 | 추가: "control::publication_observer_error_beats_accepted_cancel", | |
| 37 | 추가: "control::snapshot_observer_error_beats_accepted_cancel", | |
| 38 | 추가: "invalid::bad_crc_prevents_publication", | |
| 39 | 추가: "invalid::bad_size_prevents_publication", | |
| 40 | 추가: "invalid::concatenated_members_prevent_publication", | |
| 41 | 추가: "invalid::invalid_deflate_preserves_backend_error", | |
| 42 | 추가: "invalid::invalid_magic_prevents_publication", | |
| 43 | 추가: "invalid::trailing_byte_prevents_publication", | |
| 44 | 추가: "invalid::truncated_trailer_prevents_publication", | |
| 45 | 추가: "limits::exact_limits_in_all_stages_allow_commit", | |
| 46 | 추가: "limits::gzip_input_limit_stops_after_snapshot", | |
| 47 | 추가: "limits::gzip_metadata_limit_preserves_header_cost", | |
| 48 | 추가: "limits::gzip_processed_failure_includes_post_checkpoint_charge", | |
| 49 | 추가: "limits::gzip_selected_output_limit_preserves_consumed_cost", | |
| 50 | 추가: "limits::invalid_decode_duration_retains_snapshot_cost", | |
| 51 | 추가: "limits::invalid_publication_duration_retains_both_prior_costs", | |
| 52 | 추가: "limits::invalid_snapshot_duration_has_zero_cost", | |
| 53 | 추가: "limits::publication_byte_limit_preserves_completed_prior_stages", | |
| 54 | 추가: "limits::publication_call_limit_retains_pre_eof_usage", | |
| 55 | 추가: "limits::publication_io_limit_retains_pre_eof_usage", | |
| 56 | 추가: "limits::snapshot_byte_limit_preserves_partial_usage", | |
| 57 | 추가: "limits::snapshot_call_limit_retains_last_eof_reservation_boundary", | |
| 58 | 추가: "limits::snapshot_io_limit_retains_last_eof_reservation_boundary", | |
| 59 | 추가: "namespace::existing_directory_and_child_survive_conflict", | |
| 60 | 추가: "namespace::existing_file_bytes_and_identity_survive_conflict", | |
| 61 | 추가: "namespace::existing_symlink_and_target_survive_conflict", | |
| 62 | 추가: "namespace::identical_input_and_output_name_preserves_archive", | |
| 63 | 추가: "namespace::missing_owned_input_preserves_native_open_error", | |
| 64 | 추가: "namespace::replaced_parent_path_does_not_redirect_pinned_commit", | |
| 65 | 추가: "success::chunk_minus_one_output", | |
| 66 | 추가: "success::chunk_output", | |
| 67 | 추가: "success::chunk_plus_one_output", | |
| 68 | 추가: "success::empty_output", | |
| 69 | 추가: "success::header_name_and_comment_never_select_destination", | |
| 70 | 추가: "success::known_bytes_output", | |
| 71 | 추가: "success::one_byte_output", | |
| 72 | 추가: "success::replacing_input_after_snapshot_uses_captured_owned_bytes" | |
| 73 | 추가: ], | |
| 74 | 추가: "evidence_classes": { | |
| 75 | 추가: "concurrency::acknowledged_external_cancel_before_commit_prevents_publication": "actual-file-job-with-controlled-callback-or-schedule", | |
| 76 | 추가: "concurrency::two_file_jobs_for_one_name_have_one_complete_winner": "actual-file-job-with-controlled-callback-or-schedule", | |
| 77 | 추가: "control::cancel_decode_after_inflate": "actual-file-job-with-controlled-callback-or-schedule", | |
| 78 | 추가: "control::cancel_decode_after_output": "actual-file-job-with-controlled-callback-or-schedule", | |
| 79 | 추가: "control::cancel_decode_before_inflate": "actual-file-job-with-controlled-callback-or-schedule", | |
| 80 | 추가: "control::cancel_decode_before_return": "actual-file-job-with-controlled-callback-or-schedule", | |
| 81 | 추가: "control::cancel_decode_header": "actual-file-job-with-controlled-callback-or-schedule", | |
| 82 | 추가: "control::cancel_decode_start": "actual-file-job-with-controlled-callback-or-schedule", | |
| 83 | 추가: "control::cancel_decode_trailer": "actual-file-job-with-controlled-callback-or-schedule", | |
| 84 | 추가: "control::cancel_publication_before_commit": "actual-file-job-with-controlled-callback-or-schedule", | |
| 85 | 추가: "control::cancel_publication_opening": "actual-file-job-with-controlled-callback-or-schedule", | |
| 86 | 추가: "control::cancel_publication_verifying": "actual-file-job-with-controlled-callback-or-schedule", | |
| 87 | 추가: "control::cancel_publication_writing": "actual-file-job-with-controlled-callback-or-schedule", | |
| 88 | 추가: "control::cancel_snapshot_comparing": "actual-file-job-with-controlled-callback-or-schedule", | |
| 89 | 추가: "control::cancel_snapshot_copying": "actual-file-job-with-controlled-callback-or-schedule", | |
| 90 | 추가: "control::cancel_snapshot_finalizing": "actual-file-job-with-controlled-callback-or-schedule", | |
| 91 | 추가: "control::cancel_snapshot_opening": "actual-file-job-with-controlled-callback-or-schedule", | |
| 92 | 추가: "control::cancel_snapshot_pinned": "actual-file-job-with-controlled-callback-or-schedule", | |
| 93 | 추가: "control::cancellation_after_return_preserves_committed_bytes": "actual-file-job-with-controlled-callback-or-schedule", | |
| 94 | 추가: "control::decode_observer_error_beats_accepted_cancel": "actual-file-job-with-controlled-callback-or-schedule", | |
| 95 | 추가: "control::dropping_unused_job_finishes_its_gate": "gate-lifecycle-only", | |
| 96 | 추가: "control::local_decode_stop_does_not_need_cancel_request": "actual-file-job-with-controlled-callback-or-schedule", | |
| 97 | 추가: "control::local_publication_stop_does_not_need_cancel_request": "actual-file-job-with-controlled-callback-or-schedule", | |
| 98 | 추가: "control::local_snapshot_stop_does_not_need_cancel_request": "actual-file-job-with-controlled-callback-or-schedule", | |
| 99 | 추가: "control::pre_cancel_stops_before_snapshot_open": "actual-file-job-with-controlled-callback-or-schedule", | |
| 100 | 추가: "control::publication_observer_error_beats_accepted_cancel": "actual-file-job-with-controlled-callback-or-schedule", | |
| 101 | 추가: "control::snapshot_observer_error_beats_accepted_cancel": "actual-file-job-with-controlled-callback-or-schedule", | |
| 102 | 추가: "invalid::bad_crc_prevents_publication": "actual-file-job", | |
| 103 | 추가: "invalid::bad_size_prevents_publication": "actual-file-job", | |
| 104 | 추가: "invalid::concatenated_members_prevent_publication": "actual-file-job", | |
| 105 | 추가: "invalid::invalid_deflate_preserves_backend_error": "actual-file-job", | |
| 106 | 추가: "invalid::invalid_magic_prevents_publication": "actual-file-job", | |
| 107 | 추가: "invalid::trailing_byte_prevents_publication": "actual-file-job", | |
| 108 | 추가: "invalid::truncated_trailer_prevents_publication": "actual-file-job", | |
| 109 | 추가: "limits::exact_limits_in_all_stages_allow_commit": "actual-file-job", | |
| 110 | 추가: "limits::gzip_input_limit_stops_after_snapshot": "actual-file-job", | |
| 111 | 추가: "limits::gzip_metadata_limit_preserves_header_cost": "actual-file-job", | |
| 112 | 추가: "limits::gzip_processed_failure_includes_post_checkpoint_charge": "actual-file-job", | |
| 113 | 추가: "limits::gzip_selected_output_limit_preserves_consumed_cost": "actual-file-job", | |
| 114 | 추가: "limits::invalid_decode_duration_retains_snapshot_cost": "actual-file-job", | |
| 115 | 추가: "limits::invalid_publication_duration_retains_both_prior_costs": "actual-file-job", | |
| 116 | 추가: "limits::invalid_snapshot_duration_has_zero_cost": "actual-file-job", | |
| 117 | 추가: "limits::publication_byte_limit_preserves_completed_prior_stages": "actual-file-job", | |
| 118 | 추가: "limits::publication_call_limit_retains_pre_eof_usage": "actual-file-job", | |
| 119 | 추가: "limits::publication_io_limit_retains_pre_eof_usage": "actual-file-job", | |
| 120 | 추가: "limits::snapshot_byte_limit_preserves_partial_usage": "actual-file-job", | |
| 121 | 추가: "limits::snapshot_call_limit_retains_last_eof_reservation_boundary": "actual-file-job", | |
| 122 | 추가: "limits::snapshot_io_limit_retains_last_eof_reservation_boundary": "actual-file-job", | |
| 123 | 추가: "namespace::existing_directory_and_child_survive_conflict": "actual-file-job", | |
| 124 | 추가: "namespace::existing_file_bytes_and_identity_survive_conflict": "actual-file-job", | |
| 125 | 추가: "namespace::existing_symlink_and_target_survive_conflict": "actual-file-job", | |
| 126 | 추가: "namespace::identical_input_and_output_name_preserves_archive": "actual-file-job", | |
| 127 | 추가: "namespace::missing_owned_input_preserves_native_open_error": "actual-file-job", | |
| 128 | 추가: "namespace::replaced_parent_path_does_not_redirect_pinned_commit": "actual-file-job-with-controlled-callback-or-schedule", | |
| 129 | 추가: "success::chunk_minus_one_output": "actual-file-job", | |
| 130 | 추가: "success::chunk_output": "actual-file-job", | |
| 131 | 추가: "success::chunk_plus_one_output": "actual-file-job", | |
| 132 | 추가: "success::empty_output": "actual-file-job", | |
| 133 | 추가: "success::header_name_and_comment_never_select_destination": "actual-file-job", | |
| 134 | 추가: "success::known_bytes_output": "actual-file-job", | |
| 135 | 추가: "success::one_byte_output": "actual-file-job", | |
| 136 | 추가: "success::replacing_input_after_snapshot_uses_captured_owned_bytes": "actual-file-job-with-controlled-callback-or-schedule" | |
| 137 | 추가: }, | |
| 138 | 추가: "entrypoint": "61 cases exercise original FileJob::run with owned synthetic inputs. The two-job race calls it twice; one separate unused-job Drop case covers gate lifecycle only. No fake native reports or copied production implementation.", | |
| 139 | 추가: "fixtures": "Small in-memory GZip generator uses uncompressed DEFLATE blocks <=65535 and bitwise CRC32. Original content <=65537 bytes, header strings synthetic. No repository/user archive input, shell/network/process launcher or host font access.", | |
| 140 | 추가: "coverage": { | |
| 141 | 추가: "normal": "Empty/one/known bytes and 65535/65536/65537 outputs; actual published bytes, observed input identity/SHA256, GZip boundary/CRC, file receipt identity, native durability, close results and namespace.", | |
| 142 | 추가: "ownership": "Replace owned input pathname only at Decode::Start after snapshot completed. Output still comes from old captured bytes; replacement and saved original remain intact until assertions finish. Header FNAME/FCOMMENT are not destinations.", | |
| 143 | 추가: "invalid": "Bad magic, invalid DEFLATE, CRC/ISIZE mismatch, concatenated member, trailing byte and truncated trailer retain typed error class; publication events/Usage remain zero and output absent.", | |
| 144 | 추가: "usage": "Exact small-input budgets and one-less snapshot bytes/I/O/read calls, GZip input/processed/output/metadata and publication bytes/I/O/calls. Invalid zero durations at each stage. Compare final counters including post-checkpoint decode charge; no sums across incompatible units.", | |
| 145 | 추가: "observer": "Rc pointer-identical non-Send callback errors at snapshot Finalizing, decode AfterOutput and publication BeforeCommit survive an overlapping accepted cancellation. Later stage events/output forbidden.", | |
| 146 | 추가: "cancellation": "Pre-request idempotence; first checkpoint at all 5 snapshot, 7 decoder and 4 publication stages; local Stop::Cancelled at each phase; external acknowledged BeforeCommit cancellation; Finished after return preserves committed bytes.", | |
| 147 | 추가: "namespace": "Existing file/directory/symlink and input==output retain bytes/identity; owned parent rename at BeforeCommit still commits to pinned old parent. Two prepared FileJobs compete for one name with exactly one full winner and one typed EEXIST.", | |
| 148 | 추가: "cleanup": "No Drop cleanup for Sandbox. Assertions and bounded thread completion precede explicit finish; failed files stay for diagnosis. Check owned open descriptors before removing only identity-matched private case root.", | |
| 149 | 추가: "reports": "Actual NotCommitted/Committed exercised with native Cleanup and durability. CommitUncertain, failed sync/close are not fabricated as execution evidence." | |
| 150 | 추가: }, | |
| 151 | 추가: "unverified": [ | |
| 152 | 추가: "Rust type checking, compilation, discovery and runtime of these new tests are deferred until fixed head review.", | |
| 153 | 추가: "TooLate CAS-to-link window has no deterministic barrier. Finished after return is not TooLate coverage.", | |
| 154 | 추가: "Non-EEXIST linkat/CommitUncertain, file or parent fsync failures, close failures, partial/zero writes, read/seek errors, allocation failures and adverse filesystem faults are not deterministically injected.", | |
| 155 | 추가: "MissingSelectedOutput and SelectedLengthMismatch cannot be produced by the normal decoder API. No private receipt construction or syscall interposition.", | |
| 156 | 추가: "Real elapsed deadline expiry, hostile concurrent input ABA, crash durability, physical deletion and hard resource interruption are unverified.", | |
| 157 | 추가: "OS worker isolation, product Published, UI integration, Windows, Ubuntu24 native platform and folder extraction are outside this suite.", | |
| 158 | 추가: "Prior PR51 54 passes are native publication evidence only and are not counted as FileJob executions." | |
| 159 | 추가: ], | |
| 160 | 추가: "minimum_seams": "Only if separately requested: test-only syscall-result injection and post-CAS barrier owned by backend, plus private selected-output validation helper. No public receipt constructor; no production modification in this candidate.", | |
| 161 | 추가: "review": "Fixed control flow preserves snapshot failure usage, final GZip Budget even after last checkpoint, original publication report and accepted cancellation gate. No confirmed source defect from read-only review; static review is not runtime proof.", | |
| 162 | 추가: "dependencies": { | |
| 163 | 추가: "new_registry_versions": 0, | |
| 164 | 추가: "direct_existing": [ | |
| 165 | 추가: "libc =0.2.191 std", | |
| 166 | 추가: "sha2 =0.10.9 std force-soft" | |
| 167 | 추가: ], | |
| 168 | 추가: "path": "../../experiments/rust-gzip-file-job", | |
| 169 | 추가: "expected_registry_packages": 11 | |
| 170 | 추가: }, | |
| 171 | 추가: "deliverables": [ | |
| 172 | 추가: "Cargo.toml", | |
| 173 | 추가: "Cargo.lock", | |
| 174 | 추가: "main.rs", | |
| 175 | 추가: "support.rs", | |
| 176 | 추가: "fixtures.rs", | |
| 177 | 추가: "success.rs", | |
| 178 | 추가: "invalid.rs", | |
| 179 | 추가: "limits.rs", | |
| 180 | 추가: "control.rs", | |
| 181 | 추가: "namespace.rs", | |
| 182 | 추가: "concurrency.rs", | |
| 183 | 추가: "source-pins.json", | |
| 184 | 추가: "contract.json", | |
| 185 | 추가: "run-plan.json", | |
| 186 | 추가: "static_check.py", | |
| 187 | 추가: "static_check_helper_tests.py", | |
| 188 | 추가: "SHA256SUMS" | |
| 189 | 추가: ] | |
| 190 | 추가: } |
| @@ -0,0 +1,287 @@ | ||
| 1 | 추가: use crate::{fixtures::*, support::*}; | |
| 2 | 추가: use job::{Event, FileJob, Limits, Outcome, Report, Stop, gzip, publication, snapshot}; | |
| 3 | 추가: use std::{fs, rc::Rc}; | |
| 4 | 추가: | |
| 5 | 추가: #[derive(Clone, Copy)] | |
| 6 | 추가: enum Target { | |
| 7 | 추가: Snapshot(snapshot::Stage), | |
| 8 | 추가: Decode(gzip::Stage), | |
| 9 | 추가: Publication(publication::Stage), | |
| 10 | 추가: } | |
| 11 | 추가: | |
| 12 | 추가: impl Target { | |
| 13 | 추가: fn matches(self, event: Event) -> bool { | |
| 14 | 추가: match (self, event) { | |
| 15 | 추가: (Self::Snapshot(stage), Event::Snapshot(point)) => stage == point.stage, | |
| 16 | 추가: (Self::Decode(stage), Event::Decode(point)) => stage == point.stage, | |
| 17 | 추가: (Self::Publication(stage), Event::Publication(point)) => stage == point.stage, | |
| 18 | 추가: _ => false, | |
| 19 | 추가: } | |
| 20 | 추가: } | |
| 21 | 추가: } | |
| 22 | 추가: | |
| 23 | 추가: fn cancelled(report: &Report<()>, target: Target) { | |
| 24 | 추가: match (&report.outcome, target) { | |
| 25 | 추가: (Outcome::SnapshotFailed(failure), Target::Snapshot(_)) => { | |
| 26 | 추가: assert!(matches!(failure.cause, snapshot::Error::Cancelled)) | |
| 27 | 추가: } | |
| 28 | 추가: ( | |
| 29 | 추가: Outcome::DecodeFailed(gzip::Error::Reader(gzip::Failure::Cancelled)), | |
| 30 | 추가: Target::Decode(_), | |
| 31 | 추가: ) => {} | |
| 32 | 추가: (Outcome::Publication(native), Target::Publication(stage)) => { | |
| 33 | 추가: assert!(matches!( | |
| 34 | 추가: native.outcome, | |
| 35 | 추가: publication::Outcome::NotCommitted(publication::Error::Cancelled) | |
| 36 | 추가: )); | |
| 37 | 추가: assert_eq!(native.usage.link_calls, 0); | |
| 38 | 추가: cleanup( | |
| 39 | 추가: &native.cleanup, | |
| 40 | 추가: match stage { | |
| 41 | 추가: publication::Stage::Opening => 0, | |
| 42 | 추가: publication::Stage::BeforeCommit => 4, | |
| 43 | 추가: _ => 2, | |
| 44 | 추가: }, | |
| 45 | 추가: ); | |
| 46 | 추가: } | |
| 47 | 추가: _ => panic!("취소 원인이 해당 단계에 보존되지 않음"), | |
| 48 | 추가: } | |
| 49 | 추가: } | |
| 50 | 추가: | |
| 51 | 추가: fn cancel_at(target: Target, local_stop: bool) { | |
| 52 | 추가: let sandbox = Sandbox::new(); | |
| 53 | 추가: let archive = stored(b"abc"); | |
| 54 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 55 | 추가: let before = identity(&input); | |
| 56 | 추가: let parent = sandbox.parent(); | |
| 57 | 추가: let (task, cancel) = FileJob::new(); | |
| 58 | 추가: let mut trace = Trace::default(); | |
| 59 | 추가: let mut reached = false; | |
| 60 | 추가: let report = task.run(request(&input, &parent, Limits::default()), |point| { | |
| 61 | 추가: trace.push(point); | |
| 62 | 추가: if target.matches(point.event) { | |
| 63 | 추가: reached = true; | |
| 64 | 추가: if local_stop { | |
| 65 | 추가: return Err(Stop::<()>::Cancelled); | |
| 66 | 추가: } | |
| 67 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Requested); | |
| 68 | 추가: assert_eq!( | |
| 69 | 추가: cancel.clone().request(), | |
| 70 | 추가: publication::CancelDecision::AlreadyRequested | |
| 71 | 추가: ); | |
| 72 | 추가: } | |
| 73 | 추가: Ok(()) | |
| 74 | 추가: }); | |
| 75 | 추가: assert!(reached); | |
| 76 | 추가: trace.finish(&report); | |
| 77 | 추가: assert!(target.matches(trace.points.last().unwrap().event)); | |
| 78 | 추가: assert_eq!(report.usage, trace.points.last().unwrap().usage); | |
| 79 | 추가: cancelled(&report, target); | |
| 80 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 81 | 추가: assert!(names(&parent).is_empty()); | |
| 82 | 추가: assert_eq!(identity(&input), before); | |
| 83 | 추가: sandbox.finish(); | |
| 84 | 추가: } | |
| 85 | 추가: | |
| 86 | 추가: #[test] | |
| 87 | 추가: fn pre_cancel_stops_before_snapshot_open() { | |
| 88 | 추가: let sandbox = Sandbox::new(); | |
| 89 | 추가: let input = sandbox.file("input.gz", &stored(b"abc")); | |
| 90 | 추가: let (task, cancel) = FileJob::new(); | |
| 91 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Requested); | |
| 92 | 추가: assert_eq!( | |
| 93 | 추가: cancel.clone().request(), | |
| 94 | 추가: publication::CancelDecision::AlreadyRequested | |
| 95 | 추가: ); | |
| 96 | 추가: let mut trace = Trace::default(); | |
| 97 | 추가: let report = task.run( | |
| 98 | 추가: request(&input, &sandbox.parent(), Limits::default()), | |
| 99 | 추가: |point| { | |
| 100 | 추가: trace.push(point); | |
| 101 | 추가: Ok::<_, Stop<()>>(()) | |
| 102 | 추가: }, | |
| 103 | 추가: ); | |
| 104 | 추가: trace.finish(&report); | |
| 105 | 추가: assert_eq!(trace.points.len(), 1); | |
| 106 | 추가: assert_eq!(report.usage, job::Usage::default()); | |
| 107 | 추가: cancelled(&report, Target::Snapshot(snapshot::Stage::Opening)); | |
| 108 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 109 | 추가: assert!(names(&sandbox.parent()).is_empty()); | |
| 110 | 추가: sandbox.finish(); | |
| 111 | 추가: } | |
| 112 | 추가: | |
| 113 | 추가: fn observer_error(target: Target) { | |
| 114 | 추가: let sandbox = Sandbox::new(); | |
| 115 | 추가: let input = sandbox.file("input.gz", &stored(b"abc")); | |
| 116 | 추가: let parent = sandbox.parent(); | |
| 117 | 추가: let marker = Rc::new(String::from("원래 observer 오류")); | |
| 118 | 추가: let (task, cancel) = FileJob::new(); | |
| 119 | 추가: let mut trace = Trace::default(); | |
| 120 | 추가: let report = task.run(request(&input, &parent, Limits::default()), |point| { | |
| 121 | 추가: trace.push(point); | |
| 122 | 추가: if target.matches(point.event) { | |
| 123 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Requested); | |
| 124 | 추가: Err(Stop::Callback(marker.clone())) | |
| 125 | 추가: } else { | |
| 126 | 추가: Ok(()) | |
| 127 | 추가: } | |
| 128 | 추가: }); | |
| 129 | 추가: trace.finish(&report); | |
| 130 | 추가: let actual = match &report.outcome { | |
| 131 | 추가: Outcome::SnapshotFailed(snapshot::Failure { | |
| 132 | 추가: cause: snapshot::Error::Callback(value), | |
| 133 | 추가: .. | |
| 134 | 추가: }) => value, | |
| 135 | 추가: Outcome::DecodeFailed(gzip::Error::Callback(value)) => value, | |
| 136 | 추가: Outcome::Publication(native) => { | |
| 137 | 추가: cleanup(&native.cleanup, 4); | |
| 138 | 추가: assert_eq!(native.usage.link_calls, 0); | |
| 139 | 추가: match &native.outcome { | |
| 140 | 추가: publication::Outcome::NotCommitted(publication::Error::Callback(value)) => value, | |
| 141 | 추가: _ => panic!("게시 callback 오류 원형이 사라짐"), | |
| 142 | 추가: } | |
| 143 | 추가: } | |
| 144 | 추가: _ => panic!("callback 오류 원형이 사라짐"), | |
| 145 | 추가: }; | |
| 146 | 추가: assert!(Rc::ptr_eq(actual, &marker)); | |
| 147 | 추가: assert_eq!(report.usage, trace.points.last().unwrap().usage); | |
| 148 | 추가: assert!(target.matches(trace.points.last().unwrap().event)); | |
| 149 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 150 | 추가: assert!(names(&parent).is_empty()); | |
| 151 | 추가: sandbox.finish(); | |
| 152 | 추가: } | |
| 153 | 추가: | |
| 154 | 추가: #[test] | |
| 155 | 추가: fn snapshot_observer_error_beats_accepted_cancel() { | |
| 156 | 추가: observer_error(Target::Snapshot(snapshot::Stage::Finalizing)); | |
| 157 | 추가: } | |
| 158 | 추가: #[test] | |
| 159 | 추가: fn decode_observer_error_beats_accepted_cancel() { | |
| 160 | 추가: observer_error(Target::Decode(gzip::Stage::AfterOutput)); | |
| 161 | 추가: } | |
| 162 | 추가: #[test] | |
| 163 | 추가: fn publication_observer_error_beats_accepted_cancel() { | |
| 164 | 추가: observer_error(Target::Publication(publication::Stage::BeforeCommit)); | |
| 165 | 추가: } | |
| 166 | 추가: | |
| 167 | 추가: #[test] | |
| 168 | 추가: fn local_snapshot_stop_does_not_need_cancel_request() { | |
| 169 | 추가: cancel_at(Target::Snapshot(snapshot::Stage::Comparing), true); | |
| 170 | 추가: } | |
| 171 | 추가: #[test] | |
| 172 | 추가: fn local_decode_stop_does_not_need_cancel_request() { | |
| 173 | 추가: cancel_at(Target::Decode(gzip::Stage::AfterOutput), true); | |
| 174 | 추가: } | |
| 175 | 추가: #[test] | |
| 176 | 추가: fn local_publication_stop_does_not_need_cancel_request() { | |
| 177 | 추가: cancel_at(Target::Publication(publication::Stage::BeforeCommit), true); | |
| 178 | 추가: } | |
| 179 | 추가: | |
| 180 | 추가: #[test] | |
| 181 | 추가: fn cancellation_after_return_preserves_committed_bytes() { | |
| 182 | 추가: let sandbox = Sandbox::new(); | |
| 183 | 추가: let archive = stored(b"abc"); | |
| 184 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 185 | 추가: let parent = sandbox.parent(); | |
| 186 | 추가: let (task, cancel) = FileJob::new(); | |
| 187 | 추가: let report = task.run(request(&input, &parent, Limits::default()), |_| { | |
| 188 | 추가: Ok::<_, Stop<()>>(()) | |
| 189 | 추가: }); | |
| 190 | 추가: let before = identity(&parent.join("output")); | |
| 191 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 192 | 추가: assert_eq!( | |
| 193 | 추가: cancel.clone().request(), | |
| 194 | 추가: publication::CancelDecision::Finished | |
| 195 | 추가: ); | |
| 196 | 추가: committed(&report, &parent, b"abc"); | |
| 197 | 추가: assert_eq!(identity(&parent.join("output")), before); | |
| 198 | 추가: assert_eq!(fs::read(&input).unwrap(), archive); | |
| 199 | 추가: sandbox.finish(); | |
| 200 | 추가: } | |
| 201 | 추가: | |
| 202 | 추가: #[test] | |
| 203 | 추가: fn dropping_unused_job_finishes_its_gate() { | |
| 204 | 추가: let (task, cancel) = FileJob::new(); | |
| 205 | 추가: drop(task); | |
| 206 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 207 | 추가: } | |
| 208 | 추가: | |
| 209 | 추가: #[test] | |
| 210 | 추가: fn cancel_snapshot_opening() { | |
| 211 | 추가: cancel_at(Target::Snapshot(snapshot::Stage::Opening), false); | |
| 212 | 추가: } | |
| 213 | 추가: | |
| 214 | 추가: #[test] | |
| 215 | 추가: fn cancel_snapshot_pinned() { | |
| 216 | 추가: cancel_at(Target::Snapshot(snapshot::Stage::Pinned), false); | |
| 217 | 추가: } | |
| 218 | 추가: | |
| 219 | 추가: #[test] | |
| 220 | 추가: fn cancel_snapshot_copying() { | |
| 221 | 추가: cancel_at(Target::Snapshot(snapshot::Stage::Copying), false); | |
| 222 | 추가: } | |
| 223 | 추가: | |
| 224 | 추가: #[test] | |
| 225 | 추가: fn cancel_snapshot_comparing() { | |
| 226 | 추가: cancel_at(Target::Snapshot(snapshot::Stage::Comparing), false); | |
| 227 | 추가: } | |
| 228 | 추가: | |
| 229 | 추가: #[test] | |
| 230 | 추가: fn cancel_snapshot_finalizing() { | |
| 231 | 추가: cancel_at(Target::Snapshot(snapshot::Stage::Finalizing), false); | |
| 232 | 추가: } | |
| 233 | 추가: | |
| 234 | 추가: #[test] | |
| 235 | 추가: fn cancel_decode_start() { | |
| 236 | 추가: cancel_at(Target::Decode(gzip::Stage::Start), false); | |
| 237 | 추가: } | |
| 238 | 추가: | |
| 239 | 추가: #[test] | |
| 240 | 추가: fn cancel_decode_header() { | |
| 241 | 추가: cancel_at(Target::Decode(gzip::Stage::Header), false); | |
| 242 | 추가: } | |
| 243 | 추가: | |
| 244 | 추가: #[test] | |
| 245 | 추가: fn cancel_decode_before_inflate() { | |
| 246 | 추가: cancel_at(Target::Decode(gzip::Stage::BeforeInflate), false); | |
| 247 | 추가: } | |
| 248 | 추가: | |
| 249 | 추가: #[test] | |
| 250 | 추가: fn cancel_decode_after_inflate() { | |
| 251 | 추가: cancel_at(Target::Decode(gzip::Stage::AfterInflate), false); | |
| 252 | 추가: } | |
| 253 | 추가: | |
| 254 | 추가: #[test] | |
| 255 | 추가: fn cancel_decode_after_output() { | |
| 256 | 추가: cancel_at(Target::Decode(gzip::Stage::AfterOutput), false); | |
| 257 | 추가: } | |
| 258 | 추가: | |
| 259 | 추가: #[test] | |
| 260 | 추가: fn cancel_decode_trailer() { | |
| 261 | 추가: cancel_at(Target::Decode(gzip::Stage::Trailer), false); | |
| 262 | 추가: } | |
| 263 | 추가: | |
| 264 | 추가: #[test] | |
| 265 | 추가: fn cancel_decode_before_return() { | |
| 266 | 추가: cancel_at(Target::Decode(gzip::Stage::BeforeReturn), false); | |
| 267 | 추가: } | |
| 268 | 추가: | |
| 269 | 추가: #[test] | |
| 270 | 추가: fn cancel_publication_opening() { | |
| 271 | 추가: cancel_at(Target::Publication(publication::Stage::Opening), false); | |
| 272 | 추가: } | |
| 273 | 추가: | |
| 274 | 추가: #[test] | |
| 275 | 추가: fn cancel_publication_writing() { | |
| 276 | 추가: cancel_at(Target::Publication(publication::Stage::Writing), false); | |
| 277 | 추가: } | |
| 278 | 추가: | |
| 279 | 추가: #[test] | |
| 280 | 추가: fn cancel_publication_verifying() { | |
| 281 | 추가: cancel_at(Target::Publication(publication::Stage::Verifying), false); | |
| 282 | 추가: } | |
| 283 | 추가: | |
| 284 | 추가: #[test] | |
| 285 | 추가: fn cancel_publication_before_commit() { | |
| 286 | 추가: cancel_at(Target::Publication(publication::Stage::BeforeCommit), false); | |
| 287 | 추가: } |
| @@ -0,0 +1,39 @@ | ||
| 1 | 추가: pub fn pattern(length: usize) -> Vec<u8> { | |
| 2 | 추가: (0..length).map(|i| ((i * 37 + 11) % 251) as u8).collect() | |
| 3 | 추가: } | |
| 4 | 추가: | |
| 5 | 추가: pub fn crc32(bytes: &[u8]) -> u32 { | |
| 6 | 추가: let mut value = !0_u32; | |
| 7 | 추가: for byte in bytes { | |
| 8 | 추가: value ^= u32::from(*byte); | |
| 9 | 추가: for _ in 0..8 { | |
| 10 | 추가: value = (value >> 1) ^ (0xedb8_8320 & 0_u32.wrapping_sub(value & 1)); | |
| 11 | 추가: } | |
| 12 | 추가: } | |
| 13 | 추가: !value | |
| 14 | 추가: } | |
| 15 | 추가: | |
| 16 | 추가: pub fn stored(bytes: &[u8]) -> Vec<u8> { | |
| 17 | 추가: assert!(bytes.len() <= 65_537); | |
| 18 | 추가: let mut archive = vec![0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 0, 255]; | |
| 19 | 추가: let blocks = bytes.len().max(1).div_ceil(65_535); | |
| 20 | 추가: for index in 0..blocks { | |
| 21 | 추가: let start = index * 65_535; | |
| 22 | 추가: let end = (start + 65_535).min(bytes.len()); | |
| 23 | 추가: let length = (end - start) as u16; | |
| 24 | 추가: archive.push(u8::from(index + 1 == blocks)); | |
| 25 | 추가: archive.extend_from_slice(&length.to_le_bytes()); | |
| 26 | 추가: archive.extend_from_slice(&(!length).to_le_bytes()); | |
| 27 | 추가: archive.extend_from_slice(&bytes[start..end]); | |
| 28 | 추가: } | |
| 29 | 추가: archive.extend_from_slice(&crc32(bytes).to_le_bytes()); | |
| 30 | 추가: archive.extend_from_slice(&(bytes.len() as u32).to_le_bytes()); | |
| 31 | 추가: archive | |
| 32 | 추가: } | |
| 33 | 추가: | |
| 34 | 추가: pub fn named(bytes: &[u8]) -> Vec<u8> { | |
| 35 | 추가: let mut archive = stored(bytes); | |
| 36 | 추가: archive[3] = 8 | 16; | |
| 37 | 추가: archive.splice(10..10, b"../header-name\0../comment-name\0".iter().copied()); | |
| 38 | 추가: archive | |
| 39 | 추가: } |
| @@ -0,0 +1,72 @@ | ||
| 1 | 추가: use crate::{fixtures::*, support::*}; | |
| 2 | 추가: use job::{Limits, Outcome, gzip}; | |
| 3 | 추가: | |
| 4 | 추가: fn rejected(archive: Vec<u8>, expected: Option<gzip::Failure>) { | |
| 5 | 추가: let sandbox = Sandbox::new(); | |
| 6 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 7 | 추가: let before = identity(&input); | |
| 8 | 추가: let parent = sandbox.parent(); | |
| 9 | 추가: let (report, trace) = run(&input, &parent, Limits::default()); | |
| 10 | 추가: match (&report.outcome, expected) { | |
| 11 | 추가: (Outcome::DecodeFailed(gzip::Error::Reader(actual)), Some(expected)) => { | |
| 12 | 추가: assert_eq!(*actual, expected) | |
| 13 | 추가: } | |
| 14 | 추가: (Outcome::DecodeFailed(gzip::Error::Backend(_)), None) => {} | |
| 15 | 추가: _ => panic!("원래 GZip 실패 종류가 보존되지 않음"), | |
| 16 | 추가: } | |
| 17 | 추가: trace.finish(&report); | |
| 18 | 추가: snapshot_usage(report.usage.snapshot, archive.len()); | |
| 19 | 추가: assert_eq!( | |
| 20 | 추가: report.snapshot.as_ref().unwrap().identity().inode(), | |
| 21 | 추가: before.1 | |
| 22 | 추가: ); | |
| 23 | 추가: assert!(names(&parent).is_empty()); | |
| 24 | 추가: assert_eq!(identity(&input), before); | |
| 25 | 추가: assert_eq!(std::fs::read(input).unwrap(), archive); | |
| 26 | 추가: sandbox.finish(); | |
| 27 | 추가: } | |
| 28 | 추가: | |
| 29 | 추가: #[test] | |
| 30 | 추가: fn invalid_magic_prevents_publication() { | |
| 31 | 추가: let mut archive = stored(b"abc"); | |
| 32 | 추가: archive[0] = 0; | |
| 33 | 추가: rejected(archive, Some(gzip::Failure::Header)); | |
| 34 | 추가: } | |
| 35 | 추가: #[test] | |
| 36 | 추가: fn invalid_deflate_preserves_backend_error() { | |
| 37 | 추가: let mut archive = stored(b"abc"); | |
| 38 | 추가: archive[10] = 7; | |
| 39 | 추가: rejected(archive, None); | |
| 40 | 추가: } | |
| 41 | 추가: #[test] | |
| 42 | 추가: fn bad_crc_prevents_publication() { | |
| 43 | 추가: let mut archive = stored(b"abc"); | |
| 44 | 추가: let index = archive.len() - 8; | |
| 45 | 추가: archive[index] ^= 1; | |
| 46 | 추가: rejected(archive, Some(gzip::Failure::Crc)); | |
| 47 | 추가: } | |
| 48 | 추가: #[test] | |
| 49 | 추가: fn bad_size_prevents_publication() { | |
| 50 | 추가: let mut archive = stored(b"abc"); | |
| 51 | 추가: let index = archive.len() - 4; | |
| 52 | 추가: archive[index] ^= 1; | |
| 53 | 추가: rejected(archive, Some(gzip::Failure::Size)); | |
| 54 | 추가: } | |
| 55 | 추가: #[test] | |
| 56 | 추가: fn concatenated_members_prevent_publication() { | |
| 57 | 추가: let mut archive = stored(b"abc"); | |
| 58 | 추가: archive.extend(stored(b"def")); | |
| 59 | 추가: rejected(archive, Some(gzip::Failure::TrailingData)); | |
| 60 | 추가: } | |
| 61 | 추가: #[test] | |
| 62 | 추가: fn trailing_byte_prevents_publication() { | |
| 63 | 추가: let mut archive = stored(b"abc"); | |
| 64 | 추가: archive.push(0); | |
| 65 | 추가: rejected(archive, Some(gzip::Failure::TrailingData)); | |
| 66 | 추가: } | |
| 67 | 추가: #[test] | |
| 68 | 추가: fn truncated_trailer_prevents_publication() { | |
| 69 | 추가: let mut archive = stored(b"abc"); | |
| 70 | 추가: archive.pop(); | |
| 71 | 추가: rejected(archive, Some(gzip::Failure::Truncated)); | |
| 72 | 추가: } |
| @@ -0,0 +1,273 @@ | ||
| 1 | 추가: use crate::{fixtures::*, support::*}; | |
| 2 | 추가: use job::{Limits, Outcome, gzip, publication, snapshot}; | |
| 3 | 추가: use std::time::Duration; | |
| 4 | 추가: | |
| 5 | 추가: fn snapshot_limit(kind: snapshot::LimitKind) { | |
| 6 | 추가: let sandbox = Sandbox::new(); | |
| 7 | 추가: let archive = stored(b"abc"); | |
| 8 | 추가: let length = archive.len() as u64; | |
| 9 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 10 | 추가: let parent = sandbox.parent(); | |
| 11 | 추가: let mut limits = Limits::default(); | |
| 12 | 추가: match kind { | |
| 13 | 추가: snapshot::LimitKind::Bytes => limits.snapshot.max_bytes = length - 1, | |
| 14 | 추가: snapshot::LimitKind::IoBytes => limits.snapshot.max_io_bytes = 2 * length + 1, | |
| 15 | 추가: snapshot::LimitKind::ReadCalls => limits.snapshot.max_read_calls = 3, | |
| 16 | 추가: _ => unreachable!(), | |
| 17 | 추가: } | |
| 18 | 추가: let (report, _) = run(&input, &parent, limits); | |
| 19 | 추가: match &report.outcome { | |
| 20 | 추가: Outcome::SnapshotFailed(snapshot::Failure { | |
| 21 | 추가: cause: snapshot::Error::Limit(actual), | |
| 22 | 추가: usage, | |
| 23 | 추가: }) => { | |
| 24 | 추가: assert_eq!(*actual, kind); | |
| 25 | 추가: assert_eq!(*usage, report.usage.snapshot); | |
| 26 | 추가: } | |
| 27 | 추가: _ => panic!("snapshot 한도 오류가 아님"), | |
| 28 | 추가: } | |
| 29 | 추가: let expected = if kind == snapshot::LimitKind::Bytes { | |
| 30 | 추가: snapshot::Usage { | |
| 31 | 추가: open_calls: 1, | |
| 32 | 추가: metadata_calls: 1, | |
| 33 | 추가: ..snapshot::Usage::default() | |
| 34 | 추가: } | |
| 35 | 추가: } else { | |
| 36 | 추가: snapshot::Usage { | |
| 37 | 추가: open_calls: 4, | |
| 38 | 추가: metadata_calls: 4, | |
| 39 | 추가: read_calls: 3, | |
| 40 | 추가: reserved_read_bytes: 2 * length + 1, | |
| 41 | 추가: actual_read_bytes: 2 * length, | |
| 42 | 추가: compared_bytes: length, | |
| 43 | 추가: } | |
| 44 | 추가: }; | |
| 45 | 추가: assert_eq!(report.usage.snapshot, expected); | |
| 46 | 추가: assert!(names(&parent).is_empty()); | |
| 47 | 추가: sandbox.finish(); | |
| 48 | 추가: } | |
| 49 | 추가: #[test] | |
| 50 | 추가: fn snapshot_byte_limit_preserves_partial_usage() { | |
| 51 | 추가: snapshot_limit(snapshot::LimitKind::Bytes); | |
| 52 | 추가: } | |
| 53 | 추가: #[test] | |
| 54 | 추가: fn snapshot_io_limit_retains_last_eof_reservation_boundary() { | |
| 55 | 추가: snapshot_limit(snapshot::LimitKind::IoBytes); | |
| 56 | 추가: } | |
| 57 | 추가: #[test] | |
| 58 | 추가: fn snapshot_call_limit_retains_last_eof_reservation_boundary() { | |
| 59 | 추가: snapshot_limit(snapshot::LimitKind::ReadCalls); | |
| 60 | 추가: } | |
| 61 | 추가: | |
| 62 | 추가: fn gzip_limit(field: &str) { | |
| 63 | 추가: let sandbox = Sandbox::new(); | |
| 64 | 추가: let archive = stored(b"abc"); | |
| 65 | 추가: let length = archive.len() as u64; | |
| 66 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 67 | 추가: let parent = sandbox.parent(); | |
| 68 | 추가: let mut limits = Limits::default(); | |
| 69 | 추가: let expected = match field { | |
| 70 | 추가: "input" => { | |
| 71 | 추가: limits.gzip.input = length - 1; | |
| 72 | 추가: gzip::Usage::default() | |
| 73 | 추가: } | |
| 74 | 추가: "processed" => { | |
| 75 | 추가: limits.gzip.processed = length + 2; | |
| 76 | 추가: gzip::Usage { | |
| 77 | 추가: processed: length + 3, | |
| 78 | 추가: output: 0, | |
| 79 | 추가: metadata: 10, | |
| 80 | 추가: } | |
| 81 | 추가: } | |
| 82 | 추가: "output" => { | |
| 83 | 추가: limits.gzip.output = 2; | |
| 84 | 추가: gzip::Usage { | |
| 85 | 추가: processed: length + 3, | |
| 86 | 추가: output: 0, | |
| 87 | 추가: metadata: 10, | |
| 88 | 추가: } | |
| 89 | 추가: } | |
| 90 | 추가: "metadata" => { | |
| 91 | 추가: limits.gzip.metadata = 9; | |
| 92 | 추가: gzip::Usage { | |
| 93 | 추가: processed: 9, | |
| 94 | 추가: output: 0, | |
| 95 | 추가: metadata: 9, | |
| 96 | 추가: } | |
| 97 | 추가: } | |
| 98 | 추가: _ => unreachable!(), | |
| 99 | 추가: }; | |
| 100 | 추가: let (report, trace) = run(&input, &parent, limits); | |
| 101 | 추가: assert!(matches!( | |
| 102 | 추가: report.outcome, | |
| 103 | 추가: Outcome::DecodeFailed(gzip::Error::Reader(gzip::Failure::Budget)) | |
| 104 | 추가: )); | |
| 105 | 추가: assert_eq!(report.usage.gzip, expected); | |
| 106 | 추가: snapshot_usage(report.usage.snapshot, archive.len()); | |
| 107 | 추가: if field == "processed" { | |
| 108 | 추가: assert!(report.usage.gzip.processed > trace.points.last().unwrap().usage.gzip.processed); | |
| 109 | 추가: } | |
| 110 | 추가: assert!(names(&parent).is_empty()); | |
| 111 | 추가: sandbox.finish(); | |
| 112 | 추가: } | |
| 113 | 추가: #[test] | |
| 114 | 추가: fn gzip_input_limit_stops_after_snapshot() { | |
| 115 | 추가: gzip_limit("input"); | |
| 116 | 추가: } | |
| 117 | 추가: #[test] | |
| 118 | 추가: fn gzip_processed_failure_includes_post_checkpoint_charge() { | |
| 119 | 추가: gzip_limit("processed"); | |
| 120 | 추가: } | |
| 121 | 추가: #[test] | |
| 122 | 추가: fn gzip_selected_output_limit_preserves_consumed_cost() { | |
| 123 | 추가: gzip_limit("output"); | |
| 124 | 추가: } | |
| 125 | 추가: #[test] | |
| 126 | 추가: fn gzip_metadata_limit_preserves_header_cost() { | |
| 127 | 추가: gzip_limit("metadata"); | |
| 128 | 추가: } | |
| 129 | 추가: | |
| 130 | 추가: fn publication_limit(field: &str) { | |
| 131 | 추가: let sandbox = Sandbox::new(); | |
| 132 | 추가: let archive = stored(b"abc"); | |
| 133 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 134 | 추가: let parent = sandbox.parent(); | |
| 135 | 추가: let mut limits = Limits::default(); | |
| 136 | 추가: match field { | |
| 137 | 추가: "bytes" => limits.publication.max_bytes = 2, | |
| 138 | 추가: "io" => limits.publication.max_io_bytes = 6, | |
| 139 | 추가: "calls" => limits.publication.max_io_calls = 2, | |
| 140 | 추가: _ => unreachable!(), | |
| 141 | 추가: } | |
| 142 | 추가: let (report, _) = run(&input, &parent, limits); | |
| 143 | 추가: let native = match &report.outcome { | |
| 144 | 추가: Outcome::Publication(native) => native, | |
| 145 | 추가: _ => panic!("게시 단계 미도달"), | |
| 146 | 추가: }; | |
| 147 | 추가: assert!(matches!( | |
| 148 | 추가: native.outcome, | |
| 149 | 추가: publication::Outcome::NotCommitted(publication::Error::LimitExceeded) | |
| 150 | 추가: )); | |
| 151 | 추가: let expected = if field == "bytes" { | |
| 152 | 추가: cleanup(&native.cleanup, 0); | |
| 153 | 추가: publication::Usage::default() | |
| 154 | 추가: } else { | |
| 155 | 추가: cleanup(&native.cleanup, 2); | |
| 156 | 추가: publication::Usage { | |
| 157 | 추가: open_calls: 2, | |
| 158 | 추가: metadata_calls: 3, | |
| 159 | 추가: sync_calls: 1, | |
| 160 | 추가: write_calls: 1, | |
| 161 | 추가: read_calls: 1, | |
| 162 | 추가: reserved_io_bytes: 6, | |
| 163 | 추가: actual_written_bytes: 3, | |
| 164 | 추가: actual_read_bytes: 3, | |
| 165 | 추가: ..publication::Usage::default() | |
| 166 | 추가: } | |
| 167 | 추가: }; | |
| 168 | 추가: assert_eq!(report.usage.publication, expected); | |
| 169 | 추가: snapshot_usage(report.usage.snapshot, archive.len()); | |
| 170 | 추가: gzip_usage(report.usage.gzip, &archive, b"abc", 10); | |
| 171 | 추가: assert!(names(&parent).is_empty()); | |
| 172 | 추가: sandbox.finish(); | |
| 173 | 추가: } | |
| 174 | 추가: #[test] | |
| 175 | 추가: fn publication_byte_limit_preserves_completed_prior_stages() { | |
| 176 | 추가: publication_limit("bytes"); | |
| 177 | 추가: } | |
| 178 | 추가: #[test] | |
| 179 | 추가: fn publication_io_limit_retains_pre_eof_usage() { | |
| 180 | 추가: publication_limit("io"); | |
| 181 | 추가: } | |
| 182 | 추가: #[test] | |
| 183 | 추가: fn publication_call_limit_retains_pre_eof_usage() { | |
| 184 | 추가: publication_limit("calls"); | |
| 185 | 추가: } | |
| 186 | 추가: | |
| 187 | 추가: #[test] | |
| 188 | 추가: fn exact_limits_in_all_stages_allow_commit() { | |
| 189 | 추가: let sandbox = Sandbox::new(); | |
| 190 | 추가: let archive = stored(b"abc"); | |
| 191 | 추가: let length = archive.len() as u64; | |
| 192 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 193 | 추가: let before = identity(&input); | |
| 194 | 추가: let parent = sandbox.parent(); | |
| 195 | 추가: let limits = Limits { | |
| 196 | 추가: snapshot: snapshot::Limits { | |
| 197 | 추가: max_bytes: length, | |
| 198 | 추가: max_io_bytes: 2 * length + 2, | |
| 199 | 추가: max_read_calls: 4, | |
| 200 | 추가: ..snapshot::Limits::default() | |
| 201 | 추가: }, | |
| 202 | 추가: gzip: gzip::Limits { | |
| 203 | 추가: input: length, | |
| 204 | 추가: processed: length + 3, | |
| 205 | 추가: output: 3, | |
| 206 | 추가: metadata: 10, | |
| 207 | 추가: ..gzip::Limits::default() | |
| 208 | 추가: }, | |
| 209 | 추가: publication: publication::Limits { | |
| 210 | 추가: max_bytes: 3, | |
| 211 | 추가: max_io_bytes: 7, | |
| 212 | 추가: max_io_calls: 3, | |
| 213 | 추가: ..publication::Limits::default() | |
| 214 | 추가: }, | |
| 215 | 추가: }; | |
| 216 | 추가: let (report, _) = run(&input, &parent, limits); | |
| 217 | 추가: observations(&report, (before.0, before.1), &archive, b"abc", 10); | |
| 218 | 추가: committed(&report, &parent, b"abc"); | |
| 219 | 추가: sandbox.finish(); | |
| 220 | 추가: } | |
| 221 | 추가: | |
| 222 | 추가: fn invalid_duration(stage: u8) { | |
| 223 | 추가: let sandbox = Sandbox::new(); | |
| 224 | 추가: let archive = stored(b"abc"); | |
| 225 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 226 | 추가: let parent = sandbox.parent(); | |
| 227 | 추가: let mut limits = Limits::default(); | |
| 228 | 추가: match stage { | |
| 229 | 추가: 0 => limits.snapshot.max_duration = Duration::ZERO, | |
| 230 | 추가: 1 => limits.gzip.duration = Duration::ZERO, | |
| 231 | 추가: 2 => limits.publication.max_duration = Duration::ZERO, | |
| 232 | 추가: _ => unreachable!(), | |
| 233 | 추가: } | |
| 234 | 추가: let (report, trace) = run(&input, &parent, limits); | |
| 235 | 추가: match (&report.outcome, stage) { | |
| 236 | 추가: (Outcome::SnapshotFailed(failure), 0) => { | |
| 237 | 추가: assert!(matches!(failure.cause, snapshot::Error::InvalidLimits)); | |
| 238 | 추가: assert_eq!(report.usage, job::Usage::default()); | |
| 239 | 추가: assert!(trace.points.is_empty()); | |
| 240 | 추가: } | |
| 241 | 추가: (Outcome::DecodeFailed(gzip::Error::Reader(gzip::Failure::InvalidRequest)), 1) => { | |
| 242 | 추가: snapshot_usage(report.usage.snapshot, archive.len()); | |
| 243 | 추가: assert_eq!(report.usage.gzip, gzip::Usage::default()); | |
| 244 | 추가: assert!(trace.points.iter().all(|p| phase(p.event) == 0)); | |
| 245 | 추가: } | |
| 246 | 추가: (Outcome::Publication(native), 2) => { | |
| 247 | 추가: snapshot_usage(report.usage.snapshot, archive.len()); | |
| 248 | 추가: gzip_usage(report.usage.gzip, &archive, b"abc", 10); | |
| 249 | 추가: assert!(matches!( | |
| 250 | 추가: native.outcome, | |
| 251 | 추가: publication::Outcome::NotCommitted(publication::Error::InvalidLimits) | |
| 252 | 추가: )); | |
| 253 | 추가: assert_eq!(native.usage, publication::Usage::default()); | |
| 254 | 추가: cleanup(&native.cleanup, 0); | |
| 255 | 추가: assert!(trace.points.iter().all(|p| phase(p.event) <= 1)); | |
| 256 | 추가: } | |
| 257 | 추가: _ => panic!("단계별 잘못된 한도 오류가 아님"), | |
| 258 | 추가: } | |
| 259 | 추가: assert!(names(&parent).is_empty()); | |
| 260 | 추가: sandbox.finish(); | |
| 261 | 추가: } | |
| 262 | 추가: #[test] | |
| 263 | 추가: fn invalid_snapshot_duration_has_zero_cost() { | |
| 264 | 추가: invalid_duration(0); | |
| 265 | 추가: } | |
| 266 | 추가: #[test] | |
| 267 | 추가: fn invalid_decode_duration_retains_snapshot_cost() { | |
| 268 | 추가: invalid_duration(1); | |
| 269 | 추가: } | |
| 270 | 추가: #[test] | |
| 271 | 추가: fn invalid_publication_duration_retains_both_prior_costs() { | |
| 272 | 추가: invalid_duration(2); | |
| 273 | 추가: } |
| @@ -0,0 +1,10 @@ | ||
| 1 | 추가: #![cfg(target_os = "linux")] | |
| 2 | 추가: | |
| 3 | 추가: mod concurrency; | |
| 4 | 추가: mod control; | |
| 5 | 추가: mod fixtures; | |
| 6 | 추가: mod invalid; | |
| 7 | 추가: mod limits; | |
| 8 | 추가: mod namespace; | |
| 9 | 추가: mod success; | |
| 10 | 추가: mod support; |
| @@ -0,0 +1,138 @@ | ||
| 1 | 추가: use crate::{fixtures::*, support::*}; | |
| 2 | 추가: use job::{Event, FileJob, Limits, Outcome, Stop, publication, snapshot}; | |
| 3 | 추가: use std::{ffi::OsStr, fs, os::unix::fs::symlink}; | |
| 4 | 추가: | |
| 5 | 추가: #[test] | |
| 6 | 추가: fn existing_file_bytes_and_identity_survive_conflict() { | |
| 7 | 추가: let sandbox = Sandbox::new(); | |
| 8 | 추가: let input = sandbox.file("input.gz", &stored(b"abc")); | |
| 9 | 추가: let existing = sandbox.file("parent/output", b"preserve"); | |
| 10 | 추가: let before = identity(&existing); | |
| 11 | 추가: let (report, _) = run(&input, &sandbox.parent(), Limits::default()); | |
| 12 | 추가: conflict(&report, 3); | |
| 13 | 추가: assert_eq!(fs::read(&existing).unwrap(), b"preserve"); | |
| 14 | 추가: assert_eq!(identity(&existing), before); | |
| 15 | 추가: assert_eq!( | |
| 16 | 추가: names(&sandbox.parent()), | |
| 17 | 추가: vec![std::ffi::OsString::from("output")] | |
| 18 | 추가: ); | |
| 19 | 추가: sandbox.finish(); | |
| 20 | 추가: } | |
| 21 | 추가: | |
| 22 | 추가: #[test] | |
| 23 | 추가: fn existing_directory_and_child_survive_conflict() { | |
| 24 | 추가: let sandbox = Sandbox::new(); | |
| 25 | 추가: let input = sandbox.file("input.gz", &stored(b"abc")); | |
| 26 | 추가: let existing = sandbox.dir("parent/output"); | |
| 27 | 추가: let child = sandbox.file("parent/output/child", b"preserve"); | |
| 28 | 추가: let before = identity(&existing); | |
| 29 | 추가: let child_before = identity(&child); | |
| 30 | 추가: let (report, _) = run(&input, &sandbox.parent(), Limits::default()); | |
| 31 | 추가: conflict(&report, 3); | |
| 32 | 추가: assert_eq!(identity(&existing), before); | |
| 33 | 추가: assert_eq!(identity(&child), child_before); | |
| 34 | 추가: assert_eq!(fs::read(child).unwrap(), b"preserve"); | |
| 35 | 추가: assert_eq!(names(&existing), vec![std::ffi::OsString::from("child")]); | |
| 36 | 추가: sandbox.finish(); | |
| 37 | 추가: } | |
| 38 | 추가: | |
| 39 | 추가: #[test] | |
| 40 | 추가: fn existing_symlink_and_target_survive_conflict() { | |
| 41 | 추가: let sandbox = Sandbox::new(); | |
| 42 | 추가: let input = sandbox.file("input.gz", &stored(b"abc")); | |
| 43 | 추가: let victim = sandbox.file("victim", b"preserve"); | |
| 44 | 추가: let existing = sandbox.parent().join("output"); | |
| 45 | 추가: symlink(&victim, &existing).unwrap(); | |
| 46 | 추가: let before = identity(&existing); | |
| 47 | 추가: let victim_before = identity(&victim); | |
| 48 | 추가: let (report, _) = run(&input, &sandbox.parent(), Limits::default()); | |
| 49 | 추가: conflict(&report, 3); | |
| 50 | 추가: assert_eq!(identity(&existing), before); | |
| 51 | 추가: assert_eq!(identity(&victim), victim_before); | |
| 52 | 추가: assert_eq!(fs::read_link(existing).unwrap(), victim); | |
| 53 | 추가: assert_eq!(fs::read(victim).unwrap(), b"preserve"); | |
| 54 | 추가: sandbox.finish(); | |
| 55 | 추가: } | |
| 56 | 추가: | |
| 57 | 추가: #[test] | |
| 58 | 추가: fn identical_input_and_output_name_preserves_archive() { | |
| 59 | 추가: let sandbox = Sandbox::new(); | |
| 60 | 추가: let archive = stored(b"abc"); | |
| 61 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 62 | 추가: let before = identity(&input); | |
| 63 | 추가: let (task, cancel) = FileJob::new(); | |
| 64 | 추가: let mut trace = Trace::default(); | |
| 65 | 추가: let report = task.run( | |
| 66 | 추가: job::Request { | |
| 67 | 추가: input: &input, | |
| 68 | 추가: output_parent: &sandbox.root, | |
| 69 | 추가: output_leaf: OsStr::new("input.gz"), | |
| 70 | 추가: limits: Limits::default(), | |
| 71 | 추가: }, | |
| 72 | 추가: |point| { | |
| 73 | 추가: trace.push(point); | |
| 74 | 추가: Ok::<_, Stop<()>>(()) | |
| 75 | 추가: }, | |
| 76 | 추가: ); | |
| 77 | 추가: trace.finish(&report); | |
| 78 | 추가: conflict(&report, 3); | |
| 79 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 80 | 추가: assert_eq!(identity(&input), before); | |
| 81 | 추가: assert_eq!(fs::read(input).unwrap(), archive); | |
| 82 | 추가: sandbox.finish(); | |
| 83 | 추가: } | |
| 84 | 추가: | |
| 85 | 추가: #[test] | |
| 86 | 추가: fn missing_owned_input_preserves_native_open_error() { | |
| 87 | 추가: let sandbox = Sandbox::new(); | |
| 88 | 추가: let (report, trace) = run( | |
| 89 | 추가: &sandbox.path("missing.gz"), | |
| 90 | 추가: &sandbox.parent(), | |
| 91 | 추가: Limits::default(), | |
| 92 | 추가: ); | |
| 93 | 추가: match &report.outcome { | |
| 94 | 추가: Outcome::SnapshotFailed(snapshot::Failure { | |
| 95 | 추가: cause: snapshot::Error::Io { operation, source }, | |
| 96 | 추가: usage, | |
| 97 | 추가: }) => { | |
| 98 | 추가: assert_eq!(*operation, snapshot::IoOperation::PinPath); | |
| 99 | 추가: assert_eq!(source.raw_os_error(), Some(libc::ENOENT)); | |
| 100 | 추가: assert_eq!( | |
| 101 | 추가: *usage, | |
| 102 | 추가: snapshot::Usage { | |
| 103 | 추가: open_calls: 1, | |
| 104 | 추가: ..snapshot::Usage::default() | |
| 105 | 추가: } | |
| 106 | 추가: ); | |
| 107 | 추가: } | |
| 108 | 추가: _ => panic!("원래 입력 open 오류가 아님"), | |
| 109 | 추가: } | |
| 110 | 추가: trace.finish(&report); | |
| 111 | 추가: assert!(names(&sandbox.parent()).is_empty()); | |
| 112 | 추가: sandbox.finish(); | |
| 113 | 추가: } | |
| 114 | 추가: | |
| 115 | 추가: #[test] | |
| 116 | 추가: fn replaced_parent_path_does_not_redirect_pinned_commit() { | |
| 117 | 추가: let sandbox = Sandbox::new(); | |
| 118 | 추가: let input = sandbox.file("input.gz", &stored(b"abc")); | |
| 119 | 추가: let parent = sandbox.parent(); | |
| 120 | 추가: let (task, cancel) = FileJob::new(); | |
| 121 | 추가: let mut trace = Trace::default(); | |
| 122 | 추가: let mut replaced = false; | |
| 123 | 추가: let report = task.run(request(&input, &parent, Limits::default()), |point| { | |
| 124 | 추가: trace.push(point); | |
| 125 | 추가: if matches!(point.event, Event::Publication(native) if native.stage == publication::Stage::BeforeCommit) { | |
| 126 | 추가: fs::rename(&parent, sandbox.path("old-parent")).unwrap(); | |
| 127 | 추가: sandbox.dir("parent"); | |
| 128 | 추가: replaced = true; | |
| 129 | 추가: } | |
| 130 | 추가: Ok::<_, Stop<()>>(()) | |
| 131 | 추가: }); | |
| 132 | 추가: assert!(replaced); | |
| 133 | 추가: trace.finish(&report); | |
| 134 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 135 | 추가: committed(&report, &sandbox.path("old-parent"), b"abc"); | |
| 136 | 추가: assert!(names(&parent).is_empty()); | |
| 137 | 추가: sandbox.finish(); | |
| 138 | 추가: } |
| @@ -0,0 +1,117 @@ | ||
| 1 | 추가: { | |
| 2 | 추가: "schema": "zipelo.gzip-file-job-run-plan.v1", | |
| 3 | 추가: "gate": "No Rust compile/discovery/FileJob execution before fixed head/manifest review. rustfmt parsing, offline lock/metadata and Python static helper tests only in preparation.", | |
| 4 | 추가: "preflight": [ | |
| 5 | 추가: "Blocking exclusive current workspace flock for every file write/build/cache mutation; fresh status and fixed input check inside lock. No source/branch checkout changes in shared workspace.", | |
| 6 | 추가: "Verify 39 remote source blobs/modes/SHA256 and complete new manifest; existing Rust1.99.1 and offline registry graph only.", | |
| 7 | 추가: "Fresh canonical owned validation and target under this tests path; refuse previous result/target reuse after failure. Preserve all old evidence.", | |
| 8 | 추가: "Create runs with mode0700 only if absent under the canonical test root; verify euid and identity. Child Sandbox creates mode0700 private case root, files0600. No chmod/chown of existing paths.", | |
| 9 | 추가: "Native Linux ext-family/XFS with procfs/openat2/O_TMPFILE only; unexpected Unsupported is a failed environment prerequisite, never skip/ignore/success. No mount/permission workaround.", | |
| 10 | 추가: "Independent synthetic fixtures only. Maximum plain payload65537 and compressed fixture <=65599 bytes; two publishers only in concurrency case." | |
| 11 | 추가: ], | |
| 12 | 추가: "target": { | |
| 13 | 추가: "manifest": "tests/rust-gzip-file-job/Cargo.toml", | |
| 14 | 추가: "name": "file_job_public_api", | |
| 15 | 추가: "exact_names": [ | |
| 16 | 추가: "concurrency::acknowledged_external_cancel_before_commit_prevents_publication", | |
| 17 | 추가: "concurrency::two_file_jobs_for_one_name_have_one_complete_winner", | |
| 18 | 추가: "control::cancel_decode_after_inflate", | |
| 19 | 추가: "control::cancel_decode_after_output", | |
| 20 | 추가: "control::cancel_decode_before_inflate", | |
| 21 | 추가: "control::cancel_decode_before_return", | |
| 22 | 추가: "control::cancel_decode_header", | |
| 23 | 추가: "control::cancel_decode_start", | |
| 24 | 추가: "control::cancel_decode_trailer", | |
| 25 | 추가: "control::cancel_publication_before_commit", | |
| 26 | 추가: "control::cancel_publication_opening", | |
| 27 | 추가: "control::cancel_publication_verifying", | |
| 28 | 추가: "control::cancel_publication_writing", | |
| 29 | 추가: "control::cancel_snapshot_comparing", | |
| 30 | 추가: "control::cancel_snapshot_copying", | |
| 31 | 추가: "control::cancel_snapshot_finalizing", | |
| 32 | 추가: "control::cancel_snapshot_opening", | |
| 33 | 추가: "control::cancel_snapshot_pinned", | |
| 34 | 추가: "control::cancellation_after_return_preserves_committed_bytes", | |
| 35 | 추가: "control::decode_observer_error_beats_accepted_cancel", | |
| 36 | 추가: "control::dropping_unused_job_finishes_its_gate", | |
| 37 | 추가: "control::local_decode_stop_does_not_need_cancel_request", | |
| 38 | 추가: "control::local_publication_stop_does_not_need_cancel_request", | |
| 39 | 추가: "control::local_snapshot_stop_does_not_need_cancel_request", | |
| 40 | 추가: "control::pre_cancel_stops_before_snapshot_open", | |
| 41 | 추가: "control::publication_observer_error_beats_accepted_cancel", | |
| 42 | 추가: "control::snapshot_observer_error_beats_accepted_cancel", | |
| 43 | 추가: "invalid::bad_crc_prevents_publication", | |
| 44 | 추가: "invalid::bad_size_prevents_publication", | |
| 45 | 추가: "invalid::concatenated_members_prevent_publication", | |
| 46 | 추가: "invalid::invalid_deflate_preserves_backend_error", | |
| 47 | 추가: "invalid::invalid_magic_prevents_publication", | |
| 48 | 추가: "invalid::trailing_byte_prevents_publication", | |
| 49 | 추가: "invalid::truncated_trailer_prevents_publication", | |
| 50 | 추가: "limits::exact_limits_in_all_stages_allow_commit", | |
| 51 | 추가: "limits::gzip_input_limit_stops_after_snapshot", | |
| 52 | 추가: "limits::gzip_metadata_limit_preserves_header_cost", | |
| 53 | 추가: "limits::gzip_processed_failure_includes_post_checkpoint_charge", | |
| 54 | 추가: "limits::gzip_selected_output_limit_preserves_consumed_cost", | |
| 55 | 추가: "limits::invalid_decode_duration_retains_snapshot_cost", | |
| 56 | 추가: "limits::invalid_publication_duration_retains_both_prior_costs", | |
| 57 | 추가: "limits::invalid_snapshot_duration_has_zero_cost", | |
| 58 | 추가: "limits::publication_byte_limit_preserves_completed_prior_stages", | |
| 59 | 추가: "limits::publication_call_limit_retains_pre_eof_usage", | |
| 60 | 추가: "limits::publication_io_limit_retains_pre_eof_usage", | |
| 61 | 추가: "limits::snapshot_byte_limit_preserves_partial_usage", | |
| 62 | 추가: "limits::snapshot_call_limit_retains_last_eof_reservation_boundary", | |
| 63 | 추가: "limits::snapshot_io_limit_retains_last_eof_reservation_boundary", | |
| 64 | 추가: "namespace::existing_directory_and_child_survive_conflict", | |
| 65 | 추가: "namespace::existing_file_bytes_and_identity_survive_conflict", | |
| 66 | 추가: "namespace::existing_symlink_and_target_survive_conflict", | |
| 67 | 추가: "namespace::identical_input_and_output_name_preserves_archive", | |
| 68 | 추가: "namespace::missing_owned_input_preserves_native_open_error", | |
| 69 | 추가: "namespace::replaced_parent_path_does_not_redirect_pinned_commit", | |
| 70 | 추가: "success::chunk_minus_one_output", | |
| 71 | 추가: "success::chunk_output", | |
| 72 | 추가: "success::chunk_plus_one_output", | |
| 73 | 추가: "success::empty_output", | |
| 74 | 추가: "success::header_name_and_comment_never_select_destination", | |
| 75 | 추가: "success::known_bytes_output", | |
| 76 | 추가: "success::one_byte_output", | |
| 77 | 추가: "success::replacing_input_after_snapshot_uses_captured_owned_bytes" | |
| 78 | 추가: ], | |
| 79 | 추가: "count": 62, | |
| 80 | 추가: "filtered_per_case": 61 | |
| 81 | 추가: }, | |
| 82 | 추가: "commands": [ | |
| 83 | 추가: "python3 -B tests/rust-gzip-file-job/static_check.py --manifest-sha256 <fixed>", | |
| 84 | 추가: "cargo test --manifest-path tests/rust-gzip-file-job/Cargo.toml --locked --offline --test file_job_public_api --no-run --message-format=json", | |
| 85 | 추가: "<unique-binary> --list --format terse", | |
| 86 | 추가: "<unique-binary> --exact <name> --test-threads=1 --nocapture" | |
| 87 | 추가: ], | |
| 88 | 추가: "bounds": { | |
| 89 | 추가: "compile_seconds": 120, | |
| 90 | 추가: "discovery_seconds": 30, | |
| 91 | 추가: "per_case_seconds": 30, | |
| 92 | 추가: "per_command_log_bytes": 8388608, | |
| 93 | 추가: "channel_wait_seconds": 5, | |
| 94 | 추가: "termination_grace_seconds": 2, | |
| 95 | 추가: "reap_grace_seconds": 5, | |
| 96 | 추가: "cleanup_observation_seconds": 10, | |
| 97 | 추가: "parallel_cases": 1, | |
| 98 | 추가: "max_payload_bytes": 65537, | |
| 99 | 추가: "max_archive_bytes": 65599 | |
| 100 | 추가: }, | |
| 101 | 추가: "order": "Static then compile once, unique artifact and complete exact discovery set, each sorted case exactly once. Require1passed/0failed/0ignored/0measured and61filtered. First failure/timeout/missing/duplicate/changed input stops without retry.", | |
| 102 | 추가: "parser": "Handle --nocapture prefix/intermediate output/ok separation; exact unique name and summary plus exit0/reaped/EOF required. Reject malformed/missing/duplicate names or summaries and failed/timeout/capped command. Pre-selftest the runner parser, reusing verified PR54 parser logic only with source/hash record.", | |
| 103 | 추가: "supervision": "Stream bounded raw logs, signal only owned process group after timeout/log overflow, TERM grace2s then KILL and reap5s. Channel receives5s; join occurs after done and whole process remains bounded by30s. Never claim hard interrupt of uninterruptible I/O.", | |
| 104 | 추가: "cleanup": "Rust assertions/joins finish before Sandbox.finish; no implicit Drop deletion. Preserve failures and their residual case roots. After each passing process require runs empty and owned children/threads ended. Keep logs and binaries. Remove only newly owned empty runs after final identity check; no recursive cleanup of failures.", | |
| 105 | 추가: "evidence": "Record source/test hashes before/after, exact names/filtered values, raw stdout/stderr/argv/env, binary SHA256, process exit/reap/EOF, output stage/Usage/cleanup assertions and owned residuals. Preserve original PR48/51/54 reports. Separate real FileJob results from callback scheduling and gate lifecycle.", | |
| 106 | 추가: "forbidden": [ | |
| 107 | 추가: "Production changes", | |
| 108 | 추가: "Public receipt constructors", | |
| 109 | 추가: "Retries or weakening expectations", | |
| 110 | 추가: "User archives or paths", | |
| 111 | 추가: "GUI/VM/OS worker/execveat", | |
| 112 | 추가: "Windows cfg simulation", | |
| 113 | 추가: "System permission/mount changes", | |
| 114 | 추가: "Network/install/download", | |
| 115 | 추가: "Main merge or product release" | |
| 116 | 추가: ] | |
| 117 | 추가: } |
| @@ -0,0 +1,240 @@ | ||
| 1 | 추가: { | |
| 2 | 추가: "head": "4c6ae4b3a7ab12a992598e94e7b02f3a167fbbd4", | |
| 3 | 추가: "tree": "9a01a37623b163c35ca4ff25963b2e11c61a0c35", | |
| 4 | 추가: "files": [ | |
| 5 | 추가: { | |
| 6 | 추가: "path": "experiments/rust-file-publication/Cargo.lock", | |
| 7 | 추가: "git_blob": "207c18a163029bf5059414e443d47340f701973e", | |
| 8 | 추가: "mode": "100644", | |
| 9 | 추가: "sha256": "b38bcde0e0c7286f53254ecbc357a55a0b18e803fd7294dec1025fcb34eb6092" | |
| 10 | 추가: }, | |
| 11 | 추가: { | |
| 12 | 추가: "path": "experiments/rust-file-publication/Cargo.toml", | |
| 13 | 추가: "git_blob": "769cad258dde0179ea8e32bd3d13a7579a791497", | |
| 14 | 추가: "mode": "100644", | |
| 15 | 추가: "sha256": "e6d911fb2c215dcab367116b0eac2544a3e37abe0d69ba6f0323c0d0308b329d" | |
| 16 | 추가: }, | |
| 17 | 추가: { | |
| 18 | 추가: "path": "experiments/rust-file-publication/LICENSE", | |
| 19 | 추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc", | |
| 20 | 추가: "mode": "100644", | |
| 21 | 추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62" | |
| 22 | 추가: }, | |
| 23 | 추가: { | |
| 24 | 추가: "path": "experiments/rust-file-publication/SHA256SUMS", | |
| 25 | 추가: "git_blob": "b77cca2d6328d6c4512e3c62a65ca0b032937836", | |
| 26 | 추가: "mode": "100644", | |
| 27 | 추가: "sha256": "cc4e4cc64a8f3b537df554c7d2895ea3722fbfb0906f1ada767d5cf9b5d8bbc6" | |
| 28 | 추가: }, | |
| 29 | 추가: { | |
| 30 | 추가: "path": "experiments/rust-file-publication/THIRD-PARTY-NOTICES.txt", | |
| 31 | 추가: "git_blob": "fba3cf10cd0ff76bb025c1ff9cee6f17b4844197", | |
| 32 | 추가: "mode": "100644", | |
| 33 | 추가: "sha256": "83bd16a9177040f87f726c5ff9c0e14e7e3fc0096c743abe0d7b1b97ab1fc425" | |
| 34 | 추가: }, | |
| 35 | 추가: { | |
| 36 | 추가: "path": "experiments/rust-file-publication/contract.json", | |
| 37 | 추가: "git_blob": "e348369c0f9f0f0bb5bab9b26b4ed4659aac134b", | |
| 38 | 추가: "mode": "100644", | |
| 39 | 추가: "sha256": "fc091b378311e5a5898f770b4a91317ada5d2daebbb3cfb795e1026736334161" | |
| 40 | 추가: }, | |
| 41 | 추가: { | |
| 42 | 추가: "path": "experiments/rust-file-publication/dependencies.json", | |
| 43 | 추가: "git_blob": "85b978be36080547024565031bc6a433e6a4b321", | |
| 44 | 추가: "mode": "100644", | |
| 45 | 추가: "sha256": "75757b6b770ea09d7b345ca3beaf3d75fdbbe7c792d00d3aec7465b9968ce4f5" | |
| 46 | 추가: }, | |
| 47 | 추가: { | |
| 48 | 추가: "path": "experiments/rust-file-publication/src/lib.rs", | |
| 49 | 추가: "git_blob": "19dcc817be97c8cbb18cb863b98ce6524e164406", | |
| 50 | 추가: "mode": "100644", | |
| 51 | 추가: "sha256": "8304a9c37e8d0a2e21f6657483c58d28c23ba4a4c2ed9ae7e43d389d0f3c2bc3" | |
| 52 | 추가: }, | |
| 53 | 추가: { | |
| 54 | 추가: "path": "experiments/rust-file-publication/src/linux.rs", | |
| 55 | 추가: "git_blob": "75a7194329af66458195b08e64d3e96a08495110", | |
| 56 | 추가: "mode": "100644", | |
| 57 | 추가: "sha256": "75225159189cb2418b24c5e35c4db804dfe2f0171bf957f59578ae284f046d0c" | |
| 58 | 추가: }, | |
| 59 | 추가: { | |
| 60 | 추가: "path": "experiments/rust-file-publication/static-validation.json", | |
| 61 | 추가: "git_blob": "7ac04313d01dd90ac905275c2e08cd2991789656", | |
| 62 | 추가: "mode": "100644", | |
| 63 | 추가: "sha256": "75ed00e7059990abe5c3ba7bc0aae87801e3ffa915824c900d09ed31a61f8159" | |
| 64 | 추가: }, | |
| 65 | 추가: { | |
| 66 | 추가: "path": "experiments/rust-file-snapshot/Cargo.lock", | |
| 67 | 추가: "git_blob": "f78b06aafe24e649c3b8dbf1e80f84875665916d", | |
| 68 | 추가: "mode": "100644", | |
| 69 | 추가: "sha256": "ba55ac17dc748d1f91d7a6e5d5ebb4c6b9c84d09173a17d4cac31cf149fb771b" | |
| 70 | 추가: }, | |
| 71 | 추가: { | |
| 72 | 추가: "path": "experiments/rust-file-snapshot/Cargo.toml", | |
| 73 | 추가: "git_blob": "5f13cef3e22861c18da16a0aa45ed990a448d1bf", | |
| 74 | 추가: "mode": "100644", | |
| 75 | 추가: "sha256": "e641f091c0acabd3e6fbfa3ed6bf53e05be3ca6c2fc90d67980721b378840f0f" | |
| 76 | 추가: }, | |
| 77 | 추가: { | |
| 78 | 추가: "path": "experiments/rust-file-snapshot/LICENSE", | |
| 79 | 추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc", | |
| 80 | 추가: "mode": "100644", | |
| 81 | 추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62" | |
| 82 | 추가: }, | |
| 83 | 추가: { | |
| 84 | 추가: "path": "experiments/rust-file-snapshot/SHA256SUMS", | |
| 85 | 추가: "git_blob": "76201cbad9d40111091cb320744f59bb07b4bc65", | |
| 86 | 추가: "mode": "100644", | |
| 87 | 추가: "sha256": "668b1c3f140a033a6a0768b84ec52f111ee5fbfaf707632d2fc9a5a380758120" | |
| 88 | 추가: }, | |
| 89 | 추가: { | |
| 90 | 추가: "path": "experiments/rust-file-snapshot/THIRD-PARTY-NOTICES.txt", | |
| 91 | 추가: "git_blob": "c18cb9011479d97d247bf403c128e5923fa769c9", | |
| 92 | 추가: "mode": "100644", | |
| 93 | 추가: "sha256": "066b8c0623b870c0c3998a0499b0323f3cfe8d3cfd60bf6bbc833be0e523a06e" | |
| 94 | 추가: }, | |
| 95 | 추가: { | |
| 96 | 추가: "path": "experiments/rust-file-snapshot/contract.json", | |
| 97 | 추가: "git_blob": "93c7b53f2441eee3d98db58dcca8ece47b1094d6", | |
| 98 | 추가: "mode": "100644", | |
| 99 | 추가: "sha256": "8b54705382c3af1168b684fbcf3e25efd256eb145c636972fe6e26b8cb898ff2" | |
| 100 | 추가: }, | |
| 101 | 추가: { | |
| 102 | 추가: "path": "experiments/rust-file-snapshot/dependencies.json", | |
| 103 | 추가: "git_blob": "cf8c2f473069573ba29b9cf278d7a09eac83adca", | |
| 104 | 추가: "mode": "100644", | |
| 105 | 추가: "sha256": "ea113f15ec27f9903eed985e1e55f49114b9867b0c7c707e2cd15009fa02c6c0" | |
| 106 | 추가: }, | |
| 107 | 추가: { | |
| 108 | 추가: "path": "experiments/rust-file-snapshot/src/lib.rs", | |
| 109 | 추가: "git_blob": "b119facbf8cef61cb1877b7cef9f921f4d63d311", | |
| 110 | 추가: "mode": "100644", | |
| 111 | 추가: "sha256": "e087714fc3e30b8efdd1cf16e1d8944ebc3518c757b8917d6e32d3b3dc3936c9" | |
| 112 | 추가: }, | |
| 113 | 추가: { | |
| 114 | 추가: "path": "experiments/rust-file-snapshot/src/linux.rs", | |
| 115 | 추가: "git_blob": "ed9af89904de5a4b44673b098e944b35faa3075f", | |
| 116 | 추가: "mode": "100644", | |
| 117 | 추가: "sha256": "88aa71907bfd07ef61697eb2c71e8ffbdc178c68ea9fcae8d26957be4751fa21" | |
| 118 | 추가: }, | |
| 119 | 추가: { | |
| 120 | 추가: "path": "experiments/rust-gzip-file-job/Cargo.lock", | |
| 121 | 추가: "git_blob": "ac727b854d6d077e6e82cd6f2a6ec8687fb90a0a", | |
| 122 | 추가: "mode": "100644", | |
| 123 | 추가: "sha256": "a7c66f4a02cbae817a7147ce4c08d0b9a53e0e94b38fc6e66352bbd9b7709629" | |
| 124 | 추가: }, | |
| 125 | 추가: { | |
| 126 | 추가: "path": "experiments/rust-gzip-file-job/Cargo.toml", | |
| 127 | 추가: "git_blob": "e8b16d664942b3f6782e0daa27d3965eabfa7716", | |
| 128 | 추가: "mode": "100644", | |
| 129 | 추가: "sha256": "0a994efa506a648fdad3615a944f1d78c83ef2f5a23a6b2420e5e9dfaeb5e65c" | |
| 130 | 추가: }, | |
| 131 | 추가: { | |
| 132 | 추가: "path": "experiments/rust-gzip-file-job/LICENSE", | |
| 133 | 추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc", | |
| 134 | 추가: "mode": "100644", | |
| 135 | 추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62" | |
| 136 | 추가: }, | |
| 137 | 추가: { | |
| 138 | 추가: "path": "experiments/rust-gzip-file-job/SHA256SUMS", | |
| 139 | 추가: "git_blob": "c7ac5be9104abbe123d3cd66762a3f046dade0f0", | |
| 140 | 추가: "mode": "100644", | |
| 141 | 추가: "sha256": "ef32ad5306d2d98751836846f631f66c562e4b55caf5d3422e120305aa78b37f" | |
| 142 | 추가: }, | |
| 143 | 추가: { | |
| 144 | 추가: "path": "experiments/rust-gzip-file-job/THIRD-PARTY-NOTICES.txt", | |
| 145 | 추가: "git_blob": "93ab1f0bd590597015c867ce9ee7dee5a01b1a1d", | |
| 146 | 추가: "mode": "100644", | |
| 147 | 추가: "sha256": "3e2e572d0aa960ae002b6cdf3fb68008323d1e50b014d6ae2d3adf1845e7a3c3" | |
| 148 | 추가: }, | |
| 149 | 추가: { | |
| 150 | 추가: "path": "experiments/rust-gzip-file-job/contract.json", | |
| 151 | 추가: "git_blob": "f1f7ec8d84b644486d46e084dd64509f7e1925ce", | |
| 152 | 추가: "mode": "100644", | |
| 153 | 추가: "sha256": "2b617a3792b520c421d4ac8f6dd8e95de7425303a3d8b134200419a8de07ba45" | |
| 154 | 추가: }, | |
| 155 | 추가: { | |
| 156 | 추가: "path": "experiments/rust-gzip-file-job/dependencies.json", | |
| 157 | 추가: "git_blob": "552885ea312260dc2e289366f14407c605e3c8d9", | |
| 158 | 추가: "mode": "100644", | |
| 159 | 추가: "sha256": "52cfbf2e1363b604dc52b1a343b8f76589e920b71f1ac7564a7e413a0d3fe40d" | |
| 160 | 추가: }, | |
| 161 | 추가: { | |
| 162 | 추가: "path": "experiments/rust-gzip-file-job/source-pins.json", | |
| 163 | 추가: "git_blob": "a080b5d20ca65f1f8d14d6321faa626fe8ac5217", | |
| 164 | 추가: "mode": "100644", | |
| 165 | 추가: "sha256": "01d5b0afef63b979c04fdcc6e7077915f00982dbfc44e3cbc84899c619c5c7d9" | |
| 166 | 추가: }, | |
| 167 | 추가: { | |
| 168 | 추가: "path": "experiments/rust-gzip-file-job/src/lib.rs", | |
| 169 | 추가: "git_blob": "e7f1ee35efb71a1022c52a2e2e44b35780ae98e4", | |
| 170 | 추가: "mode": "100644", | |
| 171 | 추가: "sha256": "dad3309af8706359c1c34e6e1f56d5eb5f4ddf7f101d81f4621bbf9772592b45" | |
| 172 | 추가: }, | |
| 173 | 추가: { | |
| 174 | 추가: "path": "experiments/rust-gzip-file-job/src/types.rs", | |
| 175 | 추가: "git_blob": "58f1966f7b9b20a15a27cdc11ac217fbfd1ab9e5", | |
| 176 | 추가: "mode": "100644", | |
| 177 | 추가: "sha256": "07f98df13fe48edeef5a23905a2cb9c1d257066e97c7d413cd06a754d44b7b4b" | |
| 178 | 추가: }, | |
| 179 | 추가: { | |
| 180 | 추가: "path": "experiments/rust-gzip-file-job/static-validation.json", | |
| 181 | 추가: "git_blob": "8ba55e6b262a3fb2677bac8a022e3583f08b914f", | |
| 182 | 추가: "mode": "100644", | |
| 183 | 추가: "sha256": "274a8fb2ea9991633856fdda6802044e409bffe325af09372fa18e85e684b10c" | |
| 184 | 추가: }, | |
| 185 | 추가: { | |
| 186 | 추가: "path": "experiments/rust-memory-gzip-reader/Cargo.lock", | |
| 187 | 추가: "git_blob": "a638f9b00ea1d76a99ccd93ea465ef9df4163c7a", | |
| 188 | 추가: "mode": "100644", | |
| 189 | 추가: "sha256": "511197f27b89d37c86f82ae1e8dda4229a3e5082ede9274efe8480df6e650d24" | |
| 190 | 추가: }, | |
| 191 | 추가: { | |
| 192 | 추가: "path": "experiments/rust-memory-gzip-reader/Cargo.toml", | |
| 193 | 추가: "git_blob": "1b1b77e23d39cde1f05e55f73b62f68cf77dd9c6", | |
| 194 | 추가: "mode": "100644", | |
| 195 | 추가: "sha256": "ae76aededbb85cdd6c9227b4c06a1c8fef1bb7f203f1703e787b68f30ccfab6a" | |
| 196 | 추가: }, | |
| 197 | 추가: { | |
| 198 | 추가: "path": "experiments/rust-memory-gzip-reader/LICENSE", | |
| 199 | 추가: "git_blob": "5014abac33298592fd3450b51a9b414191e1aabc", | |
| 200 | 추가: "mode": "100644", | |
| 201 | 추가: "sha256": "0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62" | |
| 202 | 추가: }, | |
| 203 | 추가: { | |
| 204 | 추가: "path": "experiments/rust-memory-gzip-reader/SHA256SUMS", | |
| 205 | 추가: "git_blob": "e248c4827c2fb2e82a5e92f80deb0d744209c65c", | |
| 206 | 추가: "mode": "100644", | |
| 207 | 추가: "sha256": "13e41e7d8ce2442cd8d93b1229211a5257e0568acc3466d5f9ec37f03c72a736" | |
| 208 | 추가: }, | |
| 209 | 추가: { | |
| 210 | 추가: "path": "experiments/rust-memory-gzip-reader/THIRD-PARTY-NOTICES.txt", | |
| 211 | 추가: "git_blob": "f56aa8d736e78465701ac62fa5ad26d4d7dc05c9", | |
| 212 | 추가: "mode": "100644", | |
| 213 | 추가: "sha256": "655ad3bee8c41a593c2b00cbb0a12be11e7246c41dda00319c223dd3f904910e" | |
| 214 | 추가: }, | |
| 215 | 추가: { | |
| 216 | 추가: "path": "experiments/rust-memory-gzip-reader/contract.json", | |
| 217 | 추가: "git_blob": "02729ca349d5629b1a9fcd7040441db2e2660065", | |
| 218 | 추가: "mode": "100644", | |
| 219 | 추가: "sha256": "1346c0b6f0ce5221acb9aef5067b0169e08ea6752f4db41a8b9c36b10ef9b43b" | |
| 220 | 추가: }, | |
| 221 | 추가: { | |
| 222 | 추가: "path": "experiments/rust-memory-gzip-reader/dependencies.json", | |
| 223 | 추가: "git_blob": "bf9da9b737d9d574d5e31fb8343f844b61e4c192", | |
| 224 | 추가: "mode": "100644", | |
| 225 | 추가: "sha256": "3f71220451f8cd55dafdb6e6ae901572ec7bbe1be9c93d78953b44244aec6b07" | |
| 226 | 추가: }, | |
| 227 | 추가: { | |
| 228 | 추가: "path": "experiments/rust-memory-gzip-reader/src/budget.rs", | |
| 229 | 추가: "git_blob": "0fa6fd1cdb541896540b7003168e5db71c11cb4b", | |
| 230 | 추가: "mode": "100644", | |
| 231 | 추가: "sha256": "b0d0b891a048712baba2038b8439d809a0359638f390b806f88496733753d61c" | |
| 232 | 추가: }, | |
| 233 | 추가: { | |
| 234 | 추가: "path": "experiments/rust-memory-gzip-reader/src/lib.rs", | |
| 235 | 추가: "git_blob": "1811dfc7ec0917da607727e7942b5a268ac7330a", | |
| 236 | 추가: "mode": "100644", | |
| 237 | 추가: "sha256": "a865a114fdb9d79b66226387b9f0e3fa601aad29cfe65ab443c946d6cbd74062" | |
| 238 | 추가: } | |
| 239 | 추가: ] | |
| 240 | 추가: } |
| @@ -0,0 +1,157 @@ | ||
| 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-gzip-file-job" | |
| 13 | 추가: HEAD = "4c6ae4b3a7ab12a992598e94e7b02f3a167fbbd4" | |
| 14 | 추가: TREE = "9a01a37623b163c35ca4ff25963b2e11c61a0c35" | |
| 15 | 추가: SOURCE_MANIFEST = "ef32ad5306d2d98751836846f631f66c562e4b55caf5d3422e120305aa78b37f" | |
| 16 | 추가: MODULES = ("success", "invalid", "limits", "control", "namespace", "concurrency") | |
| 17 | 추가: FILES = { | |
| 18 | 추가: "Cargo.toml", "Cargo.lock", "main.rs", "support.rs", "fixtures.rs", | |
| 19 | 추가: "success.rs", "invalid.rs", "limits.rs", "control.rs", "namespace.rs", "concurrency.rs", | |
| 20 | 추가: "source-pins.json", "contract.json", "run-plan.json", "static_check.py", | |
| 21 | 추가: "static_check_helper_tests.py", | |
| 22 | 추가: } | |
| 23 | 추가: GUARD = "최적화 모드에서는 정적 검사를 실행할 수 없음" | |
| 24 | 추가: | |
| 25 | 추가: | |
| 26 | 추가: def require(condition, message): | |
| 27 | 추가: if not condition: | |
| 28 | 추가: raise RuntimeError(message) | |
| 29 | 추가: | |
| 30 | 추가: | |
| 31 | 추가: def digest(raw): | |
| 32 | 추가: return hashlib.sha256(raw).hexdigest() | |
| 33 | 추가: | |
| 34 | 추가: | |
| 35 | 추가: def parse_manifest(text, expected_paths): | |
| 36 | 추가: rows = {} | |
| 37 | 추가: for line in text.splitlines(): | |
| 38 | 추가: match = re.fullmatch(r"([0-9a-f]{64}) ([A-Za-z0-9_./-]+)", line) | |
| 39 | 추가: require(match is not None, "잘못된 manifest 행") | |
| 40 | 추가: value, name = match.groups() | |
| 41 | 추가: path = pathlib.PurePosixPath(name) | |
| 42 | 추가: require(not path.is_absolute() and ".." not in path.parts | |
| 43 | 추가: and str(path) == name and name not in rows, "중복 또는 잘못된 경로") | |
| 44 | 추가: rows[name] = value | |
| 45 | 추가: require(set(rows) == set(expected_paths), "manifest 경로 불일치") | |
| 46 | 추가: return rows | |
| 47 | 추가: | |
| 48 | 추가: | |
| 49 | 추가: def hashes(): | |
| 50 | 추가: result = {} | |
| 51 | 추가: for name in sorted(FILES | {"SHA256SUMS"}): | |
| 52 | 추가: path = BASE / name | |
| 53 | 추가: require(path.resolve() == path and stat.S_ISREG(path.lstat().st_mode), "일반 시험 파일 필요") | |
| 54 | 추가: require(not path.stat().st_mode & 0o111, "시험 파일 mode 불일치") | |
| 55 | 추가: result[name] = digest(path.read_bytes()) | |
| 56 | 추가: return result | |
| 57 | 추가: | |
| 58 | 추가: | |
| 59 | 추가: def verify_sources(): | |
| 60 | 추가: pins = json.loads((BASE / "source-pins.json").read_text()) | |
| 61 | 추가: require(pins["head"] == HEAD and pins["tree"] == TREE and len(pins["files"]) == 39, "고정 source 기준 불일치") | |
| 62 | 추가: require(len({row["path"] for row in pins["files"]}) == 39, "source 경로 중복") | |
| 63 | 추가: roots = ("experiments/rust-gzip-file-job/", "experiments/rust-file-snapshot/", | |
| 64 | 추가: "experiments/rust-file-publication/", "experiments/rust-memory-gzip-reader/") | |
| 65 | 추가: result = {} | |
| 66 | 추가: for row in pins["files"]: | |
| 67 | 추가: path = ROOT / row["path"] | |
| 68 | 추가: require(row["path"].startswith(roots) and path.resolve() == path, "source 경로 이탈") | |
| 69 | 추가: info = path.lstat() | |
| 70 | 추가: require(stat.S_ISREG(info.st_mode) and not info.st_mode & 0o111, "source mode 불일치") | |
| 71 | 추가: raw = path.read_bytes() | |
| 72 | 추가: require(digest(raw) == row["sha256"], "source SHA256 불일치") | |
| 73 | 추가: blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() | |
| 74 | 추가: require(blob == row["git_blob"] and row["mode"] == "100644", "source blob 불일치") | |
| 75 | 추가: result[row["path"]] = digest(raw) | |
| 76 | 추가: require(digest((SOURCE / "SHA256SUMS").read_bytes()) == SOURCE_MANIFEST, "source manifest 불일치") | |
| 77 | 추가: return result | |
| 78 | 추가: | |
| 79 | 추가: | |
| 80 | 추가: def main(): | |
| 81 | 추가: if sys.flags.optimize: | |
| 82 | 추가: raise RuntimeError(GUARD) | |
| 83 | 추가: parser = argparse.ArgumentParser() | |
| 84 | 추가: parser.add_argument("--manifest-sha256", required=True) | |
| 85 | 추가: parser.add_argument("--metadata", type=pathlib.Path) | |
| 86 | 추가: args = parser.parse_args() | |
| 87 | 추가: before = hashes() | |
| 88 | 추가: require(before["SHA256SUMS"] == args.manifest_sha256, "시험 manifest 불일치") | |
| 89 | 추가: rows = parse_manifest((BASE / "SHA256SUMS").read_text(), FILES) | |
| 90 | 추가: require(all(before[name] == value for name, value in rows.items()), "시험 파일 변경") | |
| 91 | 추가: sources = verify_sources() | |
| 92 | 추가: contract = json.loads((BASE / "contract.json").read_text()) | |
| 93 | 추가: require(contract["source_head"] == HEAD and contract["source_tree"] == TREE, "계약 head 불일치") | |
| 94 | 추가: require(contract["source_manifest_sha256"] == SOURCE_MANIFEST, "계약 manifest 불일치") | |
| 95 | 추가: require(set(contract["deliverables"]) == FILES | {"SHA256SUMS"}, "배포 파일 집합 불일치") | |
| 96 | 추가: names = [] | |
| 97 | 추가: for module in MODULES: | |
| 98 | 추가: text = (BASE / (module + ".rs")).read_text() | |
| 99 | 추가: found = re.findall(r"#\[test\]\s*fn ([a-z0-9_]+)\(", text) | |
| 100 | 추가: require(len(found) == text.count("#[test]"), "시험 선언 분석 실패") | |
| 101 | 추가: names.extend(module + "::" + name for name in found) | |
| 102 | 추가: require(len(names) == len(set(names)) == contract["declared_test_count"] == 62, "선언 수 불일치") | |
| 103 | 추가: require(sorted(names) == contract["test_names"] == sorted(contract["evidence_classes"]), "이름 집합 불일치") | |
| 104 | 추가: for name in FILES: | |
| 105 | 추가: raw = (BASE / name).read_bytes() | |
| 106 | 추가: require(b"\xc2\xb7" not in raw, "가운뎃점 금지") | |
| 107 | 추가: for path in BASE.glob("*.rs"): | |
| 108 | 추가: text = path.read_text() | |
| 109 | 추가: require("#[ignore" not in text and "#[should_panic" not in text, "시험 제외 금지") | |
| 110 | 추가: require(not re.search(r"include!|#\[path|Command::|execveat|\bchmod\b|\bchown\b|\bmount\b", text), "범위 밖 Rust 경계") | |
| 111 | 추가: support = (BASE / "support.rs").read_text() | |
| 112 | 추가: require("impl Drop for Sandbox" not in support, "실패 증거 자동 정리 금지") | |
| 113 | 추가: require("owned_descriptors(&self.root).is_empty()" in support, "소유 fd 점검 누락") | |
| 114 | 추가: main = (BASE / "main.rs").read_text() | |
| 115 | 추가: require(main.startswith('#![cfg(target_os = "linux")]'), "native Linux 경계 누락") | |
| 116 | 추가: require(set(re.findall(r"mod ([a-z_]+);", main)) == set(MODULES) | {"support", "fixtures"}, "모듈 집합 불일치") | |
| 117 | 추가: plan = json.loads((BASE / "run-plan.json").read_text()) | |
| 118 | 추가: require(plan["target"]["exact_names"] == sorted(names) and plan["target"]["count"] == 62, "실행 계획 이름 불일치") | |
| 119 | 추가: require(plan["target"]["filtered_per_case"] == 61, "filtered 수 불일치") | |
| 120 | 추가: require(plan["bounds"]["per_case_seconds"] == 30 and plan["bounds"]["channel_wait_seconds"] == 5, "시간 상한 변경") | |
| 121 | 추가: require(plan["bounds"]["compile_seconds"] == 120 and plan["bounds"]["per_command_log_bytes"] == 8388608, "실행 상한 변경") | |
| 122 | 추가: manifest = tomllib.loads((BASE / "Cargo.toml").read_text()) | |
| 123 | 추가: require(manifest["package"]["autotests"] is False, "자동 시험 발견 금지") | |
| 124 | 추가: require(manifest["test"] == [{"name": "file_job_public_api", "path": "main.rs"}], "target 불일치") | |
| 125 | 추가: require(manifest["dependencies"] == { | |
| 126 | 추가: "job": {"package": "zipelo-gzip-file-job", "path": "../../experiments/rust-gzip-file-job"}, | |
| 127 | 추가: "libc": {"version": "=0.2.191", "default-features": False, "features": ["std"]}, | |
| 128 | 추가: "sha2": {"version": "=0.10.9", "default-features": False, "features": ["std", "force-soft"]}, | |
| 129 | 추가: }, "직접 의존성 변경") | |
| 130 | 추가: normal = lambda rows: sorted(rows, key=lambda row: (row["name"], row["version"])) | |
| 131 | 추가: original = tomllib.loads((SOURCE / "Cargo.lock").read_text())["package"] | |
| 132 | 추가: locked = tomllib.loads((BASE / "Cargo.lock").read_text())["package"] | |
| 133 | 추가: package = {"name": "zipelo-gzip-file-job-regressions", "version": "0.1.0", | |
| 134 | 추가: "dependencies": ["libc", "sha2", "zipelo-gzip-file-job"]} | |
| 135 | 추가: require(normal(locked) == normal(original + [package]), "기존 lock graph 변경") | |
| 136 | 추가: require(len([p for p in locked if "source" in p]) == 11, "registry 수 변경") | |
| 137 | 추가: if args.metadata: | |
| 138 | 추가: require(args.metadata.resolve().is_relative_to(BASE), "metadata 위치 이탈") | |
| 139 | 추가: metadata = json.loads(args.metadata.read_text()) | |
| 140 | 추가: packages = {p["id"]: p for p in metadata["packages"]} | |
| 141 | 추가: root = packages[metadata["resolve"]["root"]] | |
| 142 | 추가: require(root["name"] == package["name"], "metadata root 불일치") | |
| 143 | 추가: require(len(root["targets"]) == 1 and root["targets"][0]["kind"] == ["test"], "target 추가") | |
| 144 | 추가: require(pathlib.Path(root["targets"][0]["src_path"]) == BASE / "main.rs", "시험 경로 이탈") | |
| 145 | 추가: for node in metadata["resolve"]["nodes"]: | |
| 146 | 추가: name = packages[node["id"]]["name"] | |
| 147 | 추가: if name == "sha2": | |
| 148 | 추가: require(sorted(node["features"]) == ["force-soft", "std"], "sha2 feature 변경") | |
| 149 | 추가: if name == "libc": | |
| 150 | 추가: require(sorted(node["features"]) == ["std"], "libc feature 변경") | |
| 151 | 추가: require(verify_sources() == sources and hashes() == before, "검사 중 입력 변경") | |
| 152 | 추가: print(json.dumps({"head": HEAD, "source_files": 39, "declared": len(names), | |
| 153 | 추가: "rust_compiled": False, "rust_executed": 0, "inputs_unchanged": True})) | |
| 154 | 추가: | |
| 155 | 추가: | |
| 156 | 추가: if __name__ == "__main__": | |
| 157 | 추가: 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,105 @@ | ||
| 1 | 추가: use crate::{fixtures::*, support::*}; | |
| 2 | 추가: use job::{Event, FileJob, Limits, Stop, gzip, publication}; | |
| 3 | 추가: use std::fs; | |
| 4 | 추가: | |
| 5 | 추가: fn boundary(length: usize) { | |
| 6 | 추가: let sandbox = Sandbox::new(); | |
| 7 | 추가: let bytes = pattern(length); | |
| 8 | 추가: let archive = stored(&bytes); | |
| 9 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 10 | 추가: let before = identity(&input); | |
| 11 | 추가: let parent = sandbox.parent(); | |
| 12 | 추가: let (report, trace) = run(&input, &parent, Limits::default()); | |
| 13 | 추가: observations(&report, (before.0, before.1), &archive, &bytes, 10); | |
| 14 | 추가: committed(&report, &parent, &bytes); | |
| 15 | 추가: assert_eq!(identity(&input), before); | |
| 16 | 추가: assert_eq!(fs::read(&input).unwrap(), archive); | |
| 17 | 추가: assert!( | |
| 18 | 추가: matches!(trace.points.last().unwrap().event, Event::Publication(point) if point.stage == publication::Stage::BeforeCommit) | |
| 19 | 추가: ); | |
| 20 | 추가: assert!(owned_descriptors(&sandbox.root).is_empty()); | |
| 21 | 추가: sandbox.finish(); | |
| 22 | 추가: } | |
| 23 | 추가: | |
| 24 | 추가: #[test] | |
| 25 | 추가: fn empty_output() { | |
| 26 | 추가: boundary(0); | |
| 27 | 추가: } | |
| 28 | 추가: #[test] | |
| 29 | 추가: fn one_byte_output() { | |
| 30 | 추가: boundary(1); | |
| 31 | 추가: } | |
| 32 | 추가: #[test] | |
| 33 | 추가: fn known_bytes_output() { | |
| 34 | 추가: boundary(3); | |
| 35 | 추가: } | |
| 36 | 추가: #[test] | |
| 37 | 추가: fn chunk_minus_one_output() { | |
| 38 | 추가: boundary(65_535); | |
| 39 | 추가: } | |
| 40 | 추가: #[test] | |
| 41 | 추가: fn chunk_output() { | |
| 42 | 추가: boundary(65_536); | |
| 43 | 추가: } | |
| 44 | 추가: #[test] | |
| 45 | 추가: fn chunk_plus_one_output() { | |
| 46 | 추가: boundary(65_537); | |
| 47 | 추가: } | |
| 48 | 추가: | |
| 49 | 추가: #[test] | |
| 50 | 추가: fn header_name_and_comment_never_select_destination() { | |
| 51 | 추가: let sandbox = Sandbox::new(); | |
| 52 | 추가: let bytes = b"abc"; | |
| 53 | 추가: assert_eq!(crc32(b"123456789"), 0xcbf4_3926); | |
| 54 | 추가: let archive = named(bytes); | |
| 55 | 추가: let header = 10 + b"../header-name\0../comment-name\0".len(); | |
| 56 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 57 | 추가: let before = identity(&input); | |
| 58 | 추가: let parent = sandbox.parent(); | |
| 59 | 추가: let (report, _) = run(&input, &parent, Limits::default()); | |
| 60 | 추가: observations(&report, (before.0, before.1), &archive, bytes, header); | |
| 61 | 추가: committed(&report, &parent, bytes); | |
| 62 | 추가: assert_eq!( | |
| 63 | 추가: names(&sandbox.root), | |
| 64 | 추가: vec![ | |
| 65 | 추가: std::ffi::OsString::from("input.gz"), | |
| 66 | 추가: std::ffi::OsString::from("parent") | |
| 67 | 추가: ] | |
| 68 | 추가: ); | |
| 69 | 추가: assert_eq!(identity(&input), before); | |
| 70 | 추가: sandbox.finish(); | |
| 71 | 추가: } | |
| 72 | 추가: | |
| 73 | 추가: #[test] | |
| 74 | 추가: fn replacing_input_after_snapshot_uses_captured_owned_bytes() { | |
| 75 | 추가: let sandbox = Sandbox::new(); | |
| 76 | 추가: let archive = stored(b"original"); | |
| 77 | 추가: let replacement = stored(b"replacement"); | |
| 78 | 추가: let input = sandbox.file("input.gz", &archive); | |
| 79 | 추가: let before = identity(&input); | |
| 80 | 추가: let parent = sandbox.parent(); | |
| 81 | 추가: let (task, cancel) = FileJob::new(); | |
| 82 | 추가: let mut changed = false; | |
| 83 | 추가: let mut trace = Trace::default(); | |
| 84 | 추가: let report = task.run(request(&input, &parent, Limits::default()), |point| { | |
| 85 | 추가: trace.push(point); | |
| 86 | 추가: if matches!(point.event, Event::Decode(native) if native.stage == gzip::Stage::Start) { | |
| 87 | 추가: fs::rename(&input, sandbox.path("old.gz")).unwrap(); | |
| 88 | 추가: sandbox.file("input.gz", &replacement); | |
| 89 | 추가: changed = true; | |
| 90 | 추가: } | |
| 91 | 추가: Ok::<_, Stop<()>>(()) | |
| 92 | 추가: }); | |
| 93 | 추가: assert!(changed); | |
| 94 | 추가: trace.finish(&report); | |
| 95 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 96 | 추가: observations(&report, (before.0, before.1), &archive, b"original", 10); | |
| 97 | 추가: committed(&report, &parent, b"original"); | |
| 98 | 추가: assert_eq!(fs::read(&input).unwrap(), replacement); | |
| 99 | 추가: assert_eq!(fs::read(sandbox.path("old.gz")).unwrap(), archive); | |
| 100 | 추가: assert_ne!( | |
| 101 | 추가: (identity(&input).0, identity(&input).1), | |
| 102 | 추가: (before.0, before.1) | |
| 103 | 추가: ); | |
| 104 | 추가: sandbox.finish(); | |
| 105 | 추가: } |
| @@ -0,0 +1,380 @@ | ||
| 1 | 추가: use crate::fixtures::crc32; | |
| 2 | 추가: use job::{ | |
| 3 | 추가: Checkpoint, Event, FileJob, Limits, Outcome, Report, Request, Stop, Usage, gzip, publication, | |
| 4 | 추가: snapshot, | |
| 5 | 추가: }; | |
| 6 | 추가: use sha2::{Digest, Sha256}; | |
| 7 | 추가: use std::{ | |
| 8 | 추가: ffi::{OsStr, OsString}, | |
| 9 | 추가: fs::{self, DirBuilder, OpenOptions}, | |
| 10 | 추가: io::Write, | |
| 11 | 추가: os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt}, | |
| 12 | 추가: path::{Path, PathBuf}, | |
| 13 | 추가: sync::atomic::{AtomicU64, Ordering}, | |
| 14 | 추가: }; | |
| 15 | 추가: | |
| 16 | 추가: static NEXT: AtomicU64 = AtomicU64::new(1); | |
| 17 | 추가: | |
| 18 | 추가: pub struct Sandbox { | |
| 19 | 추가: pub root: PathBuf, | |
| 20 | 추가: identity: (u64, u64), | |
| 21 | 추가: } | |
| 22 | 추가: | |
| 23 | 추가: impl Sandbox { | |
| 24 | 추가: pub fn new() -> Self { | |
| 25 | 추가: let runs = Path::new(env!("CARGO_MANIFEST_DIR")).join("runs"); | |
| 26 | 추가: let info = fs::symlink_metadata(&runs).expect("runner가 전용 runs를 준비해야 함"); | |
| 27 | 추가: assert!(info.is_dir() && !info.file_type().is_symlink()); | |
| 28 | 추가: assert_eq!(info.mode() & 0o777, 0o700); | |
| 29 | 추가: assert_eq!(info.uid(), unsafe { libc::geteuid() }); | |
| 30 | 추가: assert_eq!(runs.canonicalize().unwrap(), runs); | |
| 31 | 추가: let root = runs.join(format!( | |
| 32 | 추가: "case-{}-{}", | |
| 33 | 추가: std::process::id(), | |
| 34 | 추가: NEXT.fetch_add(1, Ordering::Relaxed) | |
| 35 | 추가: )); | |
| 36 | 추가: DirBuilder::new().mode(0o700).create(&root).unwrap(); | |
| 37 | 추가: let info = fs::symlink_metadata(&root).unwrap(); | |
| 38 | 추가: let result = Self { | |
| 39 | 추가: root, | |
| 40 | 추가: identity: (info.dev(), info.ino()), | |
| 41 | 추가: }; | |
| 42 | 추가: result.dir("parent"); | |
| 43 | 추가: result | |
| 44 | 추가: } | |
| 45 | 추가: | |
| 46 | 추가: pub fn path(&self, name: impl AsRef<Path>) -> PathBuf { | |
| 47 | 추가: let name = name.as_ref(); | |
| 48 | 추가: assert!( | |
| 49 | 추가: name.components() | |
| 50 | 추가: .all(|part| matches!(part, std::path::Component::Normal(_))) | |
| 51 | 추가: ); | |
| 52 | 추가: self.root.join(name) | |
| 53 | 추가: } | |
| 54 | 추가: | |
| 55 | 추가: pub fn parent(&self) -> PathBuf { | |
| 56 | 추가: self.path("parent") | |
| 57 | 추가: } | |
| 58 | 추가: | |
| 59 | 추가: pub fn dir(&self, name: impl AsRef<Path>) -> PathBuf { | |
| 60 | 추가: let path = self.path(name); | |
| 61 | 추가: DirBuilder::new().mode(0o700).create(&path).unwrap(); | |
| 62 | 추가: path | |
| 63 | 추가: } | |
| 64 | 추가: | |
| 65 | 추가: pub fn file(&self, name: impl AsRef<Path>, bytes: &[u8]) -> PathBuf { | |
| 66 | 추가: let path = self.path(name); | |
| 67 | 추가: let mut handle = OpenOptions::new() | |
| 68 | 추가: .write(true) | |
| 69 | 추가: .create_new(true) | |
| 70 | 추가: .mode(0o600) | |
| 71 | 추가: .open(&path) | |
| 72 | 추가: .unwrap(); | |
| 73 | 추가: handle.write_all(bytes).unwrap(); | |
| 74 | 추가: handle.sync_all().unwrap(); | |
| 75 | 추가: path | |
| 76 | 추가: } | |
| 77 | 추가: | |
| 78 | 추가: pub fn finish(self) { | |
| 79 | 추가: assert!( | |
| 80 | 추가: owned_descriptors(&self.root).is_empty(), | |
| 81 | 추가: "소유 fd가 남아 있음" | |
| 82 | 추가: ); | |
| 83 | 추가: let info = fs::symlink_metadata(&self.root).unwrap(); | |
| 84 | 추가: assert!(info.is_dir() && !info.file_type().is_symlink()); | |
| 85 | 추가: assert_eq!((info.dev(), info.ino()), self.identity); | |
| 86 | 추가: fs::remove_dir_all(&self.root).unwrap(); | |
| 87 | 추가: assert!(!self.root.exists()); | |
| 88 | 추가: } | |
| 89 | 추가: } | |
| 90 | 추가: | |
| 91 | 추가: pub fn owned_descriptors(root: &Path) -> Vec<u32> { | |
| 92 | 추가: let mut result = Vec::new(); | |
| 93 | 추가: for item in fs::read_dir("/proc/self/fd").unwrap() { | |
| 94 | 추가: let item = item.unwrap(); | |
| 95 | 추가: if let Ok(target) = fs::read_link(item.path()) { | |
| 96 | 추가: if target.starts_with(root) { | |
| 97 | 추가: result.push(item.file_name().to_str().unwrap().parse().unwrap()); | |
| 98 | 추가: } | |
| 99 | 추가: } | |
| 100 | 추가: } | |
| 101 | 추가: result.sort(); | |
| 102 | 추가: result | |
| 103 | 추가: } | |
| 104 | 추가: | |
| 105 | 추가: pub fn names(parent: &Path) -> Vec<OsString> { | |
| 106 | 추가: let mut result: Vec<_> = fs::read_dir(parent) | |
| 107 | 추가: .unwrap() | |
| 108 | 추가: .map(|e| e.unwrap().file_name()) | |
| 109 | 추가: .collect(); | |
| 110 | 추가: result.sort(); | |
| 111 | 추가: result | |
| 112 | 추가: } | |
| 113 | 추가: | |
| 114 | 추가: pub fn identity(path: &Path) -> (u64, u64, u64, u32, i64, i64, i64, i64) { | |
| 115 | 추가: let m = fs::symlink_metadata(path).unwrap(); | |
| 116 | 추가: ( | |
| 117 | 추가: m.dev(), | |
| 118 | 추가: m.ino(), | |
| 119 | 추가: m.len(), | |
| 120 | 추가: m.mode(), | |
| 121 | 추가: m.mtime(), | |
| 122 | 추가: m.mtime_nsec(), | |
| 123 | 추가: m.ctime(), | |
| 124 | 추가: m.ctime_nsec(), | |
| 125 | 추가: ) | |
| 126 | 추가: } | |
| 127 | 추가: | |
| 128 | 추가: pub fn request<'a>(input: &'a Path, parent: &'a Path, limits: Limits) -> Request<'a> { | |
| 129 | 추가: Request { | |
| 130 | 추가: input, | |
| 131 | 추가: output_parent: parent, | |
| 132 | 추가: output_leaf: OsStr::new("output"), | |
| 133 | 추가: limits, | |
| 134 | 추가: } | |
| 135 | 추가: } | |
| 136 | 추가: | |
| 137 | 추가: #[derive(Default)] | |
| 138 | 추가: pub struct Trace { | |
| 139 | 추가: pub points: Vec<Checkpoint>, | |
| 140 | 추가: } | |
| 141 | 추가: | |
| 142 | 추가: fn counters(usage: Usage) -> [u64; 18] { | |
| 143 | 추가: let s = usage.snapshot; | |
| 144 | 추가: let g = usage.gzip; | |
| 145 | 추가: let p = usage.publication; | |
| 146 | 추가: [ | |
| 147 | 추가: s.open_calls, | |
| 148 | 추가: s.metadata_calls, | |
| 149 | 추가: s.read_calls, | |
| 150 | 추가: s.reserved_read_bytes, | |
| 151 | 추가: s.actual_read_bytes, | |
| 152 | 추가: s.compared_bytes, | |
| 153 | 추가: g.processed, | |
| 154 | 추가: g.output, | |
| 155 | 추가: g.metadata, | |
| 156 | 추가: p.open_calls, | |
| 157 | 추가: p.metadata_calls, | |
| 158 | 추가: p.sync_calls, | |
| 159 | 추가: p.link_calls, | |
| 160 | 추가: p.read_calls, | |
| 161 | 추가: p.write_calls, | |
| 162 | 추가: p.reserved_io_bytes, | |
| 163 | 추가: p.actual_read_bytes, | |
| 164 | 추가: p.actual_written_bytes, | |
| 165 | 추가: ] | |
| 166 | 추가: } | |
| 167 | 추가: | |
| 168 | 추가: pub fn phase(event: Event) -> u8 { | |
| 169 | 추가: match event { | |
| 170 | 추가: Event::Snapshot(_) => 0, | |
| 171 | 추가: Event::Decode(_) => 1, | |
| 172 | 추가: Event::Publication(_) => 2, | |
| 173 | 추가: } | |
| 174 | 추가: } | |
| 175 | 추가: | |
| 176 | 추가: impl Trace { | |
| 177 | 추가: pub fn push(&mut self, point: Checkpoint) { | |
| 178 | 추가: if let Some(before) = self.points.last() { | |
| 179 | 추가: assert!(phase(before.event) <= phase(point.event)); | |
| 180 | 추가: for (a, b) in counters(before.usage) | |
| 181 | 추가: .into_iter() | |
| 182 | 추가: .zip(counters(point.usage)) | |
| 183 | 추가: { | |
| 184 | 추가: assert!(a <= b); | |
| 185 | 추가: } | |
| 186 | 추가: } | |
| 187 | 추가: match point.event { | |
| 188 | 추가: Event::Snapshot(native) => { | |
| 189 | 추가: assert_eq!(point.usage.snapshot, native.usage); | |
| 190 | 추가: assert_eq!(point.usage.gzip, gzip::Usage::default()); | |
| 191 | 추가: assert_eq!(point.usage.publication, publication::Usage::default()); | |
| 192 | 추가: } | |
| 193 | 추가: Event::Decode(native) => { | |
| 194 | 추가: assert_eq!(point.usage.gzip, native.usage); | |
| 195 | 추가: assert_eq!(point.usage.publication, publication::Usage::default()); | |
| 196 | 추가: } | |
| 197 | 추가: Event::Publication(native) => { | |
| 198 | 추가: assert_eq!(point.usage.publication, native.usage); | |
| 199 | 추가: assert_eq!(native.usage.link_calls, 0); | |
| 200 | 추가: } | |
| 201 | 추가: } | |
| 202 | 추가: self.points.push(point); | |
| 203 | 추가: } | |
| 204 | 추가: | |
| 205 | 추가: pub fn finish<E>(&self, report: &Report<E>) { | |
| 206 | 추가: if let Some(last) = self.points.last() { | |
| 207 | 추가: for (a, b) in counters(last.usage).into_iter().zip(counters(report.usage)) { | |
| 208 | 추가: assert!(a <= b); | |
| 209 | 추가: } | |
| 210 | 추가: } | |
| 211 | 추가: match &report.outcome { | |
| 212 | 추가: Outcome::SnapshotFailed(failure) => { | |
| 213 | 추가: assert_eq!(report.usage.snapshot, failure.usage); | |
| 214 | 추가: assert_eq!(report.usage.gzip, gzip::Usage::default()); | |
| 215 | 추가: assert_eq!(report.usage.publication, publication::Usage::default()); | |
| 216 | 추가: assert!(report.snapshot.is_none() && report.decoded.is_none()); | |
| 217 | 추가: assert!(self.points.iter().all(|p| phase(p.event) == 0)); | |
| 218 | 추가: } | |
| 219 | 추가: Outcome::DecodeFailed(_) => { | |
| 220 | 추가: assert!(report.snapshot.is_some() && report.decoded.is_none()); | |
| 221 | 추가: assert_eq!(report.usage.publication, publication::Usage::default()); | |
| 222 | 추가: assert!(self.points.iter().all(|p| phase(p.event) <= 1)); | |
| 223 | 추가: } | |
| 224 | 추가: Outcome::Publication(native) => { | |
| 225 | 추가: assert!(report.snapshot.is_some() && report.decoded.is_some()); | |
| 226 | 추가: assert_eq!(report.usage.publication, native.usage); | |
| 227 | 추가: } | |
| 228 | 추가: Outcome::AdapterFailed(_) => panic!("정상 decoder에서 adapter 실패가 발생함"), | |
| 229 | 추가: } | |
| 230 | 추가: } | |
| 231 | 추가: } | |
| 232 | 추가: | |
| 233 | 추가: pub fn run(input: &Path, parent: &Path, limits: Limits) -> (Report<()>, Trace) { | |
| 234 | 추가: let (task, cancel) = FileJob::new(); | |
| 235 | 추가: let mut trace = Trace::default(); | |
| 236 | 추가: let report = task.run(request(input, parent, limits), |point| { | |
| 237 | 추가: trace.push(point); | |
| 238 | 추가: Ok::<_, Stop<()>>(()) | |
| 239 | 추가: }); | |
| 240 | 추가: trace.finish(&report); | |
| 241 | 추가: assert_eq!(cancel.request(), publication::CancelDecision::Finished); | |
| 242 | 추가: (report, trace) | |
| 243 | 추가: } | |
| 244 | 추가: | |
| 245 | 추가: pub fn snapshot_usage(usage: snapshot::Usage, length: usize) { | |
| 246 | 추가: assert_eq!( | |
| 247 | 추가: usage, | |
| 248 | 추가: snapshot::Usage { | |
| 249 | 추가: open_calls: 4, | |
| 250 | 추가: metadata_calls: 5, | |
| 251 | 추가: read_calls: 2 * (length as u64).div_ceil(65_536) + 2, | |
| 252 | 추가: reserved_read_bytes: 2 * length as u64 + 2, | |
| 253 | 추가: actual_read_bytes: 2 * length as u64, | |
| 254 | 추가: compared_bytes: length as u64, | |
| 255 | 추가: } | |
| 256 | 추가: ); | |
| 257 | 추가: } | |
| 258 | 추가: | |
| 259 | 추가: pub fn gzip_usage(usage: gzip::Usage, archive: &[u8], output: &[u8], header: usize) { | |
| 260 | 추가: assert_eq!( | |
| 261 | 추가: usage, | |
| 262 | 추가: gzip::Usage { | |
| 263 | 추가: processed: (archive.len() + output.len()) as u64, | |
| 264 | 추가: output: output.len() as u64, | |
| 265 | 추가: metadata: header as u64, | |
| 266 | 추가: } | |
| 267 | 추가: ); | |
| 268 | 추가: } | |
| 269 | 추가: | |
| 270 | 추가: pub fn cleanup(value: &publication::Cleanup, attempts: u8) { | |
| 271 | 추가: assert_eq!(value.attempted, attempts); | |
| 272 | 추가: assert!(value.all_close_calls_succeeded()); | |
| 273 | 추가: assert!(value.failures.iter().all(Option::is_none)); | |
| 274 | 추가: } | |
| 275 | 추가: | |
| 276 | 추가: pub fn publication_usage(usage: publication::Usage, length: usize, linked: bool) { | |
| 277 | 추가: let chunks = (length as u64).div_ceil(65_536); | |
| 278 | 추가: assert_eq!( | |
| 279 | 추가: usage, | |
| 280 | 추가: publication::Usage { | |
| 281 | 추가: open_calls: 4, | |
| 282 | 추가: metadata_calls: 5, | |
| 283 | 추가: sync_calls: if linked { 2 } else { 1 }, | |
| 284 | 추가: link_calls: 1, | |
| 285 | 추가: read_calls: chunks + 1, | |
| 286 | 추가: write_calls: chunks, | |
| 287 | 추가: reserved_io_bytes: 2 * length as u64 + 1, | |
| 288 | 추가: actual_read_bytes: length as u64, | |
| 289 | 추가: actual_written_bytes: length as u64, | |
| 290 | 추가: } | |
| 291 | 추가: ); | |
| 292 | 추가: } | |
| 293 | 추가: | |
| 294 | 추가: pub fn observations<E>( | |
| 295 | 추가: report: &Report<E>, | |
| 296 | 추가: source_id: (u64, u64), | |
| 297 | 추가: archive: &[u8], | |
| 298 | 추가: output: &[u8], | |
| 299 | 추가: header: usize, | |
| 300 | 추가: ) { | |
| 301 | 추가: let captured = report.snapshot.as_ref().expect("snapshot 관측값 누락"); | |
| 302 | 추가: assert_eq!( | |
| 303 | 추가: (captured.identity().device(), captured.identity().inode()), | |
| 304 | 추가: source_id | |
| 305 | 추가: ); | |
| 306 | 추가: assert_eq!(captured.identity().length(), archive.len() as u64); | |
| 307 | 추가: assert_eq!(captured.sha256(), <[u8; 32]>::from(Sha256::digest(archive))); | |
| 308 | 추가: let boundary = report | |
| 309 | 추가: .decoded | |
| 310 | 추가: .as_ref() | |
| 311 | 추가: .expect("decode 관측값 누락") | |
| 312 | 추가: .boundary(); | |
| 313 | 추가: assert_eq!(boundary.header_bytes, header); | |
| 314 | 추가: assert_eq!(boundary.member_bytes, archive.len()); | |
| 315 | 추가: assert_eq!(boundary.deflate_bytes as usize, archive.len() - header - 8); | |
| 316 | 추가: assert_eq!(boundary.inflated_bytes, output.len() as u64); | |
| 317 | 추가: assert_eq!(boundary.crc32, crc32(output)); | |
| 318 | 추가: snapshot_usage(report.usage.snapshot, archive.len()); | |
| 319 | 추가: gzip_usage(report.usage.gzip, archive, output, header); | |
| 320 | 추가: } | |
| 321 | 추가: | |
| 322 | 추가: pub fn committed<E>(report: &Report<E>, parent: &Path, output: &[u8]) { | |
| 323 | 추가: let native = match &report.outcome { | |
| 324 | 추가: Outcome::Publication(native) => native, | |
| 325 | 추가: _ => panic!("게시 보고서 누락"), | |
| 326 | 추가: }; | |
| 327 | 추가: assert_eq!(native.usage, report.usage.publication); | |
| 328 | 추가: publication_usage(native.usage, output.len(), true); | |
| 329 | 추가: cleanup(&native.cleanup, 4); | |
| 330 | 추가: let (receipt, durability) = match &native.outcome { | |
| 331 | 추가: publication::Outcome::Committed { | |
| 332 | 추가: receipt, | |
| 333 | 추가: durability, | |
| 334 | 추가: } => (receipt, durability), | |
| 335 | 추가: _ => panic!("확정된 게시가 아님"), | |
| 336 | 추가: }; | |
| 337 | 추가: assert!(matches!( | |
| 338 | 추가: durability, | |
| 339 | 추가: publication::Durability::FileAndParentSynced | |
| 340 | 추가: )); | |
| 341 | 추가: let m = fs::symlink_metadata(parent.join("output")).unwrap(); | |
| 342 | 추가: let p = fs::metadata(parent).unwrap(); | |
| 343 | 추가: assert!(m.is_file() && !m.file_type().is_symlink()); | |
| 344 | 추가: assert_eq!(m.nlink(), 1); | |
| 345 | 추가: assert_eq!(m.mode() & 0o777, 0o600); | |
| 346 | 추가: assert_eq!(receipt.length(), output.len() as u64); | |
| 347 | 추가: assert_eq!( | |
| 348 | 추가: ( | |
| 349 | 추가: receipt.parent_identity().device(), | |
| 350 | 추가: receipt.parent_identity().inode() | |
| 351 | 추가: ), | |
| 352 | 추가: (p.dev(), p.ino()) | |
| 353 | 추가: ); | |
| 354 | 추가: assert_eq!( | |
| 355 | 추가: ( | |
| 356 | 추가: receipt.file_identity().device(), | |
| 357 | 추가: receipt.file_identity().inode() | |
| 358 | 추가: ), | |
| 359 | 추가: (m.dev(), m.ino()) | |
| 360 | 추가: ); | |
| 361 | 추가: assert_eq!(fs::read(parent.join("output")).unwrap(), output); | |
| 362 | 추가: assert_eq!(names(parent), vec![OsString::from("output")]); | |
| 363 | 추가: } | |
| 364 | 추가: | |
| 365 | 추가: pub fn conflict<E>(report: &Report<E>, length: usize) { | |
| 366 | 추가: let native = match &report.outcome { | |
| 367 | 추가: Outcome::Publication(native) => native, | |
| 368 | 추가: _ => panic!("게시 보고서 누락"), | |
| 369 | 추가: }; | |
| 370 | 추가: match &native.outcome { | |
| 371 | 추가: publication::Outcome::NotCommitted(publication::Error::Io { operation, source }) => { | |
| 372 | 추가: assert_eq!(*operation, "linkat_conflict"); | |
| 373 | 추가: assert_eq!(source.raw_os_error(), Some(libc::EEXIST)); | |
| 374 | 추가: } | |
| 375 | 추가: _ => panic!("명확한 충돌 오류가 아님"), | |
| 376 | 추가: } | |
| 377 | 추가: assert_eq!(report.usage.publication, native.usage); | |
| 378 | 추가: publication_usage(native.usage, length, false); | |
| 379 | 추가: cleanup(&native.cleanup, 4); | |
| 380 | 추가: } |