File tree Expand file tree Collapse file tree
tests/utils/fixtures/target Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ __pycache__/
5757
5858# Rust
5959debug /
60- target /
60+ / target /
6161/build /
6262
6363* ~
Original file line number Diff line number Diff line change 1+ import pytest
2+ from typing import Optional , Any
3+ import logging
4+ from time import sleep
5+ from subprocess import PIPE , STDOUT
6+ from pathlib import Path
7+
8+ from itf .core .qemu .qemu import Qemu
9+
10+ logger = logging .getLogger (__name__ )
11+
12+ @pytest .fixture
13+ def target (request ) -> Optional [Any ]:
14+ """Returns the target instance
15+ """
16+
17+ # if no image provided then run natively
18+ if request .config .getoption ("--image-path" ) == "native" :
19+ yield None
20+ return None
21+
22+ logger .info ("Starting Target" )
23+ subprocess_params = {
24+ "stdin" : PIPE ,
25+ "stdout" : PIPE ,
26+ "stderr" : STDOUT ,
27+ }
28+
29+ image_location = Path (request .config .getoption ("--image-path" ))
30+
31+ if not image_location .is_file ():
32+ raise RuntimeError (f"No image found under { image_location } " )
33+
34+ qemu = Qemu (str (image_location ),
35+ host_first_network_device_ip_address = "192.168.100.1" )
36+
37+ _ = qemu .start (subprocess_params )
38+ sleep (2 ) # wait for system to boot
39+ yield qemu
40+ logger .info ("Closing Target" )
41+ qemu .stop ()
You can’t perform that action at this time.
0 commit comments