Skip to content

Commit f2ff8bd

Browse files
committed
Add integrity into st30 test cases
1 parent 81e7db7 commit f2ff8bd

File tree

7 files changed

+61
-45
lines changed

7 files changed

+61
-45
lines changed

tests/validation/mtl_engine/integrity.py

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,61 +76,76 @@ def check_st30p_integrity(src_url: str, out_url: str, size: int):
7676
return True
7777

7878

79-
def calculate_st30p_framebuff_size(
80-
format: str, ptime: str, sampling: str, channel: str
81-
):
79+
def get_sample_size(format: str) -> int:
8280
match format:
8381
case "PCM8":
84-
sample_size = 1
82+
return 1
8583
case "PCM16":
86-
sample_size = 2
84+
return 2
8785
case "PCM24":
88-
sample_size = 3
86+
return 3
87+
case _:
88+
log_fail(f"Unknown audio format: {format}")
89+
return 0
90+
8991

92+
def get_sample_number(sampling: str, ptime: str) -> int:
9093
match sampling:
9194
case "48kHz":
9295
match ptime:
9396
case "1":
94-
sample_num = 48
97+
return 48
9598
case "0.12":
96-
sample_num = 6
99+
return 6
97100
case "0.25":
98-
sample_num = 12
101+
return 12
99102
case "0.33":
100-
sample_num = 16
103+
return 16
101104
case "4":
102-
sample_num = 192
105+
return 192
103106
case "96kHz":
104107
match ptime:
105108
case "1":
106-
sample_num = 96
109+
return 96
107110
case "0.12":
108-
sample_num = 12
111+
return 12
109112
case "0.25":
110-
sample_num = 24
113+
return 24
111114
case "0.33":
112-
sample_num = 32
115+
return 32
113116
case "4":
114-
sample_num = 384
117+
return 384
118+
return 0
119+
115120

121+
def get_channel_number(channel: str) -> int:
116122
match channel:
117123
case "M":
118-
channel_num = 1
124+
return 1
119125
case "DM" | "ST" | "LtRt" | "AES3":
120-
channel_num = 2
126+
return 2
121127
case "51":
122-
channel_num = 6
128+
return 6
123129
case "71":
124-
channel_num = 8
130+
return 8
125131
case "222":
126-
channel_num = 24
132+
return 24
127133
case "SGRP":
128-
channel_num = 4
134+
return 4
129135
case _:
130136
match = re.match(r"^U(\d{2})$", channel)
131137

132138
if match:
133-
channel_num = int(match.group(1))
139+
return int(match.group(1))
140+
return 0
141+
142+
143+
def calculate_st30p_framebuff_size(
144+
format: str, ptime: str, sampling: str, channel: str
145+
):
146+
sample_size = get_sample_size(format)
147+
sample_num = get_sample_number(sampling, ptime)
148+
channel_num = get_channel_number(channel)
134149

135150
packet_size = sample_size * sample_num * channel_num
136151

tests/validation/mtl_engine/media_files.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,15 @@
519519

520520
audio_files = dict(
521521
PCM24={
522-
"filename": "test.wav",
522+
"filename": "voice_48k_24ch_1min_24pcm.raw",
523523
"format": "PCM24",
524524
},
525525
PCM16={
526-
"filename": "test.wav",
526+
"filename": "voice_48k_24ch_1min_24pcm.raw",
527527
"format": "PCM16",
528528
},
529529
PCM8={
530-
"filename": "test.wav",
530+
"filename": "voice_48k_24ch_1min_24pcm.raw",
531531
"format": "PCM8",
532532
},
533533
)

tests/validation/tests/single/rss_mode/audio/test_rss_mode_audio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
from common.integrity.integrity_runner import FileAudioIntegrityRunner
88
from mtl_engine.execute import log_fail
9+
from mtl_engine.integrity import get_sample_size
910
from mtl_engine.media_files import audio_files
1011

1112
logger = logging.getLogger(__name__)
@@ -78,6 +79,7 @@ def test_rss_mode_audio(
7879
test_repo_path=build,
7980
src_url=media_file_path,
8081
out_name=out_file_url.name,
82+
sample_size=get_sample_size(media_file_info["format"]),
8183
out_path=str(out_file_url.parent),
8284
)
8385
result = integrity.run()

tests/validation/tests/single/st30p/st30p_channel/test_st30p_channel.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import mtl_engine.RxTxApp as rxtxapp
66
import pytest
77
from common.integrity.integrity_runner import FileAudioIntegrityRunner
8-
from future.backports.test.pystone import TRUE
98
from mtl_engine.execute import log_fail
9+
from mtl_engine.integrity import get_channel_number, get_sample_size
1010
from mtl_engine.media_files import audio_files
1111
from tests.xfail import SDBQ1001_audio_channel_check
1212

@@ -56,7 +56,7 @@ def test_st30p_channel(
5656
f"test_st30p_channel_{media_file_info['format']}_{audio_channel}" # e.g., test_st30p_channel_PCM8_M
5757
)
5858

59-
out_file_url = host.connection.path(media_file_path).parent / "out.wav"
59+
out_file_url = host.connection.path(media_file_path).parent / "out.pcm"
6060

6161
config = rxtxapp.create_empty_config()
6262
config = rxtxapp.add_st30p_sessions(
@@ -78,18 +78,19 @@ def test_st30p_channel(
7878
host=host,
7979
capture_cfg=capture_cfg,
8080
)
81-
if test_config.get("integrity_check", TRUE):
81+
82+
if test_config.get("integrity_check", True):
8283
logger.info("Running audio integrity check...")
8384
integrity = FileAudioIntegrityRunner(
8485
host=host,
8586
test_repo_path=build,
8687
src_url=media_file_path,
8788
out_name=out_file_url.name,
89+
channel_num=get_channel_number(audio_channel),
90+
sample_size=get_sample_size(media_file_info["format"]),
8891
out_path=str(out_file_url.parent),
92+
delete_file=True,
8993
)
9094
result = integrity.run()
9195
if not result:
92-
# log_fail("Audio integrity check failed")
93-
logger.warning(
94-
"Integrity check failed probably because incorrect source file."
95-
)
96+
log_fail("Audio integrity check failed")

tests/validation/tests/single/st30p/st30p_format/test_st30p_format.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
from common.integrity.integrity_runner import FileAudioIntegrityRunner
88
from mtl_engine.execute import log_fail
9+
from mtl_engine.integrity import get_sample_size
910
from mtl_engine.media_files import audio_files
1011

1112
logger = logging.getLogger(__name__)
@@ -76,11 +77,9 @@ def test_st30p_format(
7677
test_repo_path=build,
7778
src_url=media_file_path,
7879
out_name=out_file_url.name,
80+
sample_size=get_sample_size(media_file_info["format"]),
7981
out_path=str(out_file_url.parent),
8082
)
8183
result = integrity.run()
8284
if not result:
83-
# log_fail("Audio integrity check failed")
84-
logger.warning(
85-
"Integrity check failed probably because incorrect source file."
86-
)
85+
log_fail("Audio integrity check failed")

tests/validation/tests/single/st30p/st30p_ptime/test_st30p_ptime.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
from common.integrity.integrity_runner import FileAudioIntegrityRunner
88
from mtl_engine.execute import log_fail
9+
from mtl_engine.integrity import get_sample_size
910
from mtl_engine.media_files import audio_files
1011

1112
logger = logging.getLogger(__name__)
@@ -78,11 +79,9 @@ def test_st30p_ptime(
7879
test_repo_path=build,
7980
src_url=media_file_path,
8081
out_name=out_file_url.name,
82+
sample_size=get_sample_size(media_file_info["format"]),
8183
out_path=str(out_file_url.parent),
8284
)
8385
result = integrity.run()
8486
if not result:
85-
# log_fail("Audio integrity check failed")
86-
logger.warning(
87-
"Integrity check failed probably because incorrect source file."
88-
)
87+
log_fail("Audio integrity check failed")

tests/validation/tests/single/st30p/st30p_sampling/test_st30p_sampling.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
from common.integrity.integrity_runner import FileAudioIntegrityRunner
88
from mtl_engine.execute import log_fail
9+
from mtl_engine.integrity import get_sample_number, get_sample_size
910
from mtl_engine.media_files import audio_files
1011

1112
logger = logging.getLogger(__name__)
@@ -78,11 +79,10 @@ def test_st30p_sampling(
7879
test_repo_path=build,
7980
src_url=media_file_path,
8081
out_name=out_file_url.name,
82+
sample_size=get_sample_size(media_file_info["format"]),
83+
sample_num=get_sample_number(audio_sampling, "1"),
8184
out_path=str(out_file_url.parent),
8285
)
8386
result = integrity.run()
8487
if not result:
85-
# log_fail("Audio integrity check failed")
86-
logger.warning(
87-
"Integrity check failed probably because incorrect source file."
88-
)
88+
log_fail("Audio integrity check failed")

0 commit comments

Comments
 (0)