From 4acf7a88ba7e81b7b08e5716df551697f15e8779 Mon Sep 17 00:00:00 2001 From: Joe Ranweiler Date: Wed, 6 Jul 2022 21:24:45 +0000 Subject: [PATCH] Remove stubbed support for macOS builds --- src/agent/coverage/examples/coverage.rs | 10 ----- .../coverage/examples/elf_sancov_tables.rs | 5 --- .../coverage/examples/pdb_sancov_tables.rs | 5 --- src/agent/coverage/examples/src-cov.rs | 10 ----- .../src/bin/dynamic-library.rs | 6 --- src/agent/onefuzz-agent/src/worker.rs | 2 +- src/agent/onefuzz-task/src/managed/cmd.rs | 9 ----- src/agent/onefuzz/examples/memory.rs | 6 --- src/agent/onefuzz/src/input_tester.rs | 9 ----- src/agent/onefuzz/src/libfuzzer.rs | 6 --- src/agent/onefuzz/src/machine_id.rs | 40 ------------------- src/agent/onefuzz/src/memory.rs | 1 - src/agent/onefuzz/src/monitor.rs | 1 - 13 files changed, 1 insertion(+), 109 deletions(-) diff --git a/src/agent/coverage/examples/coverage.rs b/src/agent/coverage/examples/coverage.rs index 41db38994f..227579b10c 100644 --- a/src/agent/coverage/examples/coverage.rs +++ b/src/agent/coverage/examples/coverage.rs @@ -94,16 +94,6 @@ fn input_command(argv: &[String], input: &Path) -> Command { cmd } -#[cfg(target_os = "macos")] -fn record( - _cache: &mut ModuleCache, - _filter: CmdFilter, - _cmd: Command, - _timeout: Duration, -) -> Result { - unimplemented!("coverage recording is not supported on macOS"); -} - #[cfg(target_os = "linux")] fn record( cache: &mut ModuleCache, diff --git a/src/agent/coverage/examples/elf_sancov_tables.rs b/src/agent/coverage/examples/elf_sancov_tables.rs index 867f04ff85..c578f27619 100644 --- a/src/agent/coverage/examples/elf_sancov_tables.rs +++ b/src/agent/coverage/examples/elf_sancov_tables.rs @@ -16,11 +16,6 @@ struct Opt { inline: bool, } -#[cfg(target_os = "macos")] -fn main() -> Result<()> { - Ok(()) -} - #[cfg(target_os = "windows")] fn main() -> Result<()> { Ok(()) diff --git a/src/agent/coverage/examples/pdb_sancov_tables.rs b/src/agent/coverage/examples/pdb_sancov_tables.rs index a58a9f8c99..7ac4b03aff 100644 --- a/src/agent/coverage/examples/pdb_sancov_tables.rs +++ b/src/agent/coverage/examples/pdb_sancov_tables.rs @@ -43,8 +43,3 @@ fn main() -> Result<()> { fn main() -> Result<()> { Ok(()) } - -#[cfg(target_os = "macos")] -fn main() -> Result<()> { - Ok(()) -} diff --git a/src/agent/coverage/examples/src-cov.rs b/src/agent/coverage/examples/src-cov.rs index 323e86f11d..3e8dba1586 100644 --- a/src/agent/coverage/examples/src-cov.rs +++ b/src/agent/coverage/examples/src-cov.rs @@ -93,16 +93,6 @@ fn input_command(argv: &[String], input: &Path) -> Command { cmd } -#[cfg(target_os = "macos")] -fn record( - _cache: &mut ModuleCache, - _filter: CmdFilter, - _cmd: Command, - _timeout: Duration, -) -> Result { - unimplemented!("coverage recording is not supported on macOS"); -} - #[cfg(target_os = "linux")] fn record( cache: &mut ModuleCache, diff --git a/src/agent/dynamic-library/src/bin/dynamic-library.rs b/src/agent/dynamic-library/src/bin/dynamic-library.rs index 81a0a098e3..cfdcab5b22 100644 --- a/src/agent/dynamic-library/src/bin/dynamic-library.rs +++ b/src/agent/dynamic-library/src/bin/dynamic-library.rs @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#![cfg_attr(target_os = "macos", allow(unused, warnings))] use std::process::{Command, Stdio}; @@ -67,8 +66,3 @@ fn find_missing(cmd: Command) -> Result> { .map(|m| m.name) .collect()) } - -#[cfg(target_os = "macos")] -fn find_missing(cmd: Command) -> Result> { - todo!() -} diff --git a/src/agent/onefuzz-agent/src/worker.rs b/src/agent/onefuzz-agent/src/worker.rs index 525c8bca3d..0751a8b9e6 100644 --- a/src/agent/onefuzz-agent/src/worker.rs +++ b/src/agent/onefuzz-agent/src/worker.rs @@ -256,7 +256,7 @@ impl SuspendableChild for Child { } } -#[cfg(any(target_os = "linux", target_os = "macos"))] +#[cfg(target_os = "linux")] impl SuspendableChild for Child { fn suspend(&mut self) -> Result<()> { use nix::sys::signal; diff --git a/src/agent/onefuzz-task/src/managed/cmd.rs b/src/agent/onefuzz-task/src/managed/cmd.rs index 21374cc5c3..9f76e2f38c 100644 --- a/src/agent/onefuzz-task/src/managed/cmd.rs +++ b/src/agent/onefuzz-task/src/managed/cmd.rs @@ -12,7 +12,6 @@ use crate::tasks::{ task_logger, }; -#[cfg(not(target_os = "macos"))] const OOM_CHECK_INTERVAL: Duration = Duration::from_secs(5); pub async fn run(args: &clap::ArgMatches<'_>) -> Result<()> { @@ -65,7 +64,6 @@ pub async fn run(args: &clap::ArgMatches<'_>) -> Result<()> { result } -#[cfg(not(target_os = "macos"))] const MAX_OOM_QUERY_ERRORS: usize = 5; // Periodically check available system memory. @@ -73,7 +71,6 @@ const MAX_OOM_QUERY_ERRORS: usize = 5; // If available memory drops below the minimum, exit informatively. // // Parameterized to enable future configuration by VMSS. -#[cfg(not(target_os = "macos"))] async fn out_of_memory(min_bytes: u64) -> Result { if min_bytes == 0 { bail!("available memory minimum is unreachable"); @@ -109,12 +106,6 @@ async fn out_of_memory(min_bytes: u64) -> Result { } } -#[cfg(target_os = "macos")] -async fn out_of_memory(_min_bytes: u64) -> Result { - // Resolve immediately. - bail!("out-of-memory check not implemented on macOS") -} - struct OutOfMemory { available_bytes: u64, min_bytes: u64, diff --git a/src/agent/onefuzz/examples/memory.rs b/src/agent/onefuzz/examples/memory.rs index 59937fa735..dc370cb429 100644 --- a/src/agent/onefuzz/examples/memory.rs +++ b/src/agent/onefuzz/examples/memory.rs @@ -1,11 +1,5 @@ -#[cfg(not(target_os = "macos"))] fn main() { let bytes = onefuzz::memory::available_bytes().unwrap(); let gb = (bytes as f64) * 1e-9; println!("available bytes: {} ({:.1} GB)", bytes, gb); } - -#[cfg(target_os = "macos")] -fn main() { - unimplemented!() -} diff --git a/src/agent/onefuzz/src/input_tester.rs b/src/agent/onefuzz/src/input_tester.rs index 0dc161b587..6eb9e0a655 100644 --- a/src/agent/onefuzz/src/input_tester.rs +++ b/src/agent/onefuzz/src/input_tester.rs @@ -196,15 +196,6 @@ impl<'a> Tester<'a> { Ok(crash) } - #[cfg(target_os = "macos")] - async fn test_input_debugger( - &self, - _args: Vec, - _env: HashMap, - ) -> Result> { - bail!("running application under a debugger is not supported on macOS"); - } - #[cfg(target_os = "linux")] async fn test_input_debugger( &self, diff --git a/src/agent/onefuzz/src/libfuzzer.rs b/src/agent/onefuzz/src/libfuzzer.rs index 31303988cf..a45a25bd23 100644 --- a/src/agent/onefuzz/src/libfuzzer.rs +++ b/src/agent/onefuzz/src/libfuzzer.rs @@ -254,7 +254,6 @@ impl<'a> LibFuzzer<'a> { Ok(()) } - #[cfg(not(target_os = "macos"))] async fn find_missing_libraries(&self) -> Result> { let cmd = self.build_std_command(None, None, None).await?; @@ -270,11 +269,6 @@ impl<'a> LibFuzzer<'a> { Ok(missing) } - #[cfg(target_os = "macos")] - async fn find_missing_libraries(&self) -> Result> { - todo!() - } - pub async fn fuzz( &self, fault_dir: impl AsRef, diff --git a/src/agent/onefuzz/src/machine_id.rs b/src/agent/onefuzz/src/machine_id.rs index 9e42a0242f..33b222776d 100644 --- a/src/agent/onefuzz/src/machine_id.rs +++ b/src/agent/onefuzz/src/machine_id.rs @@ -6,12 +6,8 @@ use anyhow::{Context, Result}; use reqwest_retry::SendRetry; #[cfg(target_os = "linux")] use std::path::Path; -#[cfg(target_os = "macos")] -use std::process::Stdio; use std::time::Duration; use tokio::fs; -#[cfg(target_os = "macos")] -use tokio::process::Command; use uuid::Uuid; // https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service#tracking-vm-running-on-azure @@ -116,42 +112,6 @@ pub async fn get_os_machine_id() -> Result { Ok(Uuid::parse_str(&guid)?) } -#[cfg(target_os = "macos")] -pub async fn get_os_machine_id() -> Result { - // getting the machine ID can be done through mach APIs, but for - // simplicity, this uses a method originally used in - // `cpp_client_telemetry`. - // ref: https://github.com/microsoft/cpp_client_telemetry/commit/41315d1b77dcf7a419332b96ea4c7cab43760853 - - let output = Command::new("ioreg") - .args(&["-d2", "-c", "IOPlatformExpertDevice"]) - .stdin(Stdio::null()) - .stderr(Stdio::null()) - .output() - .await - .context("ioreg failed to run")?; - - let stdout = String::from_utf8_lossy(&output.stdout); - - for line in stdout.split('\n') { - // "IOPlatformUUID" = "GUID_HERE" - if line.contains("IOPlatformUUID") { - let quoted = line.split(" = ").last().ok_or_else(|| { - anyhow!("unable to find machine_id from IOPlatformUUID: {}", line) - })?; - let unquoted = quoted.trim_matches('"'); - let machine_id = Uuid::parse_str(unquoted).with_context(|| { - format!("unable to parse UUID: {} (from line: {}", unquoted, line) - })?; - return Ok(machine_id); - } - } - bail!( - "No matching IOPlatformUUID in `ioreg -rd1 -c IOPlatformExpertDevice` command: {:?}", - stdout - ); -} - async fn get_machine_id_impl() -> Result { let ims_id = get_ims_id().await; if ims_id.is_ok() { diff --git a/src/agent/onefuzz/src/memory.rs b/src/agent/onefuzz/src/memory.rs index 60746e5aa4..673b88b38a 100644 --- a/src/agent/onefuzz/src/memory.rs +++ b/src/agent/onefuzz/src/memory.rs @@ -1,7 +1,6 @@ #[cfg(target_os = "windows")] use std::convert::TryFrom; -#[cfg(not(target_os = "macos"))] use anyhow::Result; #[cfg(target_os = "linux")] diff --git a/src/agent/onefuzz/src/monitor.rs b/src/agent/onefuzz/src/monitor.rs index 00cee60d24..c2ecef6b68 100644 --- a/src/agent/onefuzz/src/monitor.rs +++ b/src/agent/onefuzz/src/monitor.rs @@ -145,6 +145,5 @@ impl DirectoryMonitor { } } -#[cfg(not(target_os = "macos"))] #[cfg(test)] mod tests;