@@ -290,65 +290,31 @@ def build_and_load_pipeline(
290290 testutils .log .info ("---------------------- Build and Load Pipeline ----------------------" )
291291 builder = f"{ self .options .ipdk_install_dir } /bin/tdi_pipeline_builder"
292292
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
293+ command = [
294+ builder ,
295+ f"--p4c_conf_file={ p4c_conf } " ,
296+ f"--pipeline_config_binary_file={ conf_bin } " ,
297+ ]
298+ testutils .log .info ("Executing command: %s" , " " .join (command ))
299+ result = subprocess .run (
300+ command ,
301+ env = proc_env_vars ,
302+ capture_output = True ,
303+ text = True ,
304+ check = False ,
305+ timeout = 30 ,
306+ )
307+ if result .stdout :
308+ testutils .log .info (result .stdout .rstrip ())
309+ if result .stderr :
310+ testutils .log .warning (result .stderr .rstrip ())
311+ if result .returncode != testutils .SUCCESS :
312+ testutils .log .error ("Failed to build pipeline" )
313+ return result .returncode
314+ if not conf_bin .exists ():
315+ testutils .log .error ("Expected pipeline config was not generated: %s" , conf_bin )
316+ return testutils .FAILURE
317+ return testutils .SUCCESS
352318
353319 def run_ptf (self , P4RUNTIME_PORT : int , info_name , conf_bin ) -> int :
354320 """Run the PTF test."""
0 commit comments