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
7 changes: 6 additions & 1 deletion bin/prod/get-recore-serial-number
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ set -euo pipefail
CONFIG_DIR="${REFLASH_CONFIG_DIR:-/mnt/config}"

mount-config
# A board with no serial number provisioned yet - the exact case this
# script exists to detect - means serial_number doesn't exist, so cat
# fails and set -e exits before reaching unmount-config, leaving the
# mount (and its transient systemd unit) dangling. Make the unmount
# unconditional instead.
trap unmount-config EXIT
cat "$CONFIG_DIR/serial_number"
unmount-config
12 changes: 12 additions & 0 deletions test/bats/getters.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,15 @@ teardown() { teardown_sandbox; }
[ "$status" -eq 0 ]
[ "$output" = "RC-0001-XYZ" ]
}

@test "get-recore-serial-number: still unmounts when serial_number is missing (#83 fallout)" {
export REFLASH_CONFIG_DIR="$SANDBOX/config"
mkdir -p "$REFLASH_CONFIG_DIR"
# No serial_number file - this is exactly the state a not-yet-provisioned
# board is in, i.e. the case this script exists to detect.
stub_silent mount-config
stub_silent unmount-config
run "$PROD_BIN/get-recore-serial-number"
[ "$status" -ne 0 ]
assert_called_with "unmount-config"
}
Loading