From bd5b5d9c5f1879b59d93eb0c65efdd45c4408751 Mon Sep 17 00:00:00 2001 From: Reactor Scram Date: Tue, 13 Feb 2024 11:12:57 -0600 Subject: [PATCH] ci(windows): test crash handling as part of smoke test (#3624) If this passes I'll use it to approve #3623 --- .github/workflows/_rust.yml | 2 ++ .../scripts/crash-handling-smoke-test.bash | 16 ++++++++++++++++ rust/windows-client/src-tauri/src/client.rs | 1 + 3 files changed, 19 insertions(+) create mode 100644 rust/windows-client/scripts/crash-handling-smoke-test.bash diff --git a/.github/workflows/_rust.yml b/.github/workflows/_rust.yml index 98ecb632b..10b825d84 100644 --- a/.github/workflows/_rust.yml +++ b/.github/workflows/_rust.yml @@ -110,6 +110,8 @@ jobs: run: cargo build -p firezone-windows-client - name: Run smoke test run: cargo run -p firezone-windows-client -- smoke-test + - name: Test that the crash handler produces a crash dump + run: bash scripts/crash-handling-smoke-test.bash # This should be identical to `build-push-windows-release-artifacts` in `cd.yml` except for the Github permissions, needs tag, and uploading step build-tauri: diff --git a/rust/windows-client/scripts/crash-handling-smoke-test.bash b/rust/windows-client/scripts/crash-handling-smoke-test.bash new file mode 100644 index 000000000..e9a59577f --- /dev/null +++ b/rust/windows-client/scripts/crash-handling-smoke-test.bash @@ -0,0 +1,16 @@ +# This script must run from an elevated shell so that Firezone won't try to elevate + +set -euo pipefail + +BUNDLE_ID="dev.firezone.client" +DUMP_PATH="$LOCALAPPDATA/$BUNDLE_ID/data/logs/last_crash.dmp" + +# Delete the crash file if present +rm -f "$DUMP_PATH" + +# Ignore the exit code, this is supposed to crash +cargo run -p firezone-windows-client -- --crash || true + +# Fail if the crash file wasn't written +stat "$DUMP_PATH" +rm "$DUMP_PATH" diff --git a/rust/windows-client/src-tauri/src/client.rs b/rust/windows-client/src-tauri/src/client.rs index ea95834d2..8f23744ce 100644 --- a/rust/windows-client/src-tauri/src/client.rs +++ b/rust/windows-client/src-tauri/src/client.rs @@ -154,6 +154,7 @@ struct Cli { command: Option, /// Crash the `Controller` task to test error handling + /// Formerly `--crash-on-purpose` #[arg(long, hide = true)] crash: bool, /// Error out of the `Controller` task to test error handling