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
58 changes: 58 additions & 0 deletions demo/carla/bridge/Cargo.lock

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

2 changes: 2 additions & 0 deletions demo/carla/bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ tracing = "0.1"
# The stand-in producer: a native Vulkan renderer that hands the bridge
# exportable slots exactly the way the CARLA plugin does.
ash = "0.38"
# Each test owns the directory its socket and lock file live in.
tempfile = "3"

[lints.clippy]
# Every suppression says why, so the next lint audit can judge it.
Expand Down
11 changes: 4 additions & 7 deletions demo/carla/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,10 @@ impl Shared {
mod tests {
use super::*;

fn socket_path(name: &str) -> PathBuf {
std::env::temp_dir().join(format!("carla-bridge-{name}-{}.sock", std::process::id()))
}

#[test]
fn a_live_bridge_keeps_its_socket() {
let path = socket_path("live");
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("bridge.sock");
let first = Bridge::listen(&path).unwrap();
let err = Bridge::listen(&path).err().expect("a second bridge on the path");
assert!(err.to_string().contains("another bridge"), "{err:#}");
Expand All @@ -200,8 +197,8 @@ mod tests {

#[test]
fn a_stale_socket_is_replaced() {
let path = socket_path("stale");
let _ = std::fs::remove_file(&path);
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("bridge.sock");
// A listener that exited without unlinking, like a crashed process.
drop(UnixListener::bind(&path).unwrap());
let bridge = Bridge::listen(&path).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions demo/carla/bridge/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ mod tests {

#[test]
fn a_superseded_connection_changes_nothing() {
let path = std::env::temp_dir().join(format!("carla-bridge-superseded-{}.sock", std::process::id()));
let bridge = crate::Bridge::listen(&path).unwrap();
let dir = tempfile::tempdir().unwrap();
let bridge = crate::Bridge::listen(dir.path().join("bridge.sock")).unwrap();
// Not the current connection: another worker replaced it (here, none
// is current at all).
let mut stale = Connection {
Expand Down
9 changes: 3 additions & 6 deletions demo/carla/bridge/tests/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod standin;
use std::collections::{HashMap, VecDeque};
use std::io::Write;
use std::os::unix::net::UnixStream;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::time::Duration;

use carla_bridge::Bridge;
Expand Down Expand Up @@ -253,15 +253,12 @@ fn step(camera: &mut Camera, worker: &mut Worker, latency: &mut Latency, number:
keyframes
}

fn socket_path() -> PathBuf {
std::env::temp_dir().join(format!("carla-bridge-test-{}.sock", std::process::id()))
}

#[test]
#[ignore = "needs a Linux NVIDIA GPU; run by `just carla bridge-gpu`"]
fn gpu_video_reaches_the_worker() {
let gpu = Gpu::open().expect("an NVIDIA Vulkan device");
let bridge = Bridge::listen(socket_path()).expect("listen");
let dir = tempfile::tempdir().expect("a directory for the socket");
let bridge = Bridge::listen(dir.path().join("bridge.sock")).expect("listen");
let mut sd = Camera::new(&gpu, &bridge, STREAM, SD, 3);
let mut hd = Camera::new(&gpu, &bridge, STREAM, HD, 3);
let mut latency = Latency::default();
Expand Down
24 changes: 0 additions & 24 deletions quest/m1/carla-bridge-test-locks.md

This file was deleted.