Skip to content

Commit

Permalink
Add test for fake-hwclock.data
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanScherer committed Jan 6, 2020
1 parent 515c0c4 commit 1ce3d5a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/fake-hwclock.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load test_helper
export OS=$(uname -s)

setup() {
if [ ! -f fake-hwclock.img ]; then
# download SD card image with cloud-init
curl -L -o download.img.zip https://github.com/hypriot/image-builder-rpi/releases/download/1.12.0-rc2/hypriotos-rpi-1.12.0-rc2.img.zip
unzip download.img.zip
# cut only 70 MByte to flash faster
dd if=hypriotos-rpi-1.12.0-rc2.img of=fake-hwclock.img bs=1048576 count=70
fi
stub_diskutil
}

teardown() {
umount_sd_boot /tmp/boot
rm -f $img
unstub_diskutil
}

@test "fake-hwclock: flash updates fake-hwclock.data" {
expected=$(TZ=UTC date '+%Y-%m-%d %H:%M')

run ./flash -f -d $img fake-hwclock.img
assert_success

assert_output_contains Finished.

mount_sd_boot $img /tmp/boot
run cat /tmp/boot/fake-hwclock.data
assert_output_contains "$expected"

assert [ -e "/tmp/boot/fake-hwclock.data" ]
}

0 comments on commit 1ce3d5a

Please sign in to comment.