Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
CARGO_TERM_COLOR: always
SCCACHE_DIR: ${{github.workspace}}/sccache/
SCCACHE_CACHE_SIZE: 1G
ACTIONS_CACHE_KEY_DATE: 2022-11-21-02
ACTIONS_CACHE_KEY_DATE: 2023-04-19
CI: true

jobs:
Expand Down
11 changes: 0 additions & 11 deletions src/agent/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/agent/coverage/examples/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,28 @@ fn dump_cobertura(binary: &BinaryCoverage) -> Result<()> {

Ok(())
}

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

#[test]
fn can_run_coverage() {
#[cfg(target_os = "linux")]
let cmd = command(&["ls"].map(str::to_string), None);

#[cfg(target_os = "windows")]
let cmd = command(&["cmd.exe", "/c", "dir"].map(str::to_string), None);

let recorded = CoverageRecorder::new(cmd)
.timeout(Duration::from_secs(5))
.record()
.unwrap();

assert_ne!("", recorded.output.stdout);

// only non-debuggable modules are found on Windows
#[cfg(target_os = "linux")]
assert!(recorded.coverage.modules.len() > 0);
}
}
7 changes: 5 additions & 2 deletions src/agent/onefuzz-agent/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Licensed under the MIT License.

#![allow(clippy::too_many_arguments)]
use std::time::Duration;

use anyhow::{Error, Result};
use tokio::time;

Expand Down Expand Up @@ -29,6 +31,7 @@ pub struct Agent {
last_poll_command: Result<Option<NodeCommand>, PollCommandError>,
managed: bool,
machine_id: uuid::Uuid,
sleep_duration: Duration,
}

impl Agent {
Expand Down Expand Up @@ -59,6 +62,7 @@ impl Agent {
last_poll_command,
managed,
machine_id,
sleep_duration: Duration::from_secs(30),
}
}

Expand Down Expand Up @@ -365,8 +369,7 @@ impl Agent {
}

async fn sleep(&self) {
let delay = time::Duration::from_secs(30);
time::sleep(delay).await;
time::sleep(self.sleep_duration).await;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/agent/onefuzz-agent/src/agent/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ impl Fixture {

#[tokio::test]
async fn test_update_free_no_work() {
let agent = Fixture.agent();
let mut agent = Fixture.agent();
agent.sleep_duration = Duration::from_secs(5);

let (agent, done) = agent.update().await.unwrap();
assert!(!done);
Expand Down
2 changes: 1 addition & 1 deletion src/ci/agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export RUST_BACKTRACE=full

# Run tests and collect coverage
# https://github.com/taiki-e/cargo-llvm-cov
cargo llvm-cov --locked --workspace --lcov --output-path "$output_dir/lcov.info"
cargo llvm-cov nextest --all-targets --locked --workspace --lcov --output-path "$output_dir/lcov.info"

# TODO: re-enable integration tests.
# cargo test --release --manifest-path ./onefuzz-task/Cargo.toml --features integration_test -- --nocapture
Expand Down
2 changes: 1 addition & 1 deletion src/ci/rust-prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -ex

cargo install sccache cargo-license@0.4.2 cargo-llvm-cov cargo-deny cargo-insta
cargo install sccache cargo-license@0.4.2 cargo-llvm-cov cargo-deny cargo-insta cargo-nextest

# sccache --start-server
# export RUSTC_WRAPPER=$(which sccache)