/// Uses the run_builder to start the fuzzer if it is not currently running; otherwise does
/// nothing. The URL is passed through test_manager and is opaque to this code.
Uses the run_builder to start the fuzzer if it is not currently running; otherwise does
nothing. The URL is passed through test_manager and is opaque to this code.
Uses the run_builder to start the fuzzer if it is not currently running ; otherwise does nothing . The URL is passed through test_manager and is opaque to this code .
pub async fn start(
        &mut self,
        run_builder: test_manager::RunBuilderProxy,
        fuzzer_url: &str,
        deadline: zx::Time,
    ) -> Result<(), zx::Status> {
        // Return immediately if already started; e.g. upon reconnect.
        if self.run_controller.is_some() {
            return Ok(());
        }
        // Add the test suite.
        let (suite_proxy, suite_controller) = create_proxy::<test_manager::SuiteControllerMarker>()
            .expect("failed to create suite_controller");
        let options = test_manager::RunOptions {
            log_iterator: Some(test_manager::LogsIteratorOption::ArchiveIterator),
            ..test_manager::RunOptions::EMPTY
        };
        run_builder.add_suite(fuzzer_url, options, suite_controller).map_err(|e| {
            fx_log_err!("failed to add test suite: {}", e);
            zx::Status::INTERNAL
        })?;
        // Build and execute the run.
        let (run_proxy, run_controller) = create_proxy::<test_manager::RunControllerMarker>()
            .expect("failed to create run_controller");
        run_builder.build(run_controller).map_err(|e| {
            fx_log_err!("failed to build test: {}", e);
            zx::Status::INTERNAL
        })?;
        self.run_controller = Some(run_proxy);
        // Bridge the diagnostics.
        self.bridged.clear();
        let (stdout_sender, stdout_bridge) = diagnostics::Bridge::create_socket_forwarder();
        self.bridged.push(stdout_bridge);
        let (stderr_sender, stderr_bridge) = diagnostics::Bridge::create_socket_forwarder();
        self.bridged.push(stderr_bridge);
        let (syslog_sender, syslog_bridge) = diagnostics::Bridge::create_archive_forwarder();
        self.bridged.push(syslog_bridge);
        // Wait for the test suite's single case to start.
        let (sender, receiver) = oneshot::channel::<zx::Status>();
        self.suite_event_handler = Some(fasync::Task::spawn(async move {
            // Errors will be communicated via the oneshot channel.
            let mut handler =
                events::SuiteEventHandler::new(stdout_sender, stderr_sender, syslog_sender);
            let _ = handler.handle(suite_proxy, sender).await;
        }));
        let result = receiver
            .on_timeout(deadline, || Err(oneshot::Canceled))
            .await
            .unwrap_or(zx::Status::CANCELED);
        let result = zx::Status::ok(result.into_raw());
        if result.is_err() {
            self.kill().await;
        }
        result
    }
pub async fn start ( & mut self , run_builder : test_manager :: RunBuilderProxy , fuzzer_url : & str , deadline : zx :: Time , ) -> Result < ( ) , zx :: Status > { // Return immediately if already started; e.g. upon reconnect. if self . run_controller . is_some ( ) { return Ok ( ( ) ) ; } // Add the test suite. let ( suite_proxy , suite_controller ) = create_proxy :: < test_manager :: SuiteControllerMarker > ( ) . expect ( " " ) ; let options = test_manager :: RunOptions { log_iterator : Some ( test_manager :: LogsIteratorOption :: ArchiveIterator ) , .. test_manager :: RunOptions :: EMPTY } ; run_builder . add_suite ( fuzzer_url , options , suite_controller ) . map_err ( | e | { fx_log_err ! ( " " e ) ; zx :: Status :: INTERNAL } ) ? ; // Build and execute the run. let ( run_proxy , run_controller ) = create_proxy :: < test_manager :: RunControllerMarker > ( ) . expect ( " " ) ; run_builder . build ( run_controller ) . map_err ( | e | { fx_log_err ! ( " " e ) ; zx :: Status :: INTERNAL } ) ? ; self . run_controller = Some ( run_proxy ) ; // Bridge the diagnostics. self . bridged . clear ( ) ; let ( stdout_sender , stdout_bridge ) = diagnostics :: Bridge :: create_socket_forwarder ( ) ; self . bridged . push ( stdout_bridge ) ; let ( stderr_sender , stderr_bridge ) = diagnostics :: Bridge :: create_socket_forwarder ( ) ; self . bridged . push ( stderr_bridge ) ; let ( syslog_sender , syslog_bridge ) = diagnostics :: Bridge :: create_archive_forwarder ( ) ; self . bridged . push ( syslog_bridge ) ; // Wait for the test suite's single case to start. let ( sender , receiver ) = oneshot :: channel :: < zx :: Status > ( ) ; self . suite_event_handler = Some ( fasync :: Task :: spawn ( async move { // Errors will be communicated via the oneshot channel. let mut handler = events :: SuiteEventHandler :: new ( stdout_sender , stderr_sender , syslog_sender ) ; let _ = handler . handle ( suite_proxy , sender ) . await ; } ) ) ; let result = receiver . on_timeout ( deadline , | | Err ( oneshot :: Canceled ) ) . await . unwrap_or ( zx :: Status :: CANCELED ) ; let result = zx :: Status :: ok ( result . into_raw ( ) ) ; if result . is_err ( ) { self . kill ( ) . await ; } result }
Uses the run_builder to start the fuzzer if it is not currently running; otherwise does
nothing.
Uses the run_builder to start the fuzzer if it is not currently running ; otherwise does nothing .
&mut self
run_builder
test_manager::RunBuilderProxy
fuzzer_url
&str
deadline
zx::Time