Skip to content
Merged
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ $(1): $(GEN_RS) $(GEN_TS) $(1)-lint $(1)-debug ## Lint and install $(1) (for use

.PHONY: $(1)-lint
$(1)-lint: fmt $(GEN_RS) $(GEN_TS)
$$(cargo) clippy $(2) -p $(1) --all-features -- -D clippy::all -D warnings
$$(cargo) clippy $(2) -p $(1) --all-features --all-targets -- -D clippy::all -D warnings

.PHONY: $(1)-test
$(1)-test: $(GEN_RS) $(GEN_TS) $(1)-lint auraed-debug
Expand Down
6 changes: 4 additions & 2 deletions auraed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,10 @@ mod tests {
);

let custom_runtime_dir = PathBuf::from("/tmp/aurae-test-runtime");
let mut runtime = AuraedRuntime::default();
runtime.runtime_dir = custom_runtime_dir.clone();
let runtime = AuraedRuntime {
runtime_dir: custom_runtime_dir.clone(),
..Default::default()
};
assert_eq!(
runtime.default_socket_address(),
custom_runtime_dir.join("aurae.sock")
Expand Down
22 changes: 11 additions & 11 deletions auraed/tests/auraed_nested_should_run_cell_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ async fn wait_for_socket_and_connect(
) -> Channel {
let deadline = tokio::time::Instant::now() + timeout;
while tokio::time::Instant::now() < deadline {
if path.exists() {
if let Ok(channel) = connect_unix(path).await {
let meta = std::fs::symlink_metadata(path)
.expect("metadata for socket");
assert!(
meta.file_type().is_socket(),
"expected {:?} to be a Unix socket",
path
);
return channel;
}
if path.exists()
&& let Ok(channel) = connect_unix(path).await
{
let meta =
std::fs::symlink_metadata(path).expect("metadata for socket");
assert!(
meta.file_type().is_socket(),
"expected {:?} to be a Unix socket",
path
);
return channel;
}
sleep(Duration::from_millis(100)).await;
}
Expand Down
22 changes: 10 additions & 12 deletions auraed/tests/auraed_pid1_should_mount_proc_and_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn wait_for_tcp_listener(pid: u32, log_path: &Path, timeout: Duration) -> bool {
if logs.contains("TCP Access Socket created") {
return true;
}
if !std::fs::metadata(format!("/proc/{pid}")).is_ok() {
if std::fs::metadata(format!("/proc/{pid}")).is_err() {
panic!("auraed pid {pid} exited early. logs:\n{}", logs);
}
thread::sleep(Duration::from_millis(50));
Expand All @@ -150,10 +150,10 @@ fn wait_for_pid_file(dir: &Path, timeout: Duration) -> u32 {
let pidfile = dir.join("runtime").join("auraed.pid");
let start = Instant::now();
while start.elapsed() < timeout {
if let Ok(contents) = std::fs::read_to_string(&pidfile) {
if let Ok(pid) = contents.trim().parse::<u32>() {
return pid;
}
if let Ok(contents) = std::fs::read_to_string(&pidfile)
&& let Ok(pid) = contents.trim().parse::<u32>()
{
return pid;
}
thread::sleep(Duration::from_millis(50));
}
Expand All @@ -167,15 +167,13 @@ fn assert_ns_pid1(pid: u32) {
if status.is_empty() {
panic!("status file {status_path} empty or missing");
}
if !std::fs::metadata(format!("/proc/{pid}")).is_ok() {
if std::fs::metadata(format!("/proc/{pid}")).is_err() {
panic!("process {pid} not alive");
}
if let Some(ns_line) = status.lines().find(|l| l.starts_with("NSpid:")) {
if ns_line.split_whitespace().last() != Some("1") {
panic!(
"expected auraed to be pid 1 in its namespace, got {ns_line}"
);
}
if let Some(ns_line) = status.lines().find(|l| l.starts_with("NSpid:"))
&& ns_line.split_whitespace().last() != Some("1")
{
panic!("expected auraed to be pid 1 in its namespace, got {ns_line}");
}
// If NSpid missing, we accept the process as long as it is alive; some kernels omit NSpid.
}
Expand Down
8 changes: 4 additions & 4 deletions auraed/tests/auraed_spawn_client_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ async fn wait_for_listener(addr: SocketAddr, child: &mut Child) {
}

fn teardown_child(child: &mut Child) {
if let Err(e) = child.kill() {
if e.kind() != std::io::ErrorKind::InvalidInput {
panic!("failed to kill auraed child: {e}");
}
if let Err(e) = child.kill()
&& e.kind() != std::io::ErrorKind::InvalidInput
{
panic!("failed to kill auraed child: {e}");
}
let _ = child.wait();
}
20 changes: 11 additions & 9 deletions auraed/tests/daemon_should_bind_only_unix_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ use test_helpers::*;
fn tcp_addrs_available_before_spawn() -> Vec<SocketAddr> {
["127.0.0.1:8080", "[::1]:8080"]
.into_iter()
.filter_map(|addr| addr.parse::<SocketAddr>().ok())
.filter_map(|addr| match TcpListener::bind(addr) {
Ok(listener) => {
drop(listener);
Some(addr)
.filter_map(|addr| {
let addr = addr.parse::<SocketAddr>().ok()?;
match TcpListener::bind(addr) {
Ok(listener) => {
drop(listener);
Some(addr)
}
Err(e) if e.kind() == io::ErrorKind::AddrInUse => None,
Err(e) if e.kind() == io::ErrorKind::AddrNotAvailable => None,
Err(e) => panic!("unexpected error probing {addr}: {e}"),
}
Err(e) if e.kind() == io::ErrorKind::AddrInUse => None,
Err(e) if e.kind() == io::ErrorKind::AddrNotAvailable => None,
Err(e) => panic!("unexpected error probing {addr}: {e}"),
})
.collect()
}
Expand Down Expand Up @@ -90,7 +92,7 @@ fn auraed_daemon_mode_should_bind_only_unix_socket() {
// Default daemon mode should not open the documented TCP endpoint ([::1]:8080 or 127.0.0.1:8080).
// Only check addresses that were free before spawning auraed to avoid false positives from other services.
for addr in tcp_addrs {
let tcp_result = TcpListener::bind(addr).map(|listener| drop(listener));
let tcp_result = TcpListener::bind(addr).map(drop);
assert!(
tcp_result.is_ok(),
"expected no TCP listener at {addr}, but binding failed after starting auraed"
Expand Down