Skip to content

Commit e825487

Browse files
committed
fix: add libc dependency for Unix and update IPC permissions assertions
1 parent a950e90 commit e825487

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ kode-bridge = { version = "0.3.4", default-features = false, features = [
8989
] }
9090
serial_test = "3.2.0"
9191

92+
[target.'cfg(unix)'.dev-dependencies]
93+
libc = "0.2.177"
94+
9295
[profile.release]
9396
panic = "abort"
9497
lto = "thin"

tests/test_start_permissions.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod tests {
1717
}
1818
#[tokio::test]
1919
#[serial]
20-
async fn start_and_stop_ipc_server_helper() {
20+
async fn start_and_check_permissions() {
2121
let server_handle = tokio::spawn(async {
2222
assert!(
2323
run_ipc_server().await.is_ok(),
@@ -38,11 +38,15 @@ mod tests {
3838
let permision = std::fs::metadata(IPC_PATH).expect("Failed to get metadata");
3939
let permissions = permision.permissions();
4040
#[cfg(unix)]
41-
assert_eq!(
42-
permissions.mode() & 0o777,
43-
0o777,
44-
"IPC file permissions should be 777"
45-
);
41+
{
42+
use libc::{S_IRWXU, S_IRWXG, S_IRWXO};
43+
let mask = (S_IRWXU | S_IRWXG | S_IRWXO) as u32;
44+
assert_eq!(
45+
permissions.mode() & mask,
46+
mask,
47+
"IPC file permissions should be 777"
48+
);
49+
}
4650
#[cfg(windows)]
4751
assert!(!permissions.readonly(), "IPC file should not be readonly");
4852

0 commit comments

Comments
 (0)