Skip to content

Commit 0adcb92

Browse files
committed
test: trace shared_memory in fspy tests
1 parent 1f1c73b commit 0adcb92

File tree

7 files changed

+30
-23
lines changed

7 files changed

+30
-23
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/fspy/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ tempfile = { workspace = true }
4646
anyhow = { workspace = true }
4747
csv-async = { workspace = true }
4848
ctor = { workspace = true }
49+
test-log = { workspace = true }
4950
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "fs", "io-std"] }
5051

5152
[target.'cfg(all(target_os = "linux", target_arch = "aarch64"))'.dev-dependencies]

crates/fspy/tests/node_fs.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod test_utils;
33
use std::env::{current_dir, vars_os};
44

55
use fspy::{AccessMode, PathAccessIterable};
6+
use test_log::test;
67
use test_utils::assert_contains;
78

89
async fn track_node_script(script: &str) -> anyhow::Result<PathAccessIterable> {
@@ -17,21 +18,21 @@ async fn track_node_script(script: &str) -> anyhow::Result<PathAccessIterable> {
1718
Ok(termination.path_accesses)
1819
}
1920

20-
#[tokio::test]
21+
#[test(tokio::test)]
2122
async fn read_sync() -> anyhow::Result<()> {
2223
let accesses = track_node_script("try { fs.readFileSync('hello') } catch {}").await?;
2324
assert_contains(&accesses, current_dir().unwrap().join("hello").as_path(), AccessMode::Read);
2425
Ok(())
2526
}
2627

27-
#[tokio::test]
28+
#[test(tokio::test)]
2829
async fn read_dir_sync() -> anyhow::Result<()> {
2930
let accesses = track_node_script("try { fs.readdirSync('.') } catch {}").await?;
3031
assert_contains(&accesses, &current_dir().unwrap(), AccessMode::ReadDir);
3132
Ok(())
3233
}
3334

34-
#[tokio::test]
35+
#[test(tokio::test)]
3536
async fn subprocess() -> anyhow::Result<()> {
3637
let cmd = if cfg!(windows) {
3738
r"'cmd', ['/c', 'type hello']"

crates/fspy/tests/rust_std.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ use std::{
88
};
99

1010
use fspy::AccessMode;
11+
use test_log::test;
1112
use test_utils::assert_contains;
1213

13-
#[tokio::test]
14+
#[test(tokio::test)]
1415
async fn open_read() -> anyhow::Result<()> {
1516
let accesses = track_child!({
1617
let _ = File::open("hello");
@@ -21,7 +22,7 @@ async fn open_read() -> anyhow::Result<()> {
2122
Ok(())
2223
}
2324

24-
#[tokio::test]
25+
#[test(tokio::test)]
2526
async fn open_write() -> anyhow::Result<()> {
2627
let accesses = track_child!({
2728
let path = format!("{}/hello", env!("CARGO_TARGET_TMPDIR"));
@@ -37,7 +38,7 @@ async fn open_write() -> anyhow::Result<()> {
3738
Ok(())
3839
}
3940

40-
#[tokio::test]
41+
#[test(tokio::test)]
4142
async fn readdir() -> anyhow::Result<()> {
4243
let accesses = track_child!({
4344
let path = format!("{}/hello", env!("CARGO_TARGET_TMPDIR"));
@@ -53,7 +54,7 @@ async fn readdir() -> anyhow::Result<()> {
5354
Ok(())
5455
}
5556

56-
#[tokio::test]
57+
#[test(tokio::test)]
5758
async fn subprocess() -> anyhow::Result<()> {
5859
let accesses = track_child!({
5960
let mut command = if cfg!(windows) {

crates/fspy/tests/rust_tokio.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ mod test_utils;
33
use std::{env::current_dir, path::Path, process::Stdio};
44

55
use fspy::AccessMode;
6+
use test_log::test;
67
use test_utils::assert_contains;
78
use tokio::fs::OpenOptions;
89

9-
#[tokio::test]
10+
#[test(tokio::test)]
1011
async fn open_read() -> anyhow::Result<()> {
1112
let accesses = track_child!({
1213
tokio::runtime::Builder::new_current_thread().enable_io().build().unwrap().block_on(
@@ -21,7 +22,7 @@ async fn open_read() -> anyhow::Result<()> {
2122
Ok(())
2223
}
2324

24-
#[tokio::test]
25+
#[test(tokio::test)]
2526
async fn open_write() -> anyhow::Result<()> {
2627
let accesses = track_child!({
2728
let path = format!("{}/hello", env!("CARGO_TARGET_TMPDIR"));
@@ -42,7 +43,7 @@ async fn open_write() -> anyhow::Result<()> {
4243
Ok(())
4344
}
4445

45-
#[tokio::test]
46+
#[test(tokio::test)]
4647
async fn readdir() -> anyhow::Result<()> {
4748
let accesses = track_child!({
4849
let path = format!("{}/hello", env!("CARGO_TARGET_TMPDIR"));
@@ -63,7 +64,7 @@ async fn readdir() -> anyhow::Result<()> {
6364
Ok(())
6465
}
6566

66-
#[tokio::test]
67+
#[test(tokio::test)]
6768
async fn subprocess() -> anyhow::Result<()> {
6869
let accesses = track_child!({
6970
tokio::runtime::Builder::new_current_thread().enable_io().build().unwrap().block_on(

crates/fspy/tests/static_executable.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{
99

1010
use fspy::PathAccessIterable;
1111
use fspy_shared_unix::is_dynamically_linked_to_libc;
12+
use test_log::test;
1213

1314
use crate::test_utils::assert_contains;
1415

@@ -49,61 +50,61 @@ async fn track_test_bin(args: &[&str], cwd: Option<&str>) -> PathAccessIterable
4950
termination.path_accesses
5051
}
5152

52-
#[tokio::test]
53+
#[test(tokio::test)]
5354
async fn open_read() {
5455
let accesses = track_test_bin(&["open_read", "/hello"], None).await;
5556
assert_contains(&accesses, Path::new("/hello"), fspy::AccessMode::Read);
5657
}
5758

58-
#[tokio::test]
59+
#[test(tokio::test)]
5960
async fn open_write() {
6061
let accesses = track_test_bin(&["open_write", "/hello"], None).await;
6162
assert_contains(&accesses, Path::new("/hello"), fspy::AccessMode::Write);
6263
}
6364

64-
#[tokio::test]
65+
#[test(tokio::test)]
6566
async fn open_readwrite() {
6667
let accesses = track_test_bin(&["open_readwrite", "/hello"], None).await;
6768
assert_contains(&accesses, Path::new("/hello"), fspy::AccessMode::ReadWrite);
6869
}
6970

70-
#[tokio::test]
71+
#[test(tokio::test)]
7172
async fn openat2_read() {
7273
let accesses = track_test_bin(&["openat2_read", "/hello"], None).await;
7374
assert_contains(&accesses, Path::new("/hello"), fspy::AccessMode::Read);
7475
}
7576

76-
#[tokio::test]
77+
#[test(tokio::test)]
7778
async fn openat2_write() {
7879
let accesses = track_test_bin(&["openat2_write", "/hello"], None).await;
7980
assert_contains(&accesses, Path::new("/hello"), fspy::AccessMode::Write);
8081
}
8182

82-
#[tokio::test]
83+
#[test(tokio::test)]
8384
async fn openat2_readwrite() {
8485
let accesses = track_test_bin(&["openat2_readwrite", "/hello"], None).await;
8586
assert_contains(&accesses, Path::new("/hello"), fspy::AccessMode::ReadWrite);
8687
}
8788

88-
#[tokio::test]
89+
#[test(tokio::test)]
8990
async fn open_relative() {
9091
let accesses = track_test_bin(&["open_read", "hello"], Some("/home")).await;
9192
assert_contains(&accesses, Path::new("/home/hello"), fspy::AccessMode::Read);
9293
}
9394

94-
#[tokio::test]
95+
#[test(tokio::test)]
9596
async fn readdir() {
9697
let accesses = track_test_bin(&["readdir", "/home"], None).await;
9798
assert_contains(&accesses, Path::new("/home"), fspy::AccessMode::ReadDir);
9899
}
99100

100-
#[tokio::test]
101+
#[test(tokio::test)]
101102
async fn stat() {
102103
let accesses = track_test_bin(&["stat", "/hello"], None).await;
103104
assert_contains(&accesses, Path::new("/hello"), fspy::AccessMode::Read);
104105
}
105106

106-
#[tokio::test]
107+
#[test(tokio::test)]
107108
async fn execve() {
108109
let accesses = track_test_bin(&["execve", "/hello"], None).await;
109110
assert_contains(&accesses, Path::new("/hello"), fspy::AccessMode::Read);

crates/fspy_shared/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ allocator-api2 = { workspace = true }
99
bincode = { workspace = true }
1010
bstr = { workspace = true }
1111
bytemuck = { workspace = true, features = ["must_cast"] }
12-
shared_memory = { workspace = true }
12+
shared_memory = { workspace = true, features = ["logging"] }
1313
thiserror = { workspace = true }
1414
tracing = { workspace = true }
1515
uuid = { workspace = true, features = ["v4"] }
@@ -24,4 +24,4 @@ winsafe = { workspace = true }
2424
assert2 = { workspace = true }
2525
ctor = { workspace = true }
2626
fspy_test_utils = { workspace = true }
27-
shared_memory = { workspace = true }
27+
shared_memory = { workspace = true, features = ["logging"] }

0 commit comments

Comments
 (0)