@@ -18,55 +18,29 @@ import logging
1818import os , sys
1919sys .path .append (f'{ os .path .dirname (sys .argv [0 ])} /../../lib' )
2020
21- from qemu import qemu_command , qemu_net_setup
22- from pexpect_utils import *
23- from utils import *
21+ from qemu import QemuConfig , qemu_main , qemu_monitor_shutdown
22+ from utils import setup_logging
2423
2524
2625def main ():
2726 setup_logging ()
28- setup_timeout (60 )
2927
30- expected_release = get_expected_release ()
31- if expected_release is None :
32- return False
28+ qconf = QemuConfig ('bamboo' )
29+ qconf .configure_from_env ()
30+ qconf .configure_from_args (sys .argv [1 :])
31+ qconf .net_tests = False
32+ qconf .smp = 1
3333
34- vmlinux = get_vmlinux ()
35- if vmlinux is None :
36- return False
34+ def shutdown (p ):
35+ p .send ('poweroff' )
36+ p .expect ('System Halted, OK to turn off power' )
37+ qemu_monitor_shutdown (p )
3738
38- p = PexpectHelper ()
39- cmd = qemu_command (qemu = 'qemu-system-ppc' , machine = 'bamboo' , vmlinux = vmlinux ,
40- cmdline = 'noreboot' )
41- p .spawn (cmd , logfile = open ('console.log' , 'w' ))
39+ qconf .shutdown = shutdown
4240
43- standard_boot ( p )
41+ qconf . apply_defaults ( )
4442
45- p .send ("echo -n 'booted-revision: '; uname -r" )
46- p .expect (f'booted-revision: { expected_release } ' )
47- p .expect_prompt ()
48-
49- p .send ('cat /proc/cpuinfo' )
50- p .expect ("PowerPC 44x Platform" )
51- p .expect_prompt ()
52-
53- if os .environ .get ('QEMU_NET_TESTS' , True ) != '0' :
54- qemu_net_setup (p )
55- ping_test (p , check = False )
56- wget_test (p )
57-
58- p .send ('echo o > /proc/sysrq-trigger' )
59- p .expect ('System Halted, OK to turn off power' )
60-
61- p .terminate ()
62-
63- if filter_log_warnings (open ('console.log' ), open ('warnings.txt' , 'w' )):
64- logging .error ('Errors/warnings seen in console.log' )
65- return False
66-
67- logging .info ('Test completed OK' )
68-
69- return True
43+ return qemu_main (qconf )
7044
7145
7246sys .exit (0 if main () else 1 )
0 commit comments