Skip to content

Commit

Permalink
chore: upgrade nix to 0.29
Browse files Browse the repository at this point in the history
This patch updates our nix dependency to 0.29.
We didn't have to do anything for libshpool, but
I had to make some tweaks to the test code. I
was even able to delete an `unsafe` block, which
is always nice.
  • Loading branch information
ethanpailes committed Jan 24, 2025
1 parent 42974fb commit 5ced31e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 42 deletions.
42 changes: 7 additions & 35 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion libshpool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ shpool-protocol = { version = "0.2.1", path = "../shpool-protocol" } # client-se

# rusty wrapper for unix apis
[dependencies.nix]
version = "0.28"
version = "0.29"
features = ["poll", "ioctl", "socket", "user", "process", "signal", "term", "fs"]

[dependencies.tracing-subscriber]
Expand Down
6 changes: 5 additions & 1 deletion shpool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ libshpool = { version = "0.8.1", path = "../libshpool" }
[dev-dependencies]
lazy_static = "1" # globals
crossbeam-channel = "0.5" # channels
nix = { version = "0.26", features = ["poll", "ioctl"] } # rusty wrapper for unix apis
tempfile = "3" # keeping tests hermetic
regex = "1" # test assertions
serde_json = "1" # json parsing
ntest = "0.9" # test timeouts

# rusty wrapper for unix apis
[dependencies.nix]
version = "0.29"
features = ["poll", "ioctl", "process", "signal", "fs"]
10 changes: 5 additions & 5 deletions shpool/tests/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
fmt::Write,
io::Read,
os::unix::{
io::{AsRawFd, FromRawFd},
io::AsRawFd,
net::UnixListener,
process::CommandExt as _,
},
Expand Down Expand Up @@ -80,8 +80,7 @@ fn systemd_activation() -> anyhow::Result<()> {

let (parent_stderr, child_stderr) =
nix::unistd::pipe().context("creating pipe to collect stderr")?;
// Safety: this is a test
let child_stderr_pipe = unsafe { Stdio::from_raw_fd(child_stderr) };
let child_stderr_pipe = Stdio::from(child_stderr);
let mut cmd = Command::new(support::shpool_bin()?);
cmd.stdout(Stdio::piped())
.stderr(child_stderr_pipe)
Expand Down Expand Up @@ -147,8 +146,9 @@ fn systemd_activation() -> anyhow::Result<()> {
nix::sys::wait::waitpid(child_pid, None).context("reaping daemon")?;

let mut stderr_buf: Vec<u8> = vec![0; 1024 * 8];
let len =
nix::unistd::read(parent_stderr, &mut stderr_buf[..]).context("reading stderr")?;
let len = nix::unistd::read(
parent_stderr.as_raw_fd(),
&mut stderr_buf[..]).context("reading stderr")?;
let stderr = String::from_utf8_lossy(&stderr_buf[..len]);
assert!(stderr.contains("using systemd activation socket"));

Expand Down

0 comments on commit 5ced31e

Please sign in to comment.