14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
17
+ import click
17
18
import os
18
19
import subprocess
19
20
import sys
@@ -40,8 +41,6 @@ def read_logs(log_file):
40
41
if "cast request 0" in line :
41
42
print (line )
42
43
found_cast_request_0 = True
43
- # sys.exit(0)
44
- print ('DONE!!' )
45
44
46
45
if "No commissioner discovered" in line :
47
46
print (line )
@@ -109,24 +108,34 @@ def read_logs(log_file):
109
108
print ('Discovery did not finish successfully! No user prompt for "cast request 0" displayed!' )
110
109
sys .exit (1 )
111
110
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 :
115
113
116
114
# 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'
118
116
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 )
120
118
121
119
time .sleep (5 )
122
120
123
121
# 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'
125
123
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 )
127
125
128
126
# Wait for the processes to finish writing before attempting to read
129
127
time .sleep (15 )
130
128
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