Skip to content

Commit 2170d80

Browse files
Update Matter Casting automation test script to use the simplified Linux tv-casting-app build command in the workflow yaml file.
1 parent 9d56786 commit 2170d80

File tree

3 files changed

+48
-38
lines changed

3 files changed

+48
-38
lines changed

.github/workflows/examples-linux-tv-casting-app.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
- name: Build Linux tv-casting-app
6262
run: |
6363
./scripts/run_in_build_env.sh \
64-
"scripts/examples/gn_build_example.sh examples/tv-casting-app/linux/ out/tv-casting-app"
64+
"scripts/examples/gn_build_example.sh examples/tv-casting-app/linux/ out/tv-casting-app chip_casting_simplified=true"
6565
6666
- name: Test casting from Linux tv-casting-app to Linux tv-app
6767
run: |

scripts/tests/linux/tv_casting_test_sequences.py

+20-25
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
"""
2020
In this file, we define the test sequences with the relevant steps that will be used in the `scripts/tests/run_tv_casting_test.py`
21-
for validating the casting experience between the Linux tv-casting-app and the Linux tv-app.
21+
test script for validating the casting experience between the Linux tv-casting-app and the Linux tv-app.
2222
2323
At the beginning of each test sequence we need to indicate the start up of the tv-app using the `START_APP` string as the `input_cmd`
2424
followed by the same for the tv-casting-app. On the other hand, at the end of each test sequence we need to ensure that each app will
@@ -71,11 +71,8 @@
7171
PRODUCT_ID = 0x8001 # Test product id
7272
DEVICE_TYPE_CASTING_VIDEO_PLAYER = 0x23 # Device type library 10.3: Casting Video Player
7373

74-
TEST_TV_CASTING_APP_DEVICE_NAME = 'Test TV casting app' # Test device name for identifying the tv-casting-app
75-
76-
# Values to verify the subscription state against from the `ReportDataMessage` in the Linux tv-casting-app output.
77-
CLUSTER_MEDIA_PLAYBACK = '0x506' # Application Cluster Spec 6.10.3 Cluster ID: Media Playback
78-
ATTRIBUTE_CURRENT_PLAYBACK_STATE = '0x0000_0000' # Application Cluster Spec 6.10.6 Attribute ID: Current State of Playback
74+
# Value to verify the subscription state against in the Linux tv-casting-app output.
75+
ATTRIBUTE_CURRENT_PLAYBACK_STATE = 0x0000_0000 # Application Cluster Spec 6.10.6 Attribute ID: Current State of Playback
7976

8077
test_sequences = [
8178
Sequence(
@@ -93,27 +90,24 @@
9390
# Validate that the server is properly initialized in the tv-casting-app output.
9491
Step(app=App.TV_CASTING_APP, timeout_sec=APP_MAX_START_WAIT_SEC, output_msg=['Server initialization complete']),
9592

96-
# Validate that there is a valid discovered commissioner with {VENDOR_ID}, {PRODUCT_ID}, and {DEVICE_TYPE_CASTING_VIDEO_PLAYER} in the tv-casting-app output.
97-
Step(app=App.TV_CASTING_APP, output_msg=['Discovered Commissioner #0', f'Vendor ID: {VENDOR_ID}', f'Product ID: {PRODUCT_ID}',
93+
# Validate that there is a valid discovered casting player with {PRODUCT_ID}, {VENDOR_ID}, and {DEVICE_TYPE_CASTING_VIDEO_PLAYER} in the tv-casting-app output.
94+
Step(app=App.TV_CASTING_APP, output_msg=['Discovered CastingPlayer #0', f'Product ID: {PRODUCT_ID}', f'Vendor ID: {VENDOR_ID}',
9895
f'Device Type: {DEVICE_TYPE_CASTING_VIDEO_PLAYER}', 'Supports Commissioner Generated Passcode: true']),
9996

100-
# Validate that we are ready to send `cast request` command to the tv-casting-app subprocess.
101-
Step(app=App.TV_CASTING_APP, output_msg=['Example: cast request 0']),
102-
10397
# Send `cast request {valid_discovered_commissioner_number}\n` command to the tv-casting-app subprocess.
10498
Step(app=App.TV_CASTING_APP, input_cmd='cast request 0\n'),
10599

106-
# Validate that the `Identification Declaration` message block in the tv-casting-app output has the expected values for `device Name`, `vendor id`, and `product id`.
107-
Step(app=App.TV_CASTING_APP, output_msg=['Identification Declaration Start', f'device Name: {TEST_TV_CASTING_APP_DEVICE_NAME}',
108-
f'vendor id: {VENDOR_ID}', f'product id: {PRODUCT_ID}', 'Identification Declaration End']),
100+
# Validate that the tv-casting-app begins the commissioning process.
101+
Step(app=App.TV_CASTING_APP, output_msg=[
102+
'CastingPlayer::VerifyOrEstablishConnection() calling OpenBasicCommissioningWindow()']),
109103

110-
# Validate that the `Identification Declaration` message block in the tv-app output has the expected values for `device Name`, `vendor id`, and `product id`.
111-
Step(app=App.TV_APP, output_msg=['Identification Declaration Start', f'device Name: {TEST_TV_CASTING_APP_DEVICE_NAME}',
112-
f'vendor id: {VENDOR_ID}', f'product id: {PRODUCT_ID}', 'Identification Declaration End']),
104+
# Validate that the `IdentificationDeclaration` message sent from the tv-casting-app to the tv-app will contain the {VENDOR_ID} of the target content app.
105+
Step(app=App.TV_CASTING_APP, output_msg=['IdentificationDeclarationOptions::TargetAppInfos list:']),
106+
Step(app=App.TV_CASTING_APP, output_msg=[f'TargetAppInfo 1, Vendor ID: {VENDOR_ID}']),
113107

114108
# Validate that we received the cast request from the tv-casting-app on the tv-app output.
115109
Step(app=App.TV_APP,
116-
output_msg=['PROMPT USER: Test TV casting app is requesting permission to cast to this TV, approve?']),
110+
output_msg=['------PROMPT USER: Test TV casting app is requesting permission to cast to this TV, approve?']),
117111

118112
# Validate that we received the instructions on the tv-app output for sending the `controller ux ok` command.
119113
Step(app=App.TV_APP, output_msg=['Via Shell Enter: controller ux ok|cancel']),
@@ -124,23 +118,24 @@
124118
# Validate that pairing succeeded between the tv-casting-app and the tv-app.
125119
Step(app=App.TV_APP, output_msg=['Secure Pairing Success']),
126120

127-
# Validate that commissioning succeeded in the tv-casting-app output.
128-
Step(app=App.TV_CASTING_APP, output_msg=['Commissioning completed successfully']),
121+
# Validate that the connection succeeded in the tv-casting-app output.
122+
Step(app=App.TV_CASTING_APP, output_msg=['Successfully connected to CastingPlayer']),
129123

130124
# Validate that commissioning succeeded in the tv-app output.
131125
Step(app=App.TV_APP, output_msg=['------PROMPT USER: commissioning success']),
132126

133-
# Validate the subscription state by looking at the `Cluster` and `Attribute` values in the `ReportDataMessage` block in the tv-casting-app output.
134-
Step(app=App.TV_CASTING_APP, output_msg=[
135-
'ReportDataMessage =', f'Cluster = {CLUSTER_MEDIA_PLAYBACK}', f'Attribute = {ATTRIBUTE_CURRENT_PLAYBACK_STATE}', 'InteractionModelRevision =', '}']),
127+
# Validate that we are able to read the application VendorID value and that it matches {VENDOR_ID}.
128+
Step(app=App.TV_CASTING_APP, output_msg=[f'Read VendorID value: {VENDOR_ID}']),
129+
130+
# Validate that we are able to subscribe to the media playback cluster by reading the CurrentState value and that it matches {ATTRIBUTE_CURRENT_PLAYBACK_STATE}.
131+
Step(app=App.TV_CASTING_APP, output_msg=[f'Read CurrentState value: {ATTRIBUTE_CURRENT_PLAYBACK_STATE}']),
136132

137133
# Validate the LaunchURL in the tv-app output.
138134
Step(app=App.TV_APP,
139135
output_msg=['ContentLauncherManager::HandleLaunchUrl TEST CASE ContentURL=https://www.test.com/videoid DisplayString=Test video']),
140136

141137
# Validate the LaunchURL in the tv-casting-app output.
142-
Step(app=App.TV_CASTING_APP, output_msg=['InvokeResponseMessage =',
143-
'exampleData', 'InteractionModelRevision =', '},']),
138+
Step(app=App.TV_CASTING_APP, output_msg=['LaunchURL Success with response.data: exampleData']),
144139

145140
# Signal to stop the tv-casting-app as we finished validation.
146141
Step(app=App.TV_CASTING_APP, input_cmd=STOP_APP),

scripts/tests/run_tv_casting_test.py

+27-12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
import glob
1718
import logging
1819
import os
1920
import signal
@@ -63,6 +64,21 @@ def __exit__(self, exception_type, exception_value, traceback):
6364
self.process.wait()
6465

6566

67+
def remove_cached_files(cached_file_pattern: str) -> bool:
68+
"""Remove any cached files that match the provided pattern."""
69+
70+
cached_files = glob.glob(cached_file_pattern) # Returns a list of paths that match the pattern.
71+
72+
for cached_file in cached_files:
73+
try:
74+
os.remove(cached_file)
75+
except OSError as e:
76+
logging.error(f'Failed to remove cached file `{cached_file}` with error: `{e.strerror}`.')
77+
return False
78+
79+
return True
80+
81+
6682
def dump_temporary_logs_to_console(log_file_path: str):
6783
"""Dump log file to the console; log file will be removed once the function exits."""
6884
"""Write the entire content of `log_file_path` to the console."""
@@ -86,7 +102,7 @@ def handle_casting_failure(test_sequence_name: str, log_file_paths: List[str]):
86102
sys.exit(1)
87103

88104

89-
def stop_app(test_sequence_name: str, app_name: str, app: subprocess.Popen):
105+
def stop_app(test_sequence_name: str, app_name: str, app: subprocess.Popen) -> bool:
90106
"""Stop the given `app` subprocess."""
91107

92108
app.terminate()
@@ -115,7 +131,7 @@ def parse_output_msg_in_subprocess(
115131
log_paths: List[str],
116132
test_sequence_name: str,
117133
test_sequence_step: Step
118-
):
134+
) -> bool:
119135
"""Parse the output of a given `app` subprocess and validate its output against the expected `output_msg` in the given `Step`."""
120136

121137
if not test_sequence_step.output_msg:
@@ -168,25 +184,22 @@ def send_input_cmd_to_subprocess(
168184
tv_app_info: Tuple[subprocess.Popen, TextIO],
169185
test_sequence_name: str,
170186
test_sequence_step: Step
171-
):
187+
) -> bool:
172188
"""Send a given input command (`input_cmd`) from the `Step` to its given `app` subprocess."""
173189

174190
if not test_sequence_step.input_cmd:
175191
logging.error(f'{test_sequence_name} - No input command provided in the test sequence step.')
176192
return False
177193

178194
app_subprocess, app_log_file = (tv_casting_app_info if test_sequence_step.app == App.TV_CASTING_APP else tv_app_info)
195+
app_name = test_sequence_step.app.value
179196

180-
app_subprocess.stdin.write(test_sequence_step.input_cmd)
197+
input_cmd = test_sequence_step.input_cmd
198+
app_subprocess.stdin.write(input_cmd)
181199
app_subprocess.stdin.flush()
182200

183-
# Read in the next line which should be the `input_cmd` that was issued.
184-
next_line = app_subprocess.stdout.readline()
185-
app_log_file.write(next_line)
186-
app_log_file.flush()
187-
next_line = next_line.rstrip('\n')
188-
189-
logging.info(f'{test_sequence_name} - Sent `{next_line}` to the {test_sequence_step.app.value} subprocess.')
201+
input_cmd = input_cmd.rstrip('\n')
202+
logging.info(f'{test_sequence_name} - Sent `{input_cmd}` to the {app_name} subprocess.')
190203

191204
return True
192205

@@ -338,7 +351,9 @@ def test_casting_fn(tv_app_rel_path, tv_casting_app_rel_path):
338351
if __name__ == '__main__':
339352

340353
# Start with a clean slate by removing any previously cached entries.
341-
os.system('rm -f /tmp/chip_*')
354+
cached_file_pattern = '/tmp/chip_*'
355+
if not remove_cached_files(cached_file_pattern):
356+
sys.exit(1)
342357

343358
# Test casting (discovery and commissioning) between the Linux tv-casting-app and the tv-app.
344359
test_casting_fn()

0 commit comments

Comments
 (0)