Add debug flag to virtio_input_test_util.

Add parameter "-d" that will show raw events, to assist with debugging.

Bug: MAC-213, MAC-214
Change-Id: Idcfa88ddfabed341ab417a426017d328683c9504
diff --git a/src/bin/virtio_input_test_util/main.rs b/src/bin/virtio_input_test_util/main.rs
index c27c88e..0637d24 100644
--- a/src/bin/virtio_input_test_util/main.rs
+++ b/src/bin/virtio_input_test_util/main.rs
@@ -22,8 +22,9 @@
     Err("Device closed while waiting for key press.".to_string())
 }
 
-fn run_keyboard_test(input_devices: &[&Path]) -> Result<(), String> {
-    // Create a EventReader object for each input file, each with its own thread, all sending to the channel `tx`.
+fn run_keyboard_test(input_devices: &[&Path], enable_debugging: bool) -> Result<(), String> {
+    // Create a EventReader object for each input file, each with its own thread, all sending to
+    // the channel `tx`.
     let (tx, rx) = mpsc::sync_channel(0);
     for path in input_devices.iter() {
         let mut reader = EventReader::new_from_path(path)
@@ -38,7 +39,11 @@
 
     // Wait for key strokes.
     println!("Type 'abc<shift>' to pass test.");
-    let mut iter = rx.iter();
+    let mut iter = rx.iter().inspect(|&x| {
+        if enable_debugging {
+            println!("{:?}", x);
+        }
+    });
     let codes = [
         KeyboardCode::A,
         KeyboardCode::B,
@@ -58,12 +63,18 @@
 fn main() -> Result<(), String> {
     // Parse command line arguments.
     let matches = clap::App::new("VirtIO Input Tester")
+        .arg(
+            clap::Arg::with_name("debug")
+                .short("d")
+                .help("Show debugging information."),
+        )
         .subcommand(
             clap::SubCommand::with_name("keyboard")
                 .about("runs a keyboard test")
                 .arg(clap::Arg::with_name("files").required(true).min_values(1)),
         )
         .get_matches();
+    let enable_debugging = matches.is_present("debug");
 
     // Run the user-specified command
     if let ("keyboard", Some(keyboard_matches)) = matches.subcommand() {
@@ -72,7 +83,7 @@
             .unwrap()
             .map(Path::new)
             .collect::<Vec<&Path>>();
-        run_keyboard_test(&files)
+        run_keyboard_test(&files, enable_debugging)
     } else {
         Err("Must provide a subcommand indicating which test to run.".to_string())
     }