sysdeploy/tests/drive.sh
Peter Surda d691022aef
fix: typos and backwards compatibility
- forgot again assertContains isn't supported on bionic's shunit2
2021-02-28 09:28:37 +01:00

56 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
function test_partitioning()
{
local img
local test_version=20210228
local min_version=20210101
local max_version=20211231
img=$(mktemp -u)
dd if=/dev/zero of="$img" bs=1M seek=16384 count=0 2> /dev/null
setup_drive "$img"
output=$(parted -ms "$img" -- print)
sed -i "s|T_E_M_P|$img|g;" tests/data/parted.dat
assertEquals "$(cat tests/data/parted.dat)" "$output"
rename_partition "$img" 2 "root $test_version"
output=$(parted -ms "$img" -- print)
sed -i "s|T_E_M_P|$img|g;" tests/data/rename.dat
assertEquals "$(cat tests/data/rename.dat)" "$output"
version_from_partnum "$img" 2
assertEquals "$test_version" "$version"
version_from_partnum "$img" 3
assertEquals "$min_version" "$version"
version_from_partnum "$img" 4
assertEquals "$max_version" "$version"
find_unused "$img"
assertEquals 3 "$unused"
rename_partition "$img" 3 "root $min_version"
find_oldest "$img"
assertEquals "$min_version" "$oldest"
rename_partition "$img" 4 "root $max_version"
find_newest "$img"
assertEquals "$max_version" "$newest"
partition_list "$img"
assertEquals "1 2 3 4 5" "$partitions"
rm -f "$img"
}
function oneTimeSetUp()
{
. drive.inc
}
# Load shUnit2.
. /usr/bin/shunit2