@@ -81,23 +81,34 @@ def run_service(client_class, binary, profile, stack_map, directory, artifact_ro
8181def link_provenance (root , default_binary , isolated_binary ):
8282 default_link = default_binary .parent / "CMakeFiles/hbf_mqsim_service.dir/link.txt"
8383 isolated_ninja = isolated_binary .parents [1 ] / "build.ninja"
84- if not default_link .is_file () or not isolated_ninja .is_file ():
84+ isolated_make = isolated_binary .parents [1 ] / "CMakeFiles/hbf_mqsim_eq3_maint.dir/link.txt"
85+ if not default_link .is_file () or not (isolated_ninja .is_file () or isolated_make .is_file ()):
8586 raise ValueError ("link provenance files are missing" )
8687 default_command = default_link .read_text ().strip ()
8788 if default_command .split ().count ("libmqsim_hbf.a" ) != 1 :
8889 raise AssertionError ("default service must link exactly one default MQSim engine archive" )
89- lines = isolated_ninja .read_text ().splitlines ()
90- marker = "build bin/hbf_mqsim_eq3_maint:"
91- index = next ((i for i , line in enumerate (lines ) if line .startswith (marker )), None )
92- if index is None :
93- raise AssertionError ("isolated service target missing from build graph" )
94- link_line = next ((line .strip () for line in lines [index :index + 20 ]
95- if line .strip ().startswith ("LINK_LIBRARIES =" )), None )
96- if link_line is None :
97- raise AssertionError ("isolated service link libraries are missing" )
98- libraries = link_line .split ("=" , 1 )[1 ].split ()
90+ if isolated_ninja .is_file ():
91+ isolated_evidence = isolated_ninja
92+ lines = isolated_ninja .read_text ().splitlines ()
93+ marker = "build bin/hbf_mqsim_eq3_maint:"
94+ index = next ((i for i , line in enumerate (lines ) if line .startswith (marker )), None )
95+ if index is None :
96+ raise AssertionError ("isolated service target missing from build graph" )
97+ link_line = next ((line .strip () for line in lines [index :index + 20 ]
98+ if line .strip ().startswith ("LINK_LIBRARIES =" )), None )
99+ if link_line is None :
100+ raise AssertionError ("isolated service link libraries are missing" )
101+ libraries = link_line .split ("=" , 1 )[1 ].split ()
102+ else :
103+ isolated_evidence = isolated_make
104+ libraries = [token for token in isolated_make .read_text ().split ()
105+ if token .endswith ((".a" , ".so" ))]
99106 if libraries .count ("lib/libmqsim_eq3_maint.a" ) != 1 :
100107 raise AssertionError ("isolated service must link exactly one isolated MQSim engine archive" )
108+ if any ("mqsim_eq3_maint" in token for token in default_command .split ()):
109+ raise AssertionError ("default service unexpectedly links the maintenance engine" )
110+ if any (Path (token ).name == "libmqsim_hbf.a" for token in libraries ):
111+ raise AssertionError ("isolated service unexpectedly links the default engine" )
101112 default_diff = subprocess .run (
102113 ["git" , "-C" , str (root ), "diff" , "--exit-code" , "HEAD" , "--" , * DEFAULT_ENGINE_PATHS ],
103114 text = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE , check = False )
@@ -112,7 +123,9 @@ def link_provenance(root, default_binary, isolated_binary):
112123 "default_link_command" : default_command ,
113124 "default_link_sha256" : sha256 (default_link ),
114125 "isolated_link_libraries" : libraries ,
115- "isolated_build_ninja_sha256" : sha256 (isolated_ninja ),
126+ "isolated_build_ninja_sha256" : sha256 (isolated_ninja ) if isolated_ninja .is_file () else None ,
127+ "isolated_link_evidence" : str (isolated_evidence ),
128+ "isolated_link_evidence_sha256" : sha256 (isolated_evidence ),
116129 "single_engine_archive_per_process" : True ,
117130 "default_engine_source_paths" : list (DEFAULT_ENGINE_PATHS ),
118131 "default_engine_sources_match_head" : True ,
0 commit comments