diff options
-rw-r--r-- | setup-disk.in | 2 | ||||
-rwxr-xr-x | tests/setup_disk_test | 87 |
2 files changed, 88 insertions, 1 deletions
diff --git a/setup-disk.in b/setup-disk.in index 399123a..fd0a8d8 100644 --- a/setup-disk.in +++ b/setup-disk.in @@ -864,7 +864,7 @@ setup_partitions() { ) | sfdisk --quiet --label $DISKLABEL $diskdev || return 1 # create device nodes if not exist - mdev -s + $MOCK mdev -s } # set up optional raid and create filesystem on boot device. diff --git a/tests/setup_disk_test b/tests/setup_disk_test index 654bfea..f935796 100755 --- a/tests/setup_disk_test +++ b/tests/setup_disk_test @@ -6,6 +6,8 @@ init_tests \ setup_disk_mode_none \ setup_disk_none \ setup_disk_func_find_disks \ + setup_disk_func_setup_partitions_dos \ + setup_disk_func_setup_partitions_gpt \ setup_disk_non_existing_block_dev setup_disk_usage_body() { @@ -73,6 +75,91 @@ setup_disk_func_find_disks_body() { setup-disk } +setup_disk_func_setup_partitions_dos_body() { + atf_require_prog sfdisk + init_env + + mkdir -p dev + truncate -s 100M dev/vda + + SETUP_DISK_TESTFUNC=setup_partitions \ + atf_check -s exit:0 \ + -o match:"mdev" \ + setup-disk dev/vda "0M," "10M,83,*", "10M,82", "10M,fd", ",8e" + + SETUP_DISK_TESTFUNC=find_partitions \ + atf_check -s exit:0 \ + -o match:"dev/vda1" \ + setup-disk dev/vda "boot" + + SETUP_DISK_TESTFUNC=find_partitions \ + atf_check -s exit:0 \ + -o match:"dev/vda1" \ + setup-disk dev/vda "linux" + + SETUP_DISK_TESTFUNC=find_partitions \ + atf_check -s exit:0 \ + -o match:"dev/vda2" \ + setup-disk dev/vda "swap" + + SETUP_DISK_TESTFUNC=find_partitions \ + atf_check -s exit:0 \ + -o match:"dev/vda3" \ + setup-disk dev/vda "raid" + + SETUP_DISK_TESTFUNC=find_partitions \ + atf_check -s exit:0 \ + -o match:"dev/vda4" \ + setup-disk dev/vda "lvm" +} + +setup_disk_func_setup_partitions_gpt_body() { + atf_require_prog sfdisk + init_env + + mkdir -p dev + truncate -s 200M dev/vda + + swap=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F + linux=0FC63DAF-8483-4772-8E79-3D69D8477DE4 + raid=A19D880F-05FC-4D3B-A006-743F0F84911E + lvm=E6D6D379-F507-44C2-A23C-238F2A3DF928 + prep=9E1A2d38-C612-4316-AA26-8B49521E5A8B + esp=C12A7328-F81F-11D2-BA4B-00A0C93EC93B + + SETUP_DISK_TESTFUNC=setup_partitions DISKLABEL=gpt \ + atf_check -s exit:0 \ + -o match:"mdev" \ + setup-disk dev/vda "0M," "30M,$esp" "30M,$swap" "30M,$linux" "30M,$raid" "30M,$lvm" + + sfdisk -d dev/vda + + SETUP_DISK_TESTFUNC=find_partitions DISKLABEL=gpt USE_EFI=1 \ + atf_check -s exit:0 \ + -o match:"dev/vda1" \ + setup-disk dev/vda "boot" + + SETUP_DISK_TESTFUNC=find_partitions DISKLABEL=gpt \ + atf_check -s exit:0 \ + -o match:"dev/vda2" \ + setup-disk dev/vda "swap" + + SETUP_DISK_TESTFUNC=find_partitions DISKLABEL=gpt \ + atf_check -s exit:0 \ + -o match:"dev/vda3" \ + setup-disk dev/vda "linux" + + SETUP_DISK_TESTFUNC=find_partitions DISKLABEL=gpt \ + atf_check -s exit:0 \ + -o match:"dev/vda4" \ + setup-disk dev/vda "raid" + + SETUP_DISK_TESTFUNC=find_partitions DISKLABEL=gpt \ + atf_check -s exit:0 \ + -o match:"dev/vda5" \ + setup-disk dev/vda "lvm" +} + setup_disk_non_existing_block_dev_body() { init_env atf_check -s not-exit:0 \ |