Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vmtest-action version 0.8 in CI #795

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
EOF
chmod a+x main.sh
- name: Test and gather coverage
uses: danobi/vmtest-action@master
uses: danobi/vmtest-action@v0.8
with:
kernel: bzImage
command: sh -c 'cd ${{ github.workspace }} && ./main.sh'
Expand Down
17 changes: 10 additions & 7 deletions src/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mod tests {
use std::ffi::CStr;
use std::io::Write;

use tempfile::tempfile;
use tempfile::NamedTempFile;
use test_log::test;

use crate::util::ReadRaw;
Expand All @@ -144,20 +144,22 @@ mod tests {
/// Check that we can `mmap` an empty file.
#[test]
fn mmap_empty_file() {
let file = tempfile().unwrap();
let mmap = Mmap::map(&file).unwrap();
let file = NamedTempFile::new().unwrap();
let file = file.as_file();
let mmap = Mmap::map(file).unwrap();
assert_eq!(mmap.deref(), &[]);
}

/// Check that we can `mmap` a file.
#[test]
fn mmap() {
let mut file = tempfile().unwrap();
let file = NamedTempFile::new().unwrap();
let mut file = file.as_file();
let cstr = b"Daniel was here. Briefly.\0";
let () = file.write_all(cstr).unwrap();
let () = file.sync_all().unwrap();

let mmap = Mmap::map(&file).unwrap();
let mmap = Mmap::map(file).unwrap();
let mut data = mmap.deref();
let s = data.read_cstr().unwrap();
assert_eq!(
Expand All @@ -169,12 +171,13 @@ mod tests {
/// Check that we can properly restrict the view of a `Mmap`.
#[test]
fn view_constraining() {
let mut file = tempfile().unwrap();
let file = NamedTempFile::new().unwrap();
let mut file = file.as_file();
let s = b"abcdefghijklmnopqrstuvwxyz";
let () = file.write_all(s).unwrap();
let () = file.sync_all().unwrap();

let mmap = Mmap::map(&file).unwrap();
let mmap = Mmap::map(file).unwrap();
assert_eq!(mmap.deref(), b"abcdefghijklmnopqrstuvwxyz");

let mmap = mmap.constrain(1..15).unwrap();
Expand Down
10 changes: 5 additions & 5 deletions src/symbolize/perf_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ mod tests {

use scopeguard::defer;

use tempfile::tempfile;
use tempfile::NamedTempFile;

use crate::symbolize::Input;
use crate::symbolize::Process;
Expand Down Expand Up @@ -257,9 +257,9 @@ mod tests {
};
assert_ne!(format!("{func:?}"), "");

let mut file = tempfile().unwrap();
let mut file = NamedTempFile::new().unwrap();
let () = file.write_all(SAMPLE_PERF_MAP).unwrap();
let perf_map = PerfMap::from_file(Path::new("SAMPLE_PERF_MAP"), &file).unwrap();
let perf_map = PerfMap::from_file(file.path(), file.as_file()).unwrap();
assert_ne!(format!("{perf_map:?}"), "");
}

Expand Down Expand Up @@ -295,9 +295,9 @@ mod tests {
/// Check that we can load a perf map and use it to symbolize an address.
#[test]
fn perf_map_symbolization() {
let mut file = tempfile().unwrap();
let mut file = NamedTempFile::new().unwrap();
let () = file.write_all(SAMPLE_PERF_MAP).unwrap();
let perf_map = PerfMap::from_file(Path::new("SAMPLE_PERF_MAP"), &file).unwrap();
let perf_map = PerfMap::from_file(file.path(), file.as_file()).unwrap();

for offset in 0..0xb {
let sym = perf_map
Expand Down