@@ -51,6 +51,9 @@ fn main() {
51
51
}
52
52
53
53
fn spawn_emulator ( rootfs : & Path , tmpdir : & Path ) {
54
+ use std:: os:: unix:: io:: { FromRawFd , IntoRawFd } ;
55
+ use std:: fs:: OpenOptions ;
56
+
54
57
// Generate a new rootfs image now that we've updated the test server
55
58
// executable. This is the equivalent of:
56
59
//
@@ -71,6 +74,10 @@ fn spawn_emulator(rootfs: &Path, tmpdir: &Path) {
71
74
& mut t!( File :: create( & rootfs_img) ) ) ) ;
72
75
assert ! ( t!( child. wait( ) ) . success( ) ) ;
73
76
77
+ let log = OpenOptions :: new ( ) . create ( true ) . append ( true ) . open ( "qemu.log" ) . unwrap ( ) ;
78
+ let qout = unsafe { Stdio :: from_raw_fd ( log. try_clone ( ) . unwrap ( ) . into_raw_fd ( ) ) } ;
79
+ let qerr = unsafe { Stdio :: from_raw_fd ( log. try_clone ( ) . unwrap ( ) . into_raw_fd ( ) ) } ;
80
+
74
81
// Start up the emulator, in the background
75
82
let mut cmd = Command :: new ( "qemu-system-arm" ) ;
76
83
cmd. arg ( "-M" ) . arg ( "vexpress-a15" )
@@ -80,7 +87,8 @@ fn spawn_emulator(rootfs: &Path, tmpdir: &Path) {
80
87
. arg ( "-dtb" ) . arg ( "/tmp/vexpress-v2p-ca15-tc1.dtb" )
81
88
. arg ( "-append" ) . arg ( "console=ttyAMA0 root=/dev/ram rdinit=/sbin/init init=/sbin/init" )
82
89
. arg ( "-nographic" )
83
- . arg ( "-redir" ) . arg ( "tcp:12345::12345" ) ;
90
+ . arg ( "-redir" ) . arg ( "tcp:12345::12345" )
91
+ . stdout ( qout) . stderr ( qerr) ;
84
92
t ! ( cmd. spawn( ) ) ;
85
93
86
94
// Wait for the emulator to come online
0 commit comments