|
| 1 | +# SPDX-License-Identifier: BSD-3-Clause |
| 2 | +# Copyright(c) 2024-2025 Intel Corporation |
| 3 | + |
| 4 | +import os |
| 5 | + |
| 6 | +import pytest |
| 7 | +from mtl_engine.media_files import yuv_files_422p10le, yuv_files_422rfc10 |
| 8 | +from mtl_engine.rxtxapp import RxTxApp |
| 9 | + |
| 10 | + |
| 11 | +@pytest.mark.smoke |
| 12 | +@pytest.mark.nightly |
| 13 | +@pytest.mark.parametrize( |
| 14 | + "media_file", |
| 15 | + list(yuv_files_422p10le.values()), |
| 16 | + indirect=["media_file"], |
| 17 | + ids=list(yuv_files_422p10le.keys()), |
| 18 | +) |
| 19 | +def test_422p10le_refactored( |
| 20 | + hosts, |
| 21 | + build, |
| 22 | + media, |
| 23 | + nic_port_list, |
| 24 | + test_time, |
| 25 | + test_config, |
| 26 | + prepare_ramdisk, |
| 27 | + media_file, |
| 28 | +): |
| 29 | + """ |
| 30 | + Send files in YUV422PLANAR10LE format converting to transport format YUV_422_10bit |
| 31 | + Using Application class refactored interface |
| 32 | + """ |
| 33 | + media_file_info, media_file_path = media_file |
| 34 | + host = list(hosts.values())[0] |
| 35 | + |
| 36 | + # Get capture configuration from test_config.yaml |
| 37 | + capture_cfg = dict(test_config.get("capture_cfg", {})) |
| 38 | + capture_cfg["test_name"] = f"test_format_refactored_{media_file_info['filename']}" |
| 39 | + |
| 40 | + # Create RxTxApp instance directly |
| 41 | + app = RxTxApp(f"{build}/tests/tools/RxTxApp/build") |
| 42 | + |
| 43 | + # Configure application using universal parameters |
| 44 | + # Note: Passing test_time here ensures it's added to RxTxApp command line |
| 45 | + app.create_command( |
| 46 | + session_type="st20p", |
| 47 | + nic_port_list=host.vfs, |
| 48 | + test_mode="multicast", |
| 49 | + width=media_file_info["width"], |
| 50 | + height=media_file_info["height"], |
| 51 | + framerate=f"p{media_file_info['fps']}", |
| 52 | + pixel_format=media_file_info["file_format"], |
| 53 | + transport_format=media_file_info["format"], |
| 54 | + input_file=media_file_path, |
| 55 | + test_time=test_time, |
| 56 | + ) |
| 57 | + |
| 58 | + # Execute test using Application class |
| 59 | + app.execute_test( |
| 60 | + build=build, |
| 61 | + test_time=test_time, |
| 62 | + host=host, |
| 63 | + capture_cfg=capture_cfg, |
| 64 | + ) |
| 65 | + |
| 66 | + |
| 67 | +# List of supported formats based on st_frame_fmt_from_transport() |
| 68 | +pixel_formats = dict( |
| 69 | + YUV_422_10bit=("ST20_FMT_YUV_422_10BIT", "YUV422RFC4175PG2BE10"), |
| 70 | + YUV_422_8bit=("ST20_FMT_YUV_422_8BIT", "UYVY"), |
| 71 | + YUV_422_12bit=("ST20_FMT_YUV_422_12BIT", "YUV422RFC4175PG2BE12"), |
| 72 | + YUV_444_10bit=("ST20_FMT_YUV_444_10BIT", "YUV444RFC4175PG4BE10"), |
| 73 | + YUV_444_12bit=("ST20_FMT_YUV_444_12BIT", "YUV444RFC4175PG2BE12"), |
| 74 | + YUV_420_8bit=("ST20_FMT_YUV_420_8BIT", "YUV420CUSTOM8"), |
| 75 | + RGB_8bit=("ST20_FMT_RGB_8BIT", "RGB8"), |
| 76 | + RGB_10bit=("ST20_FMT_RGB_10BIT", "RGBRFC4175PG4BE10"), |
| 77 | + RGB_12bit=("ST20_FMT_RGB_12BIT", "RGBRFC4175PG2BE12"), |
| 78 | + YUV_422_PLANAR10LE=("ST20_FMT_YUV_422_PLANAR10LE", "YUV422PLANAR10LE"), |
| 79 | + V210=("ST20_FMT_V210", "V210"), |
| 80 | +) |
| 81 | + |
| 82 | + |
| 83 | +# List of supported one-way convertions based on st_frame_get_converter() |
| 84 | +convert1_formats = dict( |
| 85 | + UYVY="UYVY", |
| 86 | + YUV422PLANAR8="YUV422PLANAR8", |
| 87 | + YUV420PLANAR8="YUV420PLANAR8", |
| 88 | +) |
| 89 | + |
| 90 | + |
| 91 | +@pytest.mark.nightly |
| 92 | +@pytest.mark.parametrize( |
| 93 | + "media_file", |
| 94 | + [yuv_files_422rfc10["Penguin_1080p"]], |
| 95 | + indirect=["media_file"], |
| 96 | + ids=["Penguin_1080p"], |
| 97 | +) |
| 98 | +@pytest.mark.parametrize("format", convert1_formats.keys()) |
| 99 | +def test_convert_on_rx_refactored( |
| 100 | + hosts, build, media, nic_port_list, test_time, format, media_file |
| 101 | +): |
| 102 | + """ |
| 103 | + Send file in YUV_422_10bit pixel formats with supported convertion on RX side |
| 104 | + Using Application class refactored interface |
| 105 | + """ |
| 106 | + media_file_info, media_file_path = media_file |
| 107 | + output_format = convert1_formats[format] |
| 108 | + host = list(hosts.values())[0] |
| 109 | + |
| 110 | + # Create RxTxApp instance directly |
| 111 | + app = RxTxApp(f"{build}/tests/tools/RxTxApp/build") |
| 112 | + |
| 113 | + # Configure application using universal parameters |
| 114 | + app.create_command( |
| 115 | + session_type="st20p", |
| 116 | + nic_port_list=host.vfs, |
| 117 | + test_mode="multicast", |
| 118 | + packing="GPM", |
| 119 | + width=media_file_info["width"], |
| 120 | + height=media_file_info["height"], |
| 121 | + framerate="p30", # TODO: Hardcoded |
| 122 | + pixel_format="YUV422RFC4175PG2BE10", |
| 123 | + transport_format="YUV_422_10bit", |
| 124 | + input_file=media_file_path, |
| 125 | + test_time=test_time, |
| 126 | + ) |
| 127 | + |
| 128 | + # Execute test using Application class |
| 129 | + app.execute_test( |
| 130 | + build=build, |
| 131 | + test_time=test_time, |
| 132 | + host=host, |
| 133 | + ) |
| 134 | + |
| 135 | + |
| 136 | +# List of supported two-way convertions based on st_frame_get_converter() |
| 137 | +convert2_formats = dict( |
| 138 | + V210=("ST20_FMT_YUV_422_10BIT", "YUV_422_10bit", "YUV422RFC4175PG2BE10"), |
| 139 | + Y210=("ST20_FMT_YUV_422_10BIT", "YUV_422_10bit", "YUV422RFC4175PG2BE10"), |
| 140 | + YUV422PLANAR12LE=( |
| 141 | + "ST20_FMT_YUV_422_12BIT", |
| 142 | + "YUV_422_12bit", |
| 143 | + "YUV422RFC4175PG2BE12", |
| 144 | + ), |
| 145 | + YUV444PLANAR10LE=( |
| 146 | + "ST20_FMT_YUV_444_10BIT", |
| 147 | + "YUV_444_10bit", |
| 148 | + "YUV444RFC4175PG4BE10", |
| 149 | + ), |
| 150 | + YUV444PLANAR12LE=( |
| 151 | + "ST20_FMT_YUV_444_12BIT", |
| 152 | + "YUV_444_12bit", |
| 153 | + "YUV444RFC4175PG2BE12", |
| 154 | + ), |
| 155 | + GBRPLANAR10LE=("ST20_FMT_RGB_10BIT", "RGB_10bit", "RGBRFC4175PG4BE10"), |
| 156 | + GBRPLANAR12LE=("ST20_FMT_RGB_12BIT", "RGB_12bit", "RGBRFC4175PG2BE12"), |
| 157 | +) |
| 158 | + |
| 159 | + |
| 160 | +@pytest.mark.parametrize( |
| 161 | + "media_file", |
| 162 | + [yuv_files_422rfc10["test_8K"]], |
| 163 | + indirect=["media_file"], |
| 164 | + ids=["test_8K"], |
| 165 | +) |
| 166 | +@pytest.mark.parametrize("format", convert2_formats.keys()) |
| 167 | +def test_tx_rx_conversion_refactored( |
| 168 | + hosts, |
| 169 | + build, |
| 170 | + media, |
| 171 | + nic_port_list, |
| 172 | + test_time, |
| 173 | + format, |
| 174 | + media_file, |
| 175 | +): |
| 176 | + """ |
| 177 | + Send random file in different pixel formats with supported two-way convertion on TX and RX |
| 178 | + Using Application class refactored interface |
| 179 | + """ |
| 180 | + media_file_info, media_file_path = media_file |
| 181 | + text_format, transport_format, _ = convert2_formats[format] |
| 182 | + host = list(hosts.values())[0] |
| 183 | + |
| 184 | + # Create RxTxApp instance directly |
| 185 | + app = RxTxApp(f"{build}/tests/tools/RxTxApp/build") |
| 186 | + |
| 187 | + # Configure application using universal parameters |
| 188 | + app.create_command( |
| 189 | + session_type="st20p", |
| 190 | + nic_port_list=host.vfs, |
| 191 | + test_mode="multicast", |
| 192 | + packing="GPM", |
| 193 | + width=media_file_info["width"], |
| 194 | + height=media_file_info["height"], |
| 195 | + framerate="p30", # TODO: Hardcoded |
| 196 | + pixel_format=format, |
| 197 | + transport_format=transport_format, |
| 198 | + input_file=media_file_path, |
| 199 | + test_time=test_time, |
| 200 | + ) |
| 201 | + |
| 202 | + # Execute test using Application class |
| 203 | + app.execute_test( |
| 204 | + build=build, |
| 205 | + test_time=test_time, |
| 206 | + host=host, |
| 207 | + ) |
| 208 | + |
| 209 | + |
| 210 | +@pytest.mark.parametrize( |
| 211 | + "media_file", |
| 212 | + [yuv_files_422rfc10["test_8K"]], |
| 213 | + indirect=["media_file"], |
| 214 | + ids=["test_8K"], |
| 215 | +) |
| 216 | +@pytest.mark.parametrize("format", pixel_formats.keys()) |
| 217 | +def test_formats_refactored( |
| 218 | + hosts, |
| 219 | + build, |
| 220 | + media, |
| 221 | + nic_port_list, |
| 222 | + test_time, |
| 223 | + format, |
| 224 | + test_config, |
| 225 | + prepare_ramdisk, |
| 226 | + media_file, |
| 227 | +): |
| 228 | + """ |
| 229 | + Send random file in different supported pixel formats without convertion during transport |
| 230 | + Using Application class refactored interface |
| 231 | + """ |
| 232 | + media_file_info, media_file_path = media_file |
| 233 | + text_format, file_format = pixel_formats[format] |
| 234 | + host = list(hosts.values())[0] |
| 235 | + |
| 236 | + # Get capture configuration from test_config.yaml |
| 237 | + # This controls whether tcpdump capture is enabled, where to store the pcap, etc. |
| 238 | + capture_cfg = dict(test_config.get("capture_cfg", {})) |
| 239 | + capture_cfg["test_name"] = ( |
| 240 | + f"test_format_refactored_formats_{format}" # Set a unique pcap file name |
| 241 | + ) |
| 242 | + |
| 243 | + # Create RxTxApp instance directly |
| 244 | + app = RxTxApp(f"{build}/tests/tools/RxTxApp/build") |
| 245 | + |
| 246 | + # Configure application using universal parameters |
| 247 | + app.create_command( |
| 248 | + session_type="st20p", |
| 249 | + nic_port_list=host.vfs, |
| 250 | + test_mode="multicast", |
| 251 | + packing="GPM", |
| 252 | + width=media_file_info["width"], |
| 253 | + height=media_file_info["height"], |
| 254 | + framerate="p30", # TODO: Hardcoded |
| 255 | + pixel_format=file_format, |
| 256 | + transport_format=format, |
| 257 | + input_file=media_file_path, |
| 258 | + test_time=test_time, |
| 259 | + ) |
| 260 | + |
| 261 | + # Execute test using Application class |
| 262 | + app.execute_test( |
| 263 | + build=build, |
| 264 | + test_time=test_time, |
| 265 | + host=host, |
| 266 | + capture_cfg=capture_cfg, |
| 267 | + ) |
0 commit comments