Skip to content

Commit ea9a173

Browse files
committed
Fix formatting
1 parent b975b69 commit ea9a173

File tree

6 files changed

+52
-32
lines changed

6 files changed

+52
-32
lines changed

tests/validation/mtl_engine/GstreamerApp.py

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright(c) 2024-2025 Intel Corporation
33

4-
import hashlib
54
import logging
65
import os
7-
import time
86
import re
7+
import time
98

109
from mtl_engine.RxTxApp import prepare_tcpdump
1110

@@ -54,20 +53,20 @@ def fract_format(framerate: str) -> str:
5453
# If already in fractional format, return as-is
5554
if "/" in framerate:
5655
return framerate
57-
56+
5857
# Convert specific decimal framerates to fractional format
5958
framerate_map = {
6059
"23.98": "2398/100",
61-
"23.976": "2398/100",
60+
"23.976": "2398/100",
6261
"29.97": "2997/100",
6362
"59.94": "5994/100",
64-
"119.88": "11988/100"
63+
"119.88": "11988/100",
6564
}
66-
65+
6766
# Check if it's one of the special decimal framerates
6867
if framerate in framerate_map:
6968
return framerate_map[framerate]
70-
69+
7170
# For integer framerates, add /1
7271
try:
7372
int(framerate) # Validate it's a number
@@ -324,6 +323,7 @@ def setup_gstreamer_st40p_rx_pipeline(
324323

325324
return pipeline_command
326325

326+
327327
def execute_test(
328328
build: str,
329329
tx_command: dict,
@@ -357,15 +357,15 @@ def execute_test(
357357
:return: True if test passed, False otherwise
358358
"""
359359
is_dual = tx_host is not None and rx_host is not None
360-
360+
361361
if is_dual:
362362
logger.info("Executing dual host GStreamer test")
363363
tx_remote_host = tx_host
364364
rx_remote_host = rx_host
365365
else:
366366
logger.info("Executing single host GStreamer test")
367367
tx_remote_host = rx_remote_host = host
368-
368+
369369
case_id = os.environ.get("PYTEST_CURRENT_TEST", "gstreamer_test")
370370
case_id = case_id[: case_id.rfind("(") - 1] if "(" in case_id else case_id
371371

@@ -374,10 +374,10 @@ def execute_test(
374374

375375
tx_process = None
376376
rx_process = None
377-
377+
378378
if is_dual:
379379
tx_tcpdump = prepare_tcpdump(capture_cfg, tx_host) if capture_cfg else None
380-
rx_tcpdump = prepare_tcpdump(capture_cfg, rx_host) if capture_cfg else None
380+
# rx_tcpdump = prepare_tcpdump(capture_cfg, rx_host) if capture_cfg else None # Unused
381381
tcpdump = tx_tcpdump
382382
else:
383383
tcpdump = prepare_tcpdump(capture_cfg, host)
@@ -492,15 +492,20 @@ def execute_test(
492492
# Compare files for validation
493493
if is_dual:
494494
# For dual host tests, files are on different hosts
495-
file_compare = compare_files(input_file, output_file, tx_remote_host, rx_remote_host)
495+
file_compare = compare_files(
496+
input_file, output_file, tx_remote_host, rx_remote_host
497+
)
496498
else:
497499
# For single host tests, both files are on the same host
498-
file_compare = compare_files(input_file, output_file, tx_remote_host, rx_remote_host)
499-
500+
file_compare = compare_files(
501+
input_file, output_file, tx_remote_host, rx_remote_host
502+
)
503+
500504
logger.info(f"File comparison: {file_compare}")
501505

502506
return file_compare
503507

508+
504509
def compare_files(input_file, output_file, input_host=None, output_host=None):
505510
"""
506511
Compare files on remote hosts.
@@ -513,13 +518,15 @@ def compare_files(input_file, output_file, input_host=None, output_host=None):
513518
# Check if input file exists (for cases where input file might not be created)
514519
input_stat_proc = run(f"stat -c '%s' {input_file}", host=input_host)
515520
input_file_exists = input_stat_proc.return_code == 0
516-
521+
517522
if input_file_exists:
518523
input_file_size = int(input_stat_proc.stdout_text.strip())
519524
logger.info(f"Input file size: {input_file_size}")
520525
else:
521-
logger.info(f"Input file {input_file} does not exist - skipping input validation")
522-
526+
logger.info(
527+
f"Input file {input_file} does not exist - skipping input validation"
528+
)
529+
523530
# Check output file size (always remote)
524531
output_stat_proc = run(f"stat -c '%s' {output_file}", host=output_host)
525532
if output_stat_proc.return_code != 0:
@@ -536,7 +543,7 @@ def compare_files(input_file, output_file, input_host=None, output_host=None):
536543
else:
537544
log_fail("Output file is empty")
538545
return False
539-
546+
540547
# If input file exists, do full comparison
541548
if input_file_size != output_file_size:
542549
log_fail("File size is different")
@@ -546,20 +553,28 @@ def compare_files(input_file, output_file, input_host=None, output_host=None):
546553
if input_hash_proc.return_code != 0:
547554
log_fail(f"Could not calculate hash for input file {input_file}")
548555
return False
549-
i_hash = input_hash_proc.stdout_text.split()[0] if input_hash_proc.stdout_text.strip() else ""
556+
i_hash = (
557+
input_hash_proc.stdout_text.split()[0]
558+
if input_hash_proc.stdout_text.strip()
559+
else ""
560+
)
550561

551562
output_hash_proc = run(f"md5sum {output_file}", host=output_host)
552563
if output_hash_proc.return_code != 0:
553564
log_fail(f"Could not calculate hash for output file {output_file}")
554565
return False
555-
o_hash = output_hash_proc.stdout_text.split()[0] if output_hash_proc.stdout_text.strip() else ""
566+
o_hash = (
567+
output_hash_proc.stdout_text.split()[0]
568+
if output_hash_proc.stdout_text.strip()
569+
else ""
570+
)
556571

557572
logger.info(f"Input file hash: {i_hash}")
558573
logger.info(f"Output file hash: {o_hash}")
559-
574+
560575
if i_hash and o_hash and i_hash == o_hash:
561576
return True
562-
577+
563578
except Exception as e:
564579
log_fail(f"Error during file comparison: {e}")
565580
return False
@@ -604,5 +619,4 @@ def get_case_id() -> str:
604619

605620
def sanitize_filename(name: str) -> str:
606621
"""Replace unsafe characters with underscores"""
607-
import re
608622
return re.sub(r"[^A-Za-z0-9_.-]", "_", name)

tests/validation/tests/dual/gstreamer/anc_format/test_anc_format_dual.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def test_st40p_fps_size_dual(
8585
capture_cfg=capture_cfg,
8686
)
8787

88-
assert result, f"GStreamer dual ST40P test failed for fps={fps}, size={file_size_kb}KB"
88+
assert (
89+
result
90+
), f"GStreamer dual ST40P test failed for fps={fps}, size={file_size_kb}KB"
8991

9092
finally:
9193
# Remove the input file on TX host and output file on RX host

tests/validation/tests/dual/gstreamer/audio_format/test_audio_format_dual.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def test_audio_format_dual(
4646
# )
4747

4848
# Create output file path for RX host
49-
output_file_path = os.path.join(media, f"output_audio_dual_{audio_format}_{audio_channel}_{audio_rate}.pcm")
49+
output_file_path = os.path.join(
50+
media, f"output_audio_dual_{audio_format}_{audio_channel}_{audio_rate}.pcm"
51+
)
5052

5153
# Setup TX pipeline using existing function
5254
tx_config = GstreamerApp.setup_gstreamer_st30_tx_pipeline(
@@ -92,7 +94,9 @@ def test_audio_format_dual(
9294
capture_cfg=capture_cfg,
9395
)
9496

95-
assert result, f"GStreamer dual audio format test failed for format {audio_format}"
97+
assert (
98+
result
99+
), f"GStreamer dual audio format test failed for format {audio_format}"
96100

97101
finally:
98102
# Remove the output file on RX host

tests/validation/tests/dual/gstreamer/video_resolution/test_video_resolution_dual.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
from tests.xfail import SDBQ1971_conversion_v210_720p_error
1111

1212

13-
@pytest.mark.parametrize(
14-
"file", yuv_files.keys()
15-
)
13+
@pytest.mark.parametrize("file", yuv_files.keys())
1614
def test_video_resolutions_dual(
1715
hosts,
1816
build,
@@ -99,7 +97,9 @@ def test_video_resolutions_dual(
9997
capture_cfg=capture_cfg,
10098
)
10199

102-
assert result, f"GStreamer dual video resolution test failed for resolution {file}"
100+
assert (
101+
result
102+
), f"GStreamer dual video resolution test failed for resolution {file}"
103103

104104
finally:
105105
# Remove the input file on TX host and output file on RX host

tests/validation/tests/single/gstreamer/anc_format/test_anc_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_st40p_framebuff(
133133
tx_first=False,
134134
sleep_interval=3,
135135
capture_cfg=capture_cfg,
136-
)
136+
)
137137
finally:
138138
# Remove the files after the test
139139
media_create.remove_file(input_file_path, host=host)

tests/validation/tests/single/gstreamer/audio_format/test_audio_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ def test_audio_format(
8080
)
8181
finally:
8282
pass
83-
#media_create.remove_file(input_file_path, host=host)
83+
# media_create.remove_file(input_file_path, host=host)
8484
media_create.remove_file(os.path.join(media, "output_audio.pcm"), host=host)

0 commit comments

Comments
 (0)