Subversion Repositories Kolibri OS

Rev

Rev 9254 | Rev 9256 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9254 Rev 9255
Line 20... Line 20...
20
    def __init__(self, popen):
20
    def __init__(self, popen):
21
        self.popen = popen
21
        self.popen = popen
22
        # Qemu needs time to create debug.log file
22
        # Qemu needs time to create debug.log file
23
        while not os.path.exists("debug.log"):
23
        while not os.path.exists("debug.log"):
24
            self.wait()
24
            self.wait()
-
 
25
        self.debug = open("debug.log", "rb")
-
 
26
        self.monitor_in = open("monitor.pipe.in", "wb")
Line 25... Line 27...
25
 
27
 
26
    def wait_for_debug_log(self, needle, timeout = 1):
28
    def wait_for_debug_log(self, needle, timeout = 1):
27
        needle = bytes(needle, "utf-8")
29
        needle = bytes(needle, "utf-8")
28
        start = timeit.default_timer()
-
 
29
        stdout = open("debug.log", "rb")
30
        start = timeit.default_timer()
Line 30... Line 31...
30
        log = b""
31
        log = b""
31
 
32
 
32
        # While no timeout, read and search logs
33
        # While no timeout, read and search logs
33
        while timeit.default_timer() - start < timeout:
34
        while timeit.default_timer() - start < timeout:
34
            log += stdout.read(1)
35
            log += self.debug.read(1)
Line 35... Line 36...
35
            if needle in log:
36
            if needle in log:
36
                return
37
                return
Line 60... Line 61...
60
        raise TestTimeoutException()
61
        raise TestTimeoutException()
Line 61... Line 62...
61
 
62
 
62
    def wait(self, seconds = 0.25):
63
    def wait(self, seconds = 0.25):
Line -... Line 64...
-
 
64
        time.sleep(seconds)
-
 
65
 
-
 
66
    def send_keys(self, keys):
-
 
67
        for key in keys.split():
-
 
68
            self.send_monitor_command(f"sendkey {key}")
-
 
69
 
-
 
70
    def send_monitor_command(self, command):
-
 
71
        self.monitor_in.write(bytes(command + "\n", "utf-8"))
63
        time.sleep(seconds)
72
        self.monitor_in.flush()
-
 
73
 
64
 
74
def run():
-
 
75
    if os.path.exists("debug.log"):
-
 
76
        os.remove("debug.log")
-
 
77
    if os.path.exists("monitor.pipe.in"):
-
 
78
        os.remove("monitor.pipe.in")
-
 
79
    if os.path.exists("monitor.pipe.out"):
65
def run():
80
        os.remove("monitor.pipe.out")
66
    os.remove("debug.log")
81
    os.system("mkfifo monitor.pipe.in monitor.pipe.out")
67
    s = f"qemu-system-i386 -nographic -L . -m 128 -drive format=raw,file=../../kolibri_test.img,index=0,if=floppy -boot a -vga vmware -net nic,model=rtl8139 -net user -soundhw ac97 -debugcon file:debug.log"
82
    s = f"qemu-system-i386 -nographic -monitor pipe:monitor.pipe -debugcon file:debug.log -L . -m 128 -drive format=raw,file=../../kolibri_test.img,index=0,if=floppy -boot a -vga vmware -net nic,model=rtl8139 -net user -soundhw ac97"
68
    a = shlex.split(s)
83
    a = shlex.split(s)