@@ -149,9 +149,7 @@ def default_library_path(ipdk_install_dir: Path) -> str:
149149 deps_dir = os .environ .get (deps_env )
150150 if deps_dir :
151151 deps_path = Path (deps_dir )
152- candidate_dirs .extend (
153- [deps_path / "lib" , deps_path / "lib/x86_64-linux-gnu" ]
154- )
152+ candidate_dirs .extend ([deps_path / "lib" , deps_path / "lib/x86_64-linux-gnu" ])
155153
156154 existing_dirs = [str (lib_dir ) for lib_dir in candidate_dirs if lib_dir .exists ()]
157155 return ":" .join (existing_dirs )
@@ -290,65 +288,31 @@ def build_and_load_pipeline(
290288 testutils .log .info ("---------------------- Build and Load Pipeline ----------------------" )
291289 builder = f"{ self .options .ipdk_install_dir } /bin/tdi_pipeline_builder"
292290
293- # NOTE: We intentionally use a fallback matrix instead of probing
294- # `tdi_pipeline_builder --help`.
295- #
296- # Why this exists:
297- # - Different IPDK/networking-recipe releases ship incompatible CLI
298- # variants for the pipeline binary output option.
299- # - Some versions only accept one of the following flags:
300- # * --bf_pipeline_config_binary_file
301- # * --p4_pipeline_config_binary_file
302- # * --pipeline_config_binary_file
303- # - Some builds can also succeed with only --p4c_conf_file.
304- #
305- # Why we do not parse `--help` output:
306- # - In practice, `--help` may return a non-zero exit status and can be
307- # unreliable in this test harness, which caused failures unrelated to
308- # the actual test objective.
309- #
310- # Behavior below:
311- # - Try command variants in deterministic order.
312- # - If failure clearly indicates an unknown option/flag, try next variant.
313- # - For any other failure, stop immediately and surface the real error.
314- commands = [[builder , f"--p4c_conf_file={ p4c_conf } " ]]
315- for candidate_flag in (
316- "--bf_pipeline_config_binary_file" ,
317- "--p4_pipeline_config_binary_file" ,
318- "--pipeline_config_binary_file" ,
319- ):
320- commands .append (
321- [builder , f"--p4c_conf_file={ p4c_conf } " , f"{ candidate_flag } ={ conf_bin } " ]
322- )
323-
324- last_returncode = testutils .FAILURE
325- for command in commands :
326- testutils .log .info ("Executing command: %s" , " " .join (command ))
327- result = subprocess .run (
328- command ,
329- env = proc_env_vars ,
330- capture_output = True ,
331- text = True ,
332- check = False ,
333- timeout = 30 ,
334- )
335- output = f"{ result .stdout or '' } \n { result .stderr or '' } "
336- if result .stdout :
337- testutils .log .info (result .stdout .rstrip ())
338- if result .stderr :
339- testutils .log .warning (result .stderr .rstrip ())
340-
341- last_returncode = result .returncode
342- if result .returncode == testutils .SUCCESS :
343- return testutils .SUCCESS
344-
345- lowered_output = output .lower ()
346- if "unknown command line flag" in lowered_output or "unrecognized option" in lowered_output :
347- continue
348- break
349-
350- testutils .log .error ("Failed to build pipeline" )
351- return last_returncode
291+ command = [
292+ builder ,
293+ f"--p4c_conf_file={ p4c_conf } " ,
294+ f"--bf_pipeline_config_binary_file={ conf_bin } " ,
295+ ]
296+ testutils .log .info ("Executing command: %s" , " " .join (command ))
297+ result = subprocess .run (
298+ command ,
299+ env = proc_env_vars ,
300+ capture_output = True ,
301+ text = True ,
302+ check = False ,
303+ timeout = 30 ,
304+ )
305+ if result .stdout :
306+ testutils .log .info (result .stdout .rstrip ())
307+ if result .stderr :
308+ testutils .log .warning (result .stderr .rstrip ())
309+ if result .returncode != testutils .SUCCESS :
310+ testutils .log .error ("Failed to build pipeline" )
311+ return result .returncode
312+ if not conf_bin .exists ():
313+ testutils .log .error ("Expected pipeline config was not generated: %s" , conf_bin )
314+ return testutils .FAILURE
315+ return testutils .SUCCESS
352316
353317 def run_ptf (self , P4RUNTIME_PORT : int , info_name , conf_bin ) -> int :
354318 """Run the PTF test."""
0 commit comments