Skip to content

Commit 7e2759b

Browse files
Revised to add cli commands
1 parent 035a7d8 commit 7e2759b

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ jobs:
6464
- name: Test Discovery between Linux tv-casting-app and Linux tv-app
6565
run: |
6666
./scripts/run_in_build_env.sh \
67-
"./scripts/tests/run_test_suite.py"
67+
"python3 ./scripts/tests/run_tv_casting_test.py test-discovery"
68+
69+
- name: Remove Linux tv-casting-app and Linux tv-app log files
70+
run: |
71+
"rm ./scripts/tests/Linux-tv-casting-app-logs.txt \
72+
rm ./scripts/tests/Linux-tv-app-logs.txt"
6873
6974
- name: Uploading Size Reports
7075
uses: ./.github/actions/upload-size-reports

scripts/tests/run_tv_casting_test.py

+20-11
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 click
1718
import os
1819
import subprocess
1920
import sys
@@ -40,8 +41,6 @@ def read_logs(log_file):
4041
if "cast request 0" in line:
4142
print(line)
4243
found_cast_request_0 = True
43-
# sys.exit(0)
44-
print('DONE!!')
4544

4645
if "No commissioner discovered" in line:
4746
print(line)
@@ -109,24 +108,34 @@ def read_logs(log_file):
109108
print('Discovery did not finish successfully! No user prompt for "cast request 0" displayed!')
110109
sys.exit(1)
111110

112-
if __name__ == '__main__':
113-
114-
with open('Linux-tv-app-logs.txt', 'w') as fd1, open('Linux-tv-casting-app-logs.txt', 'w') as fd2:
111+
def test_discovery_fn():
112+
with open('./scripts/tests/Linux-tv-app-logs.txt', 'w') as fd1, open('./scripts/tests/Linux-tv-casting-app-logs.txt', 'w') as fd2:
115113

116114
# Run the Linux tv-app and write the output to file
117-
tv_app_rel_path = '../../out/tv-app/chip-tv-app'
115+
tv_app_rel_path = 'out/tv-app/chip-tv-app'
118116
tv_app_abs_path = os.path.abspath(tv_app_rel_path)
119-
p1 = subprocess.Popen(tv_app_abs_path, stdout=fd1, text=True)
117+
p1 = subprocess.Popen(tv_app_abs_path, stdout=fd1, stderr=subprocess.PIPE, text=True)
120118

121119
time.sleep(5)
122120

123121
# Run the Linux tv-casting-app and write the output to file
124-
tv_casting_app_rel_path = '../../out/tv-casting-app/chip-tv-casting-app'
122+
tv_casting_app_rel_path = 'out/tv-casting-app/chip-tv-casting-app'
125123
tv_casting_app_abs_path = os.path.abspath(tv_casting_app_rel_path)
126-
p2 = subprocess.Popen(tv_casting_app_abs_path, stdout=fd2, text=True)
124+
p2 = subprocess.Popen(tv_casting_app_abs_path, stdout=fd2, stderr=subprocess.PIPE, text=True)
127125

128126
# Wait for the processes to finish writing before attempting to read
129127
time.sleep(15)
130128

131-
read_logs('Linux-tv-casting-app-logs.txt')
132-
# print('Finished reading')
129+
read_logs('./scripts/tests/Linux-tv-casting-app-logs.txt')
130+
131+
@click.group()
132+
def main():
133+
pass
134+
135+
@main.command()
136+
def test_discovery():
137+
test_discovery_fn()
138+
139+
if __name__ == '__main__':
140+
141+
main()

0 commit comments

Comments
 (0)