Skip to content

Commit 0c5d374

Browse files
committed
Merge branch 'fix/find_and_close_service_in_ot_ci_case_v5.4' into 'release/v5.4'
fix(ci): optimize an openthread ci case (Backport v5.4) See merge request espressif/esp-idf!34727
2 parents 3b2eb13 + 454c314 commit 0c5d374

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/openthread/ot_ci_function.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# SPDX-License-Identifier: Unlicense OR CC0-1.0
33
# !/usr/bin/env python3
44
# this file defines some functions for testing cli and br under pytest framework
5-
65
import re
76
import socket
87
import struct
@@ -411,12 +410,15 @@ def host_publish_service() -> None:
411410

412411

413412
def host_close_service() -> None:
414-
command = "ps | grep avahi-publish-s | awk '{print $1}'"
413+
command = 'ps aux | grep avahi-publish-s'
415414
out_bytes = subprocess.check_output(command, shell=True, timeout=5)
416415
out_str = out_bytes.decode('utf-8')
417-
the_pid = re.findall(r'(\d+)\n', str(out_str))
418-
for pid in the_pid:
416+
service_info = [line for line in out_str.splitlines() if 'testxxx _testxxx._udp' in line]
417+
for line in service_info:
418+
print('Process:', line)
419+
pid = line.split()[1]
419420
command = 'kill -9 ' + pid
421+
print('kill ', pid)
420422
subprocess.call(command, shell=True, timeout=5)
421423
time.sleep(1)
422424

0 commit comments

Comments
 (0)