@@ -96,6 +96,53 @@ def test_clean_option_is_preserved(self):
9696 def test_complete_install_is_reused (self ):
9797 self .check_install ("Linux" , None )
9898
99+ def archive_installer (self ):
100+ script = (ROOT / "thirdparty/build-thirdparty.sh" ).read_text ()
101+ return re .search (r"^install_rust_archive\(\) \{\n.*?^\}" , script , re .M | re .S )[0 ]
102+
103+ def check_archive_publication (self , name ):
104+ source = self .write ("build/" + name , "new archive" )
105+ source .chmod (0o644 )
106+ destination = self .work / "installed/lib64" / name
107+ destination .parent .mkdir (parents = True , exist_ok = True )
108+ self .env .update (TP_INSTALL_DIR = str (self .work / "installed" ),
109+ STRIP_TP_LIB = "ON" , KERNEL = "Linux" , ARCHIVE = str (source ))
110+ failures = {
111+ "copy" : 'cp() { printf partial > "${@: -1}"; return 1; }' ,
112+ "strip" : 'strip() { printf damaged > "${@: -1}"; return 1; }' ,
113+ "publish" : 'mv() { return 1; }' ,
114+ "success" : '' ,
115+ }
116+ for replacement in (False , True ):
117+ for stage , injection in failures .items ():
118+ with self .subTest (archive = name , replacement = replacement , stage = stage ):
119+ if destination .exists ():
120+ destination .unlink ()
121+ if replacement :
122+ destination .write_text ("old archive" )
123+ # Execute the production publisher with failures after partial copy/strip;
124+ # neither a first install nor a replacement may expose those bytes.
125+ result = self .run_bash (self .archive_installer () +
126+ '\n strip() { :; }\n ' + injection +
127+ '\n install_rust_archive "$ARCHIVE"' )
128+ if stage == "success" :
129+ self .assertEqual (result .returncode , 0 , result .stderr )
130+ self .assertEqual (destination .read_text (), "new archive" )
131+ self .assertEqual (destination .stat ().st_mode & 0o777 , 0o644 )
132+ else :
133+ self .assertNotEqual (result .returncode , 0 )
134+ if replacement :
135+ self .assertEqual (destination .read_text (), "old archive" )
136+ else :
137+ self .assertFalse (destination .exists ())
138+ self .assertEqual (list (destination .parent .glob (name + ".tmp.*" )), [])
139+
140+ def test_atomic_lance_archive_publication (self ):
141+ self .check_archive_publication ("liblance_c.a" )
142+
143+ def test_atomic_paimon_archive_publication (self ):
144+ self .check_archive_publication ("libpaimon_c.a" )
145+
99146 def check_header (self , offline , inherited_offline = "" , cargo_override = True ):
100147 script = (ROOT / "thirdparty/build-thirdparty.sh" ).read_text ()
101148 function = re .search (r"^build_paimon_rust\(\) \{\n.*?^\}" , script , re .M | re .S )[0 ]
@@ -130,7 +177,8 @@ def check_header(self, offline, inherited_offline="", cargo_override=True):
130177 self .env ["CARGO" ] = str (cargo )
131178 if inherited_offline :
132179 self .env ["CARGO_NET_OFFLINE" ] = inherited_offline
133- result = self .run_bash ("check_if_source_exist() { :; }\n " + function + "\n build_paimon_rust" )
180+ result = self .run_bash ("check_if_source_exist() { :; }\n " + self .archive_installer ()
181+ + "\n " + function + "\n build_paimon_rust" )
134182 self .assertEqual (result .returncode , 0 , result .stdout + result .stderr )
135183 expected = "true" if offline .upper () == "ON" else inherited_offline or "unset"
136184 self .assertEqual ((self .work / "metadata.log" ).read_text (), expected )
0 commit comments