summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2018-10-03 10:22:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-09 21:14:05 -0700
commit55a9e504beef368bd97e51ffd5a7fa6c034eb8ad (patch)
tree894d8685e2fdfa105ea35d1cb6cfceee06502c7a /tests
parent046df60760f3b0691f23c27a7f24a96c9afe8c05 (diff)
downloadcrosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.gz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.bz2
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.lz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.xz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.zst
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.zip
cargo fmt all source code
Now that cargo fmt has landed, run it over everything at once to bring
rust source to the standard formatting.

TEST=cargo test
BUG=None

Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b
Reviewed-on: https://chromium-review.googlesource.com/1259287
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/plugins.rs87
1 files changed, 44 insertions, 43 deletions
diff --git a/tests/plugins.rs b/tests/plugins.rs
index 67e68e6..27bbc47 100644
--- a/tests/plugins.rs
+++ b/tests/plugins.rs
@@ -9,17 +9,17 @@ extern crate sys_util;
 
 use rand::{thread_rng, Rng};
 
-use std::ffi::OsString;
-use std::fs::{File, remove_file};
-use std::io::{Write, Read};
 use std::env::{current_exe, var_os};
+use std::ffi::OsString;
+use std::fs::{remove_file, File};
+use std::io::{Read, Write};
+use std::os::unix::io::AsRawFd;
 use std::path::{Path, PathBuf};
 use std::process::{Command, Stdio};
 use std::thread::sleep;
-use std::os::unix::io::AsRawFd;
 use std::time::Duration;
 
-use sys_util::{SharedMemory, ioctl};
+use sys_util::{ioctl, SharedMemory};
 
 struct RemovePath(PathBuf);
 impl Drop for RemovePath {
@@ -34,32 +34,27 @@ fn get_target_path() -> PathBuf {
     current_exe()
         .ok()
         .map(|mut path| {
-                 path.pop();
-                 path
-             })
-        .expect("failed to get crosvm binary directory")
+            path.pop();
+            path
+        }).expect("failed to get crosvm binary directory")
 }
 
 fn get_crosvm_path() -> PathBuf {
     current_exe()
         .ok()
         .map(|mut path| {
-                 path.pop();
-                 if path.ends_with("deps") {
-                     path.pop();
-                 }
-                 path
-             })
-        .expect("failed to get crosvm binary directory")
+            path.pop();
+            if path.ends_with("deps") {
+                path.pop();
+            }
+            path
+        }).expect("failed to get crosvm binary directory")
 }
 
 fn build_plugin(src: &str) -> RemovePath {
     let libcrosvm_plugin_dir = get_target_path();
     let mut out_bin = libcrosvm_plugin_dir.clone();
-    out_bin.push(thread_rng()
-                     .gen_ascii_chars()
-                     .take(10)
-                     .collect::<String>());
+    out_bin.push(thread_rng().gen_ascii_chars().take(10).collect::<String>());
     let mut child = Command::new(var_os("CC").unwrap_or(OsString::from("cc")))
         .args(&["-Icrosvm_plugin", "-pthread", "-o"]) // crosvm.h location and set output path.
         .arg(&out_bin)
@@ -90,21 +85,24 @@ fn run_plugin(bin_path: &Path, with_sandbox: bool) {
     let mut crosvm_path = get_crosvm_path();
     crosvm_path.push("crosvm");
     let mut cmd = Command::new(crosvm_path);
-    cmd.args(&["run",
-                "-c",
-                "1",
-                "--host_ip",
-                "100.115.92.5",
-                "--netmask",
-                "255.255.255.252",
-                "--mac",
-                "de:21:e8:47:6b:6a",
-                "--seccomp-policy-dir",
-                "tests",
-                "--plugin"])
-        .arg(bin_path
-                 .canonicalize()
-                 .expect("failed to canonicalize plugin path"));
+    cmd.args(&[
+        "run",
+        "-c",
+        "1",
+        "--host_ip",
+        "100.115.92.5",
+        "--netmask",
+        "255.255.255.252",
+        "--mac",
+        "de:21:e8:47:6b:6a",
+        "--seccomp-policy-dir",
+        "tests",
+        "--plugin",
+    ]).arg(
+        bin_path
+            .canonicalize()
+            .expect("failed to canonicalize plugin path"),
+    );
     if !with_sandbox {
         cmd.arg("--disable-sandbox");
     }
@@ -204,20 +202,23 @@ impl Default for MiniPlugin {
 fn test_mini_plugin(plugin: &MiniPlugin) {
     // Adds a preamble to ensure the output opcodes are 16-bit real mode and the lables start at the
     // load address.
-    let assembly_src = format!("org 0x{:x}\nbits 16\n{}",
-                               plugin.load_address,
-                               plugin.assembly_src);
+    let assembly_src = format!(
+        "org 0x{:x}\nbits 16\n{}",
+        plugin.load_address, plugin.assembly_src
+    );
 
     // Builds the assembly and convert it to a C literal array format.
     let assembly = build_assembly(&assembly_src);
     let assembly_hex = format_as_hex(&assembly);
 
     // Glues the pieces of this plugin together and tests the completed plugin.
-    let generated_src = format!(include_str!("mini_plugin_template.c"),
-                                mem_size = plugin.mem_size,
-                                load_address = plugin.load_address,
-                                assembly_code = assembly_hex,
-                                src = plugin.src);
+    let generated_src = format!(
+        include_str!("mini_plugin_template.c"),
+        mem_size = plugin.mem_size,
+        load_address = plugin.load_address,
+        assembly_code = assembly_hex,
+        src = plugin.src
+    );
     test_plugin(&generated_src);
 }