Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Remove stubbed support for macOS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ranweiler committed Jul 6, 2022
1 parent c0895a5 commit 4acf7a8
Show file tree
Hide file tree
Showing 13 changed files with 1 addition and 109 deletions.
10 changes: 0 additions & 10 deletions src/agent/coverage/examples/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Coverage> {
unimplemented!("coverage recording is not supported on macOS");
}

#[cfg(target_os = "linux")]
fn record(
cache: &mut ModuleCache,
Expand Down
5 changes: 0 additions & 5 deletions src/agent/coverage/examples/elf_sancov_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ struct Opt {
inline: bool,
}

#[cfg(target_os = "macos")]
fn main() -> Result<()> {
Ok(())
}

#[cfg(target_os = "windows")]
fn main() -> Result<()> {
Ok(())
Expand Down
5 changes: 0 additions & 5 deletions src/agent/coverage/examples/pdb_sancov_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,3 @@ fn main() -> Result<()> {
fn main() -> Result<()> {
Ok(())
}

#[cfg(target_os = "macos")]
fn main() -> Result<()> {
Ok(())
}
10 changes: 0 additions & 10 deletions src/agent/coverage/examples/src-cov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Coverage> {
unimplemented!("coverage recording is not supported on macOS");
}

#[cfg(target_os = "linux")]
fn record(
cache: &mut ModuleCache,
Expand Down
6 changes: 0 additions & 6 deletions src/agent/dynamic-library/src/bin/dynamic-library.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -67,8 +66,3 @@ fn find_missing(cmd: Command) -> Result<Vec<String>> {
.map(|m| m.name)
.collect())
}

#[cfg(target_os = "macos")]
fn find_missing(cmd: Command) -> Result<Vec<String>> {
todo!()
}
2 changes: 1 addition & 1 deletion src/agent/onefuzz-agent/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions src/agent/onefuzz-task/src/managed/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down Expand Up @@ -65,15 +64,13 @@ 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.
//
// 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<OutOfMemory> {
if min_bytes == 0 {
bail!("available memory minimum is unreachable");
Expand Down Expand Up @@ -109,12 +106,6 @@ async fn out_of_memory(min_bytes: u64) -> Result<OutOfMemory> {
}
}

#[cfg(target_os = "macos")]
async fn out_of_memory(_min_bytes: u64) -> Result<OutOfMemory> {
// Resolve immediately.
bail!("out-of-memory check not implemented on macOS")
}

struct OutOfMemory {
available_bytes: u64,
min_bytes: u64,
Expand Down
6 changes: 0 additions & 6 deletions src/agent/onefuzz/examples/memory.rs
Original file line number Diff line number Diff line change
@@ -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!()
}
9 changes: 0 additions & 9 deletions src/agent/onefuzz/src/input_tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,6 @@ impl<'a> Tester<'a> {
Ok(crash)
}

#[cfg(target_os = "macos")]
async fn test_input_debugger(
&self,
_args: Vec<String>,
_env: HashMap<String, String>,
) -> Result<Option<CrashLog>> {
bail!("running application under a debugger is not supported on macOS");
}

#[cfg(target_os = "linux")]
async fn test_input_debugger(
&self,
Expand Down
6 changes: 0 additions & 6 deletions src/agent/onefuzz/src/libfuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ impl<'a> LibFuzzer<'a> {
Ok(())
}

#[cfg(not(target_os = "macos"))]
async fn find_missing_libraries(&self) -> Result<Vec<String>> {
let cmd = self.build_std_command(None, None, None).await?;

Expand All @@ -270,11 +269,6 @@ impl<'a> LibFuzzer<'a> {
Ok(missing)
}

#[cfg(target_os = "macos")]
async fn find_missing_libraries(&self) -> Result<Vec<String>> {
todo!()
}

pub async fn fuzz(
&self,
fault_dir: impl AsRef<Path>,
Expand Down
40 changes: 0 additions & 40 deletions src/agent/onefuzz/src/machine_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -116,42 +112,6 @@ pub async fn get_os_machine_id() -> Result<Uuid> {
Ok(Uuid::parse_str(&guid)?)
}

#[cfg(target_os = "macos")]
pub async fn get_os_machine_id() -> Result<Uuid> {
// 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<Uuid> {
let ims_id = get_ims_id().await;
if ims_id.is_ok() {
Expand Down
1 change: 0 additions & 1 deletion src/agent/onefuzz/src/memory.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#[cfg(target_os = "windows")]
use std::convert::TryFrom;

#[cfg(not(target_os = "macos"))]
use anyhow::Result;

#[cfg(target_os = "linux")]
Expand Down
1 change: 0 additions & 1 deletion src/agent/onefuzz/src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,5 @@ impl DirectoryMonitor {
}
}

#[cfg(not(target_os = "macos"))]
#[cfg(test)]
mod tests;

0 comments on commit 4acf7a8

Please sign in to comment.