-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathqemu_run.py
More file actions
55 lines (44 loc) · 1.33 KB
/
Copy pathqemu_run.py
File metadata and controls
55 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import subprocess
import time
import signal
import sys
def run_west_qemu_with_signal_and_check(timeout=60):
west_build_command = [
"west",
"build",
"-t",
"run",
]
proc = subprocess.Popen(west_build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
test_success = False
start_time = time.time()
try:
for line in proc.stdout:
print(line, end='')
if "PROJECT EXECUTION SUCCESSFUL" in line:
test_success = True
break
elif "PROJECT EXECUTION FAILED" in line:
break
if time.time() - start_time > timeout:
print("\n⏰ Timeout reached, stopping QEMU...")
break
time.sleep(2)
proc.send_signal(signal.SIGINT)
proc.wait(timeout=5)
except subprocess.TimeoutExpired:
print("QEMU did not stop in time, killing...")
proc.kill()
except Exception as e:
print(f"Unexpected error: {e}")
proc.kill()
finally:
proc.stdout.close()
if test_success:
print("\n✅ Tests passed successfully!")
sys.exit(0)
else:
print("\n❌ Tests failed or no success message found.")
sys.exit(1)
if __name__ == "__main__":
run_west_qemu_with_signal_and_check()