kernel: tests: remove excess prints

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-07-28 13:35:15 +08:00
parent 19222c34a9
commit 1512d2138e
3 changed files with 28 additions and 28 deletions

View file

@ -174,7 +174,7 @@ fn listen_thread(
chn: Sender<ThreadMessage>, chn: Sender<ThreadMessage>,
mut local_addr_sender: Option<Sender<SocketAddr>>, mut local_addr_sender: Option<Sender<SocketAddr>>,
new_pid_channel: Receiver<NewPidMessage>, new_pid_channel: Receiver<NewPidMessage>,
exit_channel: Receiver<ExitMessage> exit_channel: Receiver<ExitMessage>,
) { ) {
let should_exit = std::sync::Arc::new(core::sync::atomic::AtomicBool::new(false)); let should_exit = std::sync::Arc::new(core::sync::atomic::AtomicBool::new(false));
@ -209,7 +209,8 @@ fn listen_thread(
access_key, access_key,
)) ))
.expect("couldn't request a new PID"); .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"); .expect("couldn't receive message from main thread");
// println!("KERNEL({}): New client connected from {}", new_pid, _addr); // println!("KERNEL({}): New client connected from {}", new_pid, _addr);
let conn_copy = conn.try_clone().expect("couldn't duplicate connection"); let conn_copy = conn.try_clone().expect("couldn't duplicate connection");
@ -257,15 +258,12 @@ fn listen_thread(
} }
} }
}); });
spawn(move || loop { spawn(move || match exit_channel.recv() {
match exit_channel.recv() { Ok(ExitMessage::Exit) => {
Ok(ExitMessage::Exit) => { exit_sender.send(ClientMessage::Exit).unwrap()
exit_sender.send(ClientMessage::Exit).unwrap(); }
} Err(std::sync::mpsc::RecvError) => {
Err(e) => { println!("error receiving exit command")
println!("error receiving exit command: {}", e);
return;
}
} }
}); });
@ -276,7 +274,7 @@ fn listen_thread(
exit_server(should_exit, clients); exit_server(should_exit, clients);
return; return;
} }
}, }
ClientMessage::Exit => { ClientMessage::Exit => {
exit_server(should_exit, clients); exit_server(should_exit, clients);
return; return;
@ -353,7 +351,7 @@ pub fn idle() -> bool {
// This is because the "process" will be "terminated" (the network socket will be closed), // 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. // and we won't be able to send the response after we're done.
if is_shutdown { 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 process = Process::current();
let mut response_vec = Vec::new(); let mut response_vec = Vec::new();
response_vec.extend_from_slice(&thread_id.to_le_bytes()); 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| { 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. // 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(); crate::syscall::handle(pid, thread_id, SysCall::TerminateProcess).ok();
}); });
println!("KERNEL: Done sending"); // println!("KERNEL: Done sending");
} }
// Handle the syscall within the Xous kernel // 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 listen_thread_handle
.join() .join()
.expect("error waiting for listen thread to return"); .expect("error waiting for listen thread to return");
println!("Thank you for using Xous!"); // println!("Thank you for using Xous!");
false false
} }

View file

@ -25,7 +25,7 @@ fn start_kernel(server_spec: &str) -> JoinHandle<()> {
"XOUS_SERVER environment variable must be unset to run tests" "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 pid1_key = [0u8; 16];
let mut rng = thread_rng(); let mut rng = thread_rng();
for b in pid1_key.iter_mut() { for b in pid1_key.iter_mut() {
@ -97,10 +97,9 @@ fn shutdown() {
// Send a raw `Shutdown` message to terminate the kernel. // Send a raw `Shutdown` message to terminate the kernel.
xous::create_process(xous::ProcessArgs::new(|| { xous::create_process(xous::ProcessArgs::new(|| {
println!("Running in new process..."); rsyscall(SysCall::Shutdown).unwrap();
let call_result = rsyscall(SysCall::Shutdown); }))
println!("Call result: {:?}", call_result); .unwrap();
})).unwrap();
// Wait for the kernel to exit. // Wait for the kernel to exit.
main_thread.join().expect("couldn't join main thread"); main_thread.join().expect("couldn't join main thread");

View file

@ -258,7 +258,7 @@ fn xous_connect_impl(
addr: SocketAddr, addr: SocketAddr,
key: &[u8; 16], key: &[u8; 16],
) -> core::result::Result<ServerConnection, ()> { ) -> core::result::Result<ServerConnection, ()> {
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]); assert_ne!(key, &[0u8; 16]);
match TcpStream::connect(addr) { match TcpStream::connect(addr) {
Ok(mut conn) => { Ok(mut conn) => {
@ -374,7 +374,7 @@ fn _xous_syscall_result(
let response = Result::from_args(pkt); let response = Result::from_args(pkt);
println!(" Response: {:?}", response); // println!(" Response: {:?}", response);
if Result::BlockedProcess == response { if Result::BlockedProcess == response {
// println!(" Waiting again"); // println!(" Waiting again");
continue; continue;
@ -455,10 +455,10 @@ fn _xous_syscall_to(
call: &crate::SysCall, call: &crate::SysCall,
xsc: &mut TcpStream, xsc: &mut TcpStream,
) { ) {
println!( // println!(
"Making Syscall: {:?}", // "Making Syscall: {:?}",
crate::SysCall::from_args(nr, a1, a2, a3, a4, a5, a6, a7).unwrap() // crate::SysCall::from_args(nr, a1, a2, a3, a4, a5, a6, a7).unwrap()
); // );
// Send the packet to the server // Send the packet to the server
let mut pkt = vec![]; let mut pkt = vec![];