From 1512d2138e42cce15f2e15042ebfbaacd46fd9af Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 28 Jul 2020 13:35:15 +0800 Subject: [PATCH] kernel: tests: remove excess prints Signed-off-by: Sean Cross --- kernel/src/arch/hosted.rs | 35 ++++++++++++++++++----------------- kernel/src/test.rs | 9 ++++----- xous-rs/src/arch/hosted.rs | 12 ++++++------ 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/kernel/src/arch/hosted.rs b/kernel/src/arch/hosted.rs index 1ad83ad9b..9b7acd67d 100644 --- a/kernel/src/arch/hosted.rs +++ b/kernel/src/arch/hosted.rs @@ -174,7 +174,7 @@ fn listen_thread( chn: Sender, mut local_addr_sender: Option>, new_pid_channel: Receiver, - exit_channel: Receiver + exit_channel: Receiver, ) { let should_exit = std::sync::Arc::new(core::sync::atomic::AtomicBool::new(false)); @@ -209,7 +209,8 @@ fn listen_thread( access_key, )) .expect("couldn't request a new PID"); - let NewPidMessage::NewPid(new_pid) = new_pid_channel.recv() + let NewPidMessage::NewPid(new_pid) = new_pid_channel + .recv() .expect("couldn't receive message from main thread"); // println!("KERNEL({}): New client connected from {}", new_pid, _addr); let conn_copy = conn.try_clone().expect("couldn't duplicate connection"); @@ -257,15 +258,12 @@ fn listen_thread( } } }); - spawn(move || loop { - match exit_channel.recv() { - Ok(ExitMessage::Exit) => { - exit_sender.send(ClientMessage::Exit).unwrap(); - } - Err(e) => { - println!("error receiving exit command: {}", e); - return; - } + spawn(move || match exit_channel.recv() { + Ok(ExitMessage::Exit) => { + exit_sender.send(ClientMessage::Exit).unwrap() + } + Err(std::sync::mpsc::RecvError) => { + println!("error receiving exit command") } }); @@ -276,7 +274,7 @@ fn listen_thread( exit_server(should_exit, clients); return; } - }, + } ClientMessage::Exit => { exit_server(should_exit, clients); return; @@ -353,7 +351,7 @@ pub fn idle() -> bool { // This is because the "process" will be "terminated" (the network socket will be closed), // and we won't be able to send the response after we're done. if is_shutdown { - println!("KERNEL: Detected shutdown -- sending final \"Ok\" to the client"); + // println!("KERNEL: Detected shutdown -- sending final \"Ok\" to the client"); let mut process = Process::current(); let mut response_vec = Vec::new(); response_vec.extend_from_slice(&thread_id.to_le_bytes()); @@ -362,10 +360,13 @@ pub fn idle() -> bool { } process.send(&response_vec).unwrap_or_else(|_e| { // If we're unable to send data to the process, assume it's dead and terminate it. - println!("Unable to send response to process: {:?} -- terminating", _e); + println!( + "Unable to send response to process: {:?} -- terminating", + _e + ); crate::syscall::handle(pid, thread_id, SysCall::TerminateProcess).ok(); }); - println!("KERNEL: Done sending"); + // println!("KERNEL: Done sending"); } // Handle the syscall within the Xous kernel @@ -412,11 +413,11 @@ pub fn idle() -> bool { } } - println!("Exiting Xous because the listen thread channel has closed. Waiting for thread to finish..."); + // println!("Exiting Xous because the listen thread channel has closed. Waiting for thread to finish..."); listen_thread_handle .join() .expect("error waiting for listen thread to return"); - println!("Thank you for using Xous!"); + // println!("Thank you for using Xous!"); false } diff --git a/kernel/src/test.rs b/kernel/src/test.rs index 5de151db0..0d340e89e 100644 --- a/kernel/src/test.rs +++ b/kernel/src/test.rs @@ -25,7 +25,7 @@ fn start_kernel(server_spec: &str) -> JoinHandle<()> { "XOUS_SERVER environment variable must be unset to run tests" ); - use rand::{Rng, thread_rng}; + use rand::{thread_rng, Rng}; let mut pid1_key = [0u8; 16]; let mut rng = thread_rng(); for b in pid1_key.iter_mut() { @@ -97,10 +97,9 @@ fn shutdown() { // Send a raw `Shutdown` message to terminate the kernel. xous::create_process(xous::ProcessArgs::new(|| { - println!("Running in new process..."); - let call_result = rsyscall(SysCall::Shutdown); - println!("Call result: {:?}", call_result); - })).unwrap(); + rsyscall(SysCall::Shutdown).unwrap(); + })) + .unwrap(); // Wait for the kernel to exit. main_thread.join().expect("couldn't join main thread"); diff --git a/xous-rs/src/arch/hosted.rs b/xous-rs/src/arch/hosted.rs index a5db34b5d..e763cd525 100644 --- a/xous-rs/src/arch/hosted.rs +++ b/xous-rs/src/arch/hosted.rs @@ -258,7 +258,7 @@ fn xous_connect_impl( addr: SocketAddr, key: &[u8; 16], ) -> core::result::Result { - eprintln!("Opening connection to Xous server @ {} with key {:?}...", addr, key); + // eprintln!("Opening connection to Xous server @ {} with key {:?}...", addr, key); assert_ne!(key, &[0u8; 16]); match TcpStream::connect(addr) { Ok(mut conn) => { @@ -374,7 +374,7 @@ fn _xous_syscall_result( let response = Result::from_args(pkt); - println!(" Response: {:?}", response); + // println!(" Response: {:?}", response); if Result::BlockedProcess == response { // println!(" Waiting again"); continue; @@ -455,10 +455,10 @@ fn _xous_syscall_to( call: &crate::SysCall, xsc: &mut TcpStream, ) { - println!( - "Making Syscall: {:?}", - crate::SysCall::from_args(nr, a1, a2, a3, a4, a5, a6, a7).unwrap() - ); + // println!( + // "Making Syscall: {:?}", + // crate::SysCall::from_args(nr, a1, a2, a3, a4, a5, a6, a7).unwrap() + // ); // Send the packet to the server let mut pkt = vec![];