Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/sbin/gpt Add test for type, set, unset



details:   https://anonhg.NetBSD.org/src/rev/7e604304efde
branches:  trunk
changeset: 342096:7e604304efde
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Dec 06 00:38:30 2015 +0000

description:
Add test for type, set, unset

diffstat:

 tests/sbin/gpt/t_gpt.sh |  53 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 50 insertions(+), 3 deletions(-)

diffs (102 lines):

diff -r cf298c9ec2b7 -r 7e604304efde tests/sbin/gpt/t_gpt.sh
--- a/tests/sbin/gpt/t_gpt.sh   Sun Dec 06 00:33:44 2015 +0000
+++ b/tests/sbin/gpt/t_gpt.sh   Sun Dec 06 00:38:30 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_gpt.sh,v 1.10 2015/12/05 18:53:29 christos Exp $
+# $NetBSD: t_gpt.sh,v 1.11 2015/12/06 00:38:30 christos Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -41,6 +41,12 @@
        atf_check -s exit:0 -o empty -e empty "$@"
 }
 
+inline() {
+       local inline="$1"
+       shift
+       atf_check -s exit:0 -e empty -o inline:"$inline" "$@"
+}
+
 match() {
        local match="$1"
        shift
@@ -105,7 +111,6 @@
 
 partbootmsg() {
        echo "^$disk: Partition $1 marked as bootable\$"
-
 }
 
 recovermsg() {
@@ -117,6 +122,14 @@
        echo 'using "Microsoft Basic Data"$'
 }
 
+attrmsg() {
+       echo "^$disk: Partition $1 attributes updated\$"
+}
+
+typemsg() {
+       echo "^$disk: Partition $1 type changed\$"
+}
+
 atf_test_case create_empty
 create_empty_head() {
        atf_set "descr" "Create empty disk"
@@ -138,6 +151,38 @@
        check_2part
 }
 
+atf_test_case change_attr_2part
+change_attr_2part_head() {
+       atf_set "descr" "Change the attribute of 2 partition disk"
+}
+
+change_attr_2part_body() {
+       prepare_2part
+       match "$(attrmsg 1)" gpt set -i 1 -a biosboot,bootme "$disk"
+       save attr gpt show -i 1 "$disk"
+       match "^Attributes: biosboot,bootme\$" tail -1 attr
+       match "$(attrmsg 1)" gpt unset -i 1 -a biosboot,bootme "$disk"
+       save attr gpt show -i 1 "$disk"
+       match "^Attributes: None\$" tail -1 attr
+}
+
+atf_test_case change_type_2part
+change_type_2part_head() {
+       atf_set "descr" "Change the partition type type of 2 partition disk"
+}
+
+change_type_2part_body() {
+       prepare_2part
+       match "$(typemsg 1)" gpt type -i 1 -T apple "$disk"
+       save type gpt show -i 1 "$disk"
+       inline "Type: apple (48465300-0000-11aa-aa11-00306543ecac)\n" \
+           grep "^Type:" type
+       match "$(typemsg 1)" gpt type -i 1 -T efi "$disk"
+       save type gpt show -i 1 "$disk"
+       inline "Type: efi (c12a7328-f81f-11d2-ba4b-00a0c93ec93b)\n" \
+           grep "^Type:" type
+}
+
 atf_test_case backup_2part
 backup_2part_head() {
        atf_set "descr" "Backup 2 partition disk"
@@ -238,7 +283,7 @@
        silence dd msgfmt=quiet if="$disk" of=bootblk bs=1 count="$bootsz"
        silence cmp "$bootblk" bootblk
        save bootattr gpt show -i 2 "$disk"
-       match "^  legacy BIOS boot partition\$" tail -1 bootattr
+       match "^Attributes: biosboot\$" tail -1 bootattr
 }
 
 atf_test_case migrate_disklabel
@@ -258,6 +303,8 @@
 atf_init_test_cases() {
        atf_add_test_case create_empty
        atf_add_test_case create_2part
+       atf_add_test_case change_attr_2part
+       atf_add_test_case change_type_2part
        atf_add_test_case backup_2part
        atf_add_test_case remove_2part
        atf_add_test_case restore_2part



Home | Main Index | Thread Index | Old Index