From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E57F51FF178 for ; Mon, 1 Dec 2025 18:13:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D5B26228D8; Mon, 1 Dec 2025 18:13:25 +0100 (CET) From: Filip Schauer To: pve-devel@lists.proxmox.com Date: Mon, 1 Dec 2025 18:13:11 +0100 Message-ID: <20251201171317.149449-3-f.schauer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251201171317.149449-1-f.schauer@proxmox.com> References: <20251201171317.149449-1-f.schauer@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764609159096 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.132 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LOTSOFHASH 0.25 Emails with lots of hash-like gibberish RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH proxmox 2/2] oci: test replacing files in subsequent layers X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Add tests that verify later layer entries properly replace paths from earlier layers. Signed-off-by: Filip Schauer --- proxmox-oci/tests/extract_replace.rs | 57 ++++++++++++++++++ .../oci_test_replace_dir_with_file.tar | Bin 0 -> 8704 bytes .../oci_image_data/oci_test_replace_file.tar | Bin 0 -> 8704 bytes .../oci_test_replace_file_with_dir.tar | Bin 0 -> 8704 bytes 4 files changed, 57 insertions(+) create mode 100644 proxmox-oci/tests/extract_replace.rs create mode 100644 proxmox-oci/tests/oci_image_data/oci_test_replace_dir_with_file.tar create mode 100644 proxmox-oci/tests/oci_image_data/oci_test_replace_file.tar create mode 100644 proxmox-oci/tests/oci_image_data/oci_test_replace_file_with_dir.tar diff --git a/proxmox-oci/tests/extract_replace.rs b/proxmox-oci/tests/extract_replace.rs new file mode 100644 index 00000000..eb41f9e3 --- /dev/null +++ b/proxmox-oci/tests/extract_replace.rs @@ -0,0 +1,57 @@ +use std::fs::{read_to_string, remove_dir_all}; + +use proxmox_oci::{parse_and_extract_image, Arch}; +use proxmox_sys::fs::make_tmp_dir; + +#[test] +fn test_replace_file() { + let extract_dir = make_tmp_dir("/tmp/", None).unwrap(); + + parse_and_extract_image( + &"tests/oci_image_data/oci_test_replace_file.tar".into(), + &extract_dir, + Some(&Arch::Amd64), + ) + .unwrap(); + + let replaced_path = extract_dir.join("etc/a"); + assert!(replaced_path.is_file()); + assert_eq!(read_to_string(replaced_path).unwrap(), "2"); + + // Cleanup + remove_dir_all(extract_dir).unwrap(); +} + +#[test] +fn test_replace_file_with_dir() { + let extract_dir = make_tmp_dir("/tmp/", None).unwrap(); + + parse_and_extract_image( + &"tests/oci_image_data/oci_test_replace_file_with_dir.tar".into(), + &extract_dir, + Some(&Arch::Amd64), + ) + .unwrap(); + + assert!(extract_dir.join("etc/a").is_dir()); + + // Cleanup + remove_dir_all(extract_dir).unwrap(); +} + +#[test] +fn test_replace_dir_with_file() { + let extract_dir = make_tmp_dir("/tmp/", None).unwrap(); + + parse_and_extract_image( + &"tests/oci_image_data/oci_test_replace_dir_with_file.tar".into(), + &extract_dir, + Some(&Arch::Amd64), + ) + .unwrap(); + + assert!(extract_dir.join("etc/a").is_file()); + + // Cleanup + remove_dir_all(extract_dir).unwrap(); +} diff --git a/proxmox-oci/tests/oci_image_data/oci_test_replace_dir_with_file.tar b/proxmox-oci/tests/oci_image_data/oci_test_replace_dir_with_file.tar new file mode 100644 index 0000000000000000000000000000000000000000..c4e488602eef13d5cee53710b97ffce5bf0586c7 GIT binary patch literal 8704 zcmeHM&1+m$6n|QyVekvPu!!jJ7DcEtz26_fjUW-xO=)nU1i7D?C&^5hnS`b_P+h2K z79#!uqM&R23oN*(I}xdi2trrlN_Q@b^}ILJn3;5Dsxt|dytjDo&3X5pd+xdC_q*qw zv8yfHIh!2nh2WB$C;1bu;pcu??;Rt7MN;L5YE@tPMyG4q)oRjiwYuZRoAiBL-@Evm zE!Mx&FocW43WI!6|K0jyLCW<%lBgM2|ELX7hz4(QjE-WC48cM>$A!}|Xb^I%i13jp zB_y^0Qy-O%&`Mx53a|P43&w_Vf9p3QjO@Kb(*zO11WKytC_He?@&ELP^YgW@Yguwa zN#bK7$M_68O zDHlKj+zO?L3I^`ZAdLbt)*1yQpuHa9$cgxuco_eJl=vUv&Dn}`{I|c#@eiwv5Y`+i z%_#QDD9?>l!f5zHsl>#{U;*xeMZ*mZR(c++h7Cb!>djR6-@WI9C3^DYbAPnnf9mGx z#l;6J_p{B%Pwo8vr+l*Uz|K48P-PLA;n5_iTz#*dRA%dhW2|ie|Hf0~gEY~>)-JFE zOe4#Q*DPx3uy?IR~TWJ`8U-BTN6tG=OhV2MH=J+3z|6xK8;GeM)|0BFPTk)kz zwVHNZBdnQML%Wl;n(0E7Jey0`g3rv-)_MR*YS!0RGiSQc;Ou78*IO>DXKQ99)YnWi zi=or4Z{jm=cA$UJ*|nN6TY;YW0C%pe*KI%*boSW_43L}AJE$xK#T4e0GptP@LSyQQ zPyqr7Qqstb&chRXL9qymAdZ+ckh{o8onu0Y!p3~!*~NTzlyb0gyD)s!Y=Iv@_F+xZr=&c8#nXTz8}0Bl|TkSb@;g zwS(yfpK~ukgx4^sA-sg~0@4eJ*QpSM!f~Cw)@$C#I^9-#E2q!pf=*jGm8Pp%bK^p< zMP5gXxv;-6bc+op?bB}Fr=ZFh-^e^P>#;D1`pgft2uGZx!Uiv`ih(o1p#~8VCC&?O zh-X1K2{w^HwDlnn4|NPiNDs)36#)R-FG1)_wOdPx(;(hoSNW z^}n+IGvLNU`BC71ME=)L?EZT)blcRh5AdOkZrY>AK3w;5IwAVGP?=AR3mnMfYrws& zjj?}zjMFgr+a&xWD)zVl+9n9_k6DTT$)26Q#ig`3#l2F5z}^Wk#dTCi>Gt&cOAVz5 ON)MDCC_Qj@df;!g^|Z$T literal 0 HcmV?d00001 diff --git a/proxmox-oci/tests/oci_image_data/oci_test_replace_file.tar b/proxmox-oci/tests/oci_image_data/oci_test_replace_file.tar new file mode 100644 index 0000000000000000000000000000000000000000..77922f7dbb6588a25e2b2514ec017d7327469d06 GIT binary patch literal 8704 zcmeHMOK%)S5FQ8tYsE|CKolWZ%^^Yx-gNc5EiOpN5`s$+!yVma7iW4jW z2cAA4#1BCH1O5S#I0R0JLoVUO32}lG93qA8*|p;}nYHomq9A4to>fg(b#+yL)%}&t zTF3M*W;1w$|%(|UUf82aWeIKWLAAd7t z{(Gw$Gd``TtjT%}D++fRIKz!KHHsdl8hy-Un`p2S5T_K+?wn$V7B_=x-iCa_l%2KdJW0n3`G!roNH|8x9bYc!jA&#wA){kre=icULU zXyO-=bltl`FKuu5D9QE4##&)@KMuIK)po6pEn3C8Uh%DU-7bRf^;=tT;q6}3FO_Yl z9g3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