Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 898fcaee authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add tests to verify clap command." am: 9a5ea1dc am: f709374d am: 2933b7a4

parents 6feb7864 2933b7a4
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -43,6 +43,25 @@ rust_binary {
    ],
}

rust_test {
    name: "bluetooth_with_facades.test",
    defaults: ["gd_rust_defaults"],
    srcs: ["src/main.rs"],
    edition: "2018",
    rustlibs: [
      "libclap",
      "libbluetooth_with_facades",
      "libfutures",
      "libgrpcio",
      "liblazy_static",
      "libtokio",
      "libnix",
      "libbt_common",
      "liblog_rust",
    ],
    test_suites: ["general-tests"],
}

rust_library {
    name: "libbt_facade_helpers",
    defaults: ["gd_rust_defaults"],
+16 −3
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ fn main() {
    rt.block_on(async_main(Arc::clone(&rt), sigint));
}

async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
    let matches = Command::new("bluetooth_with_facades")
fn clap_command() -> Command {
    Command::new("bluetooth_with_facades")
        .about("The bluetooth stack, with testing facades enabled and exposed via gRPC.")
        .arg(
            Arg::new("root-server-port")
@@ -44,7 +44,10 @@ async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
        .arg(Arg::new("btsnoop").long("btsnoop"))
        .arg(Arg::new("btsnooz").long("btsnooz"))
        .arg(Arg::new("btconfig").long("btconfig"))
        .get_matches();
}

async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
    let matches = clap_command().get_matches();

    let root_server_port = *matches.get_one::<u16>("root-server-port").unwrap();
    let grpc_port = *matches.get_one::<u16>("grpc-port").unwrap();
@@ -95,3 +98,13 @@ extern "C" fn handle_sigint(_: i32) {
    }
    *sigint_tx = None;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn verify_comand() {
        clap_command().debug_assert();
    }
}
+13 −2
Original line number Diff line number Diff line
@@ -7,8 +7,8 @@ package {
    default_applicable_licenses: ["system_bt_license"],
}

rust_binary_host {
    name: "bt_topshim_facade",
rust_defaults {
    name: "bt_topshim_facade.defaults",
    defaults: [
        "gd_rust_defaults",
        "libchrome_support_defaults"
@@ -84,3 +84,14 @@ rust_binary_host {
        "libpaste",
    ],
}

rust_binary_host {
    name: "bt_topshim_facade",
    defaults: ["bt_topshim_facade.defaults"],
}

rust_test_host {
    name: "bt_topshim_facade.test",
    defaults: ["bt_topshim_facade.defaults"],
    test_suites: ["general-tests"],
}
+16 −3
Original line number Diff line number Diff line
@@ -40,8 +40,8 @@ fn main() {
    rt.block_on(async_main(Arc::clone(&rt), sigint));
}

async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
    let matches = Command::new("bluetooth_topshim_facade")
fn clap_command() -> Command {
    Command::new("bluetooth_topshim_facade")
        .about("The bluetooth topshim stack, with testing facades enabled and exposed via gRPC.")
        .arg(
            Arg::new("grpc-port")
@@ -71,7 +71,10 @@ async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
                .value_parser(value_parser!(bool))
                .default_value("true"),
        )
        .get_matches();
}

async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
    let matches = clap_command().get_matches();

    let grpc_port = *matches.get_one::<u16>("grpc-port").unwrap();
    let _rootcanal_port = matches.get_one::<u16>("rootcanal-port").cloned();
@@ -146,3 +149,13 @@ extern "C" fn handle_sigint(_: i32) {
    }
    *sigint_tx = None;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn verify_comand() {
        clap_command().debug_assert();
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -83,3 +83,14 @@ fn main() -> std::process::ExitCode {
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use clap::CommandFactory;

    #[test]
    fn verify_opt() {
        Opt::command().debug_assert();
    }
}