Skip to content

Commit 0b78603

Browse files
committed
fix: reorder permission constants and enhance IPC connection assertions for Unix
1 parent 5456d9e commit 0b78603

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

tests/test_start_permissions.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,59 @@ mod tests {
3939
let permissions = permision.permissions();
4040
#[cfg(all(unix, target_os = "macos"))]
4141
{
42-
use platform_lib::{S_IRWXU, S_IRWXG, S_IRWXO};
43-
42+
use platform_lib::{S_IRWXG, S_IRWXO, S_IRWXU};
43+
4444
let owner_perm = u32::from(S_IRWXU); // 用户权限 (rwx------ = 700)
4545
let group_perm = u32::from(S_IRWXG); // 组权限 (---rwx--- = 070)
4646
let other_perm = u32::from(S_IRWXO); // 其他权限 (------rwx = 007)
4747
let full_mask = owner_perm | group_perm | other_perm; // 完整权限掩码 (rwxrwxrwx = 777)
48-
48+
4949
let actual_perms = permissions.mode() & full_mask;
50-
50+
5151
debug!("macOS IPC file permissions: {:o}", permissions.mode());
5252
assert_eq!(
53-
actual_perms,
54-
full_mask,
53+
actual_perms, full_mask,
5554
"IPC file permissions should be 777 (actual: {:o})",
5655
actual_perms
5756
);
5857
}
5958

6059
#[cfg(all(unix, not(target_os = "macos")))]
6160
{
62-
use platform_lib::{S_IRWXU, S_IRWXG, S_IRWXO};
63-
61+
use platform_lib::{S_IRWXG, S_IRWXO, S_IRWXU};
62+
6463
let owner_perm = S_IRWXU; // 用户权限 (rwx------ = 700)
6564
let group_perm = S_IRWXG; // 组权限 (---rwx--- = 070)
6665
let other_perm = S_IRWXO; // 其他权限 (------rwx = 007)
6766
let full_mask = owner_perm | group_perm | other_perm; // 完整权限掩码 (rwxrwxrwx = 777)
68-
67+
6968
let actual_perms = permissions.mode() & full_mask;
70-
69+
7170
debug!("Linux IPC file permissions: {:o}", permissions.mode());
7271
assert_eq!(
73-
actual_perms,
74-
full_mask,
72+
actual_perms, full_mask,
7573
"IPC file permissions should be 777 (actual: {:o})",
7674
actual_perms
7775
);
7876
}
7977
#[cfg(windows)]
8078
assert!(!permissions.readonly(), "IPC file should not be readonly");
8179

80+
let client = connect_ipc().await;
81+
assert!(
82+
client.is_ok(),
83+
"Should be able to connect to IPC server after starting"
84+
);
85+
let version = client
86+
.unwrap()
87+
.get(IpcCommand::GetVersion.as_ref())
88+
.send()
89+
.await;
90+
assert!(
91+
version.is_ok(),
92+
"Should receive a response from GetVersion command"
93+
);
94+
8295
assert!(
8396
stop_ipc_server().await.is_ok(),
8497
"Stopping IPC server after starting should return Ok"

0 commit comments

Comments
 (0)