Merge branch 'fix/find_and_close_service_in_ot_ci_case_v5.1' into 'release/v5.1'

fix(ci): optimize an openthread ci case (Backport v5.1)

See merge request espressif/esp-idf!34724
This commit is contained in:
Shu Chen 2024-11-14 11:58:58 +08:00
commit 5ed3e67c7c

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: Unlicense OR CC0-1.0
# !/usr/bin/env python3
# this file defines some functions for testing cli and br under pytest framework
import re
import socket
import struct
@ -392,12 +391,15 @@ def host_publish_service() -> None:
def host_close_service() -> None:
command = "ps | grep avahi-publish-s | awk '{print $1}'"
command = 'ps aux | grep avahi-publish-s'
out_bytes = subprocess.check_output(command, shell=True, timeout=5)
out_str = out_bytes.decode('utf-8')
the_pid = re.findall(r'(\d+)\n', str(out_str))
for pid in the_pid:
service_info = [line for line in out_str.splitlines() if 'testxxx _testxxx._udp' in line]
for line in service_info:
print('Process:', line)
pid = line.split()[1]
command = 'kill -9 ' + pid
print('kill ', pid)
subprocess.call(command, shell=True, timeout=5)
time.sleep(1)