The product is Voelin (app id io.github.faumaray.Voelin), everywhere: - crates tsc-* -> voelin-* (and voelin-fuzz), the desktop binary tsc-desktop -> voelin, the development CLI tsctl -> voelinctl; - the Android app: applicationId, Kotlin package io.github.faumaray.voelin, VoelinApp, libvoelin_android.so (JNI class names follow); - TSC_* environment variables -> VOELIN_*, Gradle properties tsc.* -> voelin.*, signing secrets VOELIN_SIGNING_*; - the data/config/cache/state folder tsc -> voelin, the keyring service, thread names, the dev compose project; - desktop file, metainfo, icon, Flatpak manifest, NSIS installer, docs. The gateway keeps its name: bin tsgw (crate voelin-gateway), TSGW_* env vars, the tsgw.v1+json protocol, the tsgw image. The window title and the About page show "Voelin <version>" from voelin_platform::APP_NAME. Packages (scripts/package.sh): the app only (voelin, voelin.exe, APKs, Flatpak). voelinctl is a development tool and in no package. tsgw is for servers and now its own Linux package, tsgw_<v>_amd64.deb and tsgw-<v>-linux-x86_64.tar.gz, with a sandboxed systemd unit (packaging/linux/tsgw.service; /etc/tsgw config, /var/lib/tsgw state) and dependencies of its own (no GUI libraries). docs/gateway-admin.md has an Install section. Fixes: - package-windows: makensis on Windows found no file through "D:/a/..." paths; pass Windows paths (cygpath -w). - StartupWMClass is the app id, which the app sets as its X11 WM_CLASS (it was the binary name, so desktops could not match the window). - Gradle wrapper download timeout 10 s -> 60 s (slow proxies). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
118 lines
4.5 KiB
Rust
118 lines
4.5 KiB
Rust
//! The crash report panic hook, with real panics in threads and in a child
|
|
//! process. Its own test binary: the hook is process-wide.
|
|
|
|
use std::path::PathBuf;
|
|
use std::thread;
|
|
|
|
use voelin_platform::crash;
|
|
|
|
fn temp_dir(name: &str) -> PathBuf {
|
|
let dir = std::env::temp_dir().join(format!("voelin-crash-{name}-{}", std::process::id()));
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
dir
|
|
}
|
|
|
|
/// Panic in a named thread and wait for it.
|
|
fn panic_in_thread(name: &str, message: String) {
|
|
let result =
|
|
thread::Builder::new().name(name.into()).spawn(move || panic!("{message}")).unwrap().join();
|
|
assert!(result.is_err(), "the thread should have panicked");
|
|
}
|
|
|
|
// The only test that installs the hook in this process: the hook and its
|
|
// settings are global. The child process test below only spawns.
|
|
#[test]
|
|
fn panic_hook_writes_reports() {
|
|
let dir = temp_dir("hook");
|
|
crash::set_app_version("9.8.7-test");
|
|
crash::install(&dir, false);
|
|
assert_eq!(crash::dir().as_deref(), Some(dir.as_path()));
|
|
|
|
// Disabled: nothing is written.
|
|
panic_in_thread("quiet", "not recorded".into());
|
|
assert!(crash::pending_reports().unwrap().is_empty());
|
|
|
|
// Enabled: one report with the details.
|
|
crash::set_enabled(true);
|
|
assert!(crash::is_enabled());
|
|
panic_in_thread("crash-test", "boom 42\nsecond line".into());
|
|
let reports = crash::pending_reports().unwrap();
|
|
assert_eq!(reports.len(), 1, "{reports:?}");
|
|
let report = &reports[0];
|
|
assert_eq!(report.summary, "boom 42");
|
|
let age = report.time.elapsed().unwrap_or_default();
|
|
assert!(age.as_secs() < 60, "report time {:?} ago", age);
|
|
let text = std::fs::read_to_string(&report.path).unwrap();
|
|
eprintln!("{text}");
|
|
assert!(text.contains("Version: 9.8.7-test"), "{text}");
|
|
assert!(text.contains("Thread: crash-test ("), "{text}");
|
|
assert!(text.contains("Message: boom 42\n second line"), "{text}");
|
|
assert!(text.contains(&format!("System: {}", std::env::consts::OS)), "{text}");
|
|
// The path separator is the platform's.
|
|
let location = text.lines().find(|l| l.starts_with("Location: ")).unwrap_or_default();
|
|
assert!(location.contains("tests") && location.contains("crash.rs:"), "{text}");
|
|
assert!(text.contains("Backtrace:\n"), "{text}");
|
|
// Symbols resolve on Linux (MSVC needs the PDB files next to the binary).
|
|
if cfg!(target_os = "linux") {
|
|
assert!(text.contains("panic_in_thread"), "{text}");
|
|
}
|
|
// No partial files are left behind.
|
|
assert_eq!(std::fs::read_dir(&dir).unwrap().count(), 1);
|
|
|
|
// Only the newest reports are kept.
|
|
crash::set_keep(3);
|
|
for i in 0..5 {
|
|
panic_in_thread("crash-test", format!("panic {i}"));
|
|
}
|
|
let summaries: Vec<_> =
|
|
crash::pending_reports().unwrap().into_iter().map(|r| r.summary).collect();
|
|
assert_eq!(summaries, ["panic 2", "panic 3", "panic 4"]);
|
|
|
|
// Reports survive a restart (a new install) and can be deleted.
|
|
crash::install(&dir, true);
|
|
assert_eq!(crash::pending_reports().unwrap().len(), 3);
|
|
assert_eq!(crash::clear().unwrap(), 3);
|
|
assert!(crash::pending_reports().unwrap().is_empty());
|
|
|
|
// A directory that does not exist yet is created on the first report.
|
|
let nested = dir.join("a").join("b");
|
|
crash::install(&nested, true);
|
|
panic_in_thread("crash-test", "into a new directory".into());
|
|
assert_eq!(crash::reports_in(&nested).unwrap().len(), 1);
|
|
|
|
crash::set_enabled(false);
|
|
std::fs::remove_dir_all(&dir).unwrap();
|
|
}
|
|
|
|
/// Runs only as the child of `test_crash_in_child_process`: a start with
|
|
/// `VOELIN_TEST_CRASH` set, as a tester would do with the app.
|
|
#[test]
|
|
fn child_process_crash() {
|
|
let Some(dir) = std::env::var_os("VOELIN_CRASH_CHILD_DIR") else { return };
|
|
crash::set_app_version("child");
|
|
crash::install(PathBuf::from(dir), true);
|
|
crash::test_crash_if_requested();
|
|
unreachable!("VOELIN_TEST_CRASH is set");
|
|
}
|
|
|
|
#[test]
|
|
fn test_crash_in_child_process() {
|
|
let dir = temp_dir("child");
|
|
// Captured: the child's "FAILED" would look like a failure of this run.
|
|
let output = std::process::Command::new(std::env::current_exe().unwrap())
|
|
.args(["--exact", "child_process_crash", "--test-threads=1"])
|
|
.env("VOELIN_CRASH_CHILD_DIR", &dir)
|
|
.env("VOELIN_TEST_CRASH", "1")
|
|
.output()
|
|
.unwrap();
|
|
let log = String::from_utf8_lossy(&output.stderr);
|
|
assert!(!output.status.success(), "the child should have panicked: {log}");
|
|
// The next start finds the report.
|
|
let reports = crash::reports_in(&dir).unwrap();
|
|
assert_eq!(reports.len(), 1, "{reports:?}");
|
|
assert_eq!(reports[0].summary, "test crash requested with VOELIN_TEST_CRASH");
|
|
let text = std::fs::read_to_string(&reports[0].path).unwrap();
|
|
assert!(text.contains("Version: child"), "{text}");
|
|
std::fs::remove_dir_all(&dir).unwrap();
|
|
}
|