summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Marineau2015-05-03 00:52:48 +0200
committerKarel Zak2015-05-05 12:39:36 +0200
commit4a4a0927c6b761f7b8b29b00491b22b3553720e8 (patch)
tree91dc14b26e6650b10dbb94af2535354724b3736c /tests
parentlibfdisk: (gpt) fix check for beginning of protective partition (diff)
downloadkernel-qcow2-util-linux-4a4a0927c6b761f7b8b29b00491b22b3553720e8.tar.gz
kernel-qcow2-util-linux-4a4a0927c6b761f7b8b29b00491b22b3553720e8.tar.xz
kernel-qcow2-util-linux-4a4a0927c6b761f7b8b29b00491b22b3553720e8.zip
libfdisk: (gpt) add API for raw partition attributes
The existing APIs can only toggle individual bits or get and set bits in a complex text representation, making it impractical to use libfdisk for manipulating the GPT partition attribute field in more complex ways such as updating a value that is multiple bits wide. For example priority based partition selection originally designed for ChromeOS includes two integer values that are 4-bits wide. http://www.chromium.org/chromium-os/chromiumos-design-docs/disk-format#TOC-Trusting-the-GPT [kzak@redhat.com: - add new symbols to .sym file and docs - remove unused variables from test program] Signed-off-by: Michael Marineau <michael.marineau@coreos.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/commands.sh1
-rw-r--r--tests/expected/libfdisk/gpt-all-defaults21
-rw-r--r--tests/expected/libfdisk/gpt-getattr2
-rw-r--r--tests/expected/libfdisk/gpt-setattr2
-rwxr-xr-xtests/ts/libfdisk/gpt52
5 files changed, 78 insertions, 0 deletions
diff --git a/tests/commands.sh b/tests/commands.sh
index e3ac43394..dfb19e315 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -7,6 +7,7 @@ TS_HELPER_CPUSET="$top_builddir/test_cpuset"
TS_HELPER_DMESG="$top_builddir/test_dmesg"
TS_HELPER_ISLOCAL="$top_builddir/test_islocal"
TS_HELPER_ISMOUNTED="$top_builddir/test_ismounted"
+TS_HELPER_LIBFDISK_GPT="$top_builddir/test_fdisk_gpt"
TS_HELPER_LIBMOUNT_CONTEXT="$top_builddir/test_mount_context"
TS_HELPER_LIBMOUNT_LOCK="$top_builddir/test_mount_lock"
TS_HELPER_LIBMOUNT_OPTSTR="$top_builddir/test_mount_optstr"
diff --git a/tests/expected/libfdisk/gpt-all-defaults b/tests/expected/libfdisk/gpt-all-defaults
new file mode 100644
index 000000000..883680744
--- /dev/null
+++ b/tests/expected/libfdisk/gpt-all-defaults
@@ -0,0 +1,21 @@
+Checking that no-one is using this disk right now ... OK
+
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+
+>>> Script header accepted.
+>>> Script header accepted.
+>>> Created a new <removed>.
+Created a new <removed>.
+<removed>2: Created a new <removed>.
+<removed>3:
+New situation:
+
+Device Start End Sectors Size Type
+<removed>1 2048 12287 10240 5M Linux filesystem
+<removed>2 12288 20446 8159 4M Linux filesystem
+
+The partition table has been altered.
+Syncing disks.
diff --git a/tests/expected/libfdisk/gpt-getattr b/tests/expected/libfdisk/gpt-getattr
new file mode 100644
index 000000000..559a9ae72
--- /dev/null
+++ b/tests/expected/libfdisk/gpt-getattr
@@ -0,0 +1,2 @@
+1: 0x0001000000000001
+2: 0x4030000000000000
diff --git a/tests/expected/libfdisk/gpt-setattr b/tests/expected/libfdisk/gpt-setattr
new file mode 100644
index 000000000..41af260f4
--- /dev/null
+++ b/tests/expected/libfdisk/gpt-setattr
@@ -0,0 +1,2 @@
+GUID:56,57,58,59,60,61,62,63
+LegacyBIOSBootable
diff --git a/tests/ts/libfdisk/gpt b/tests/ts/libfdisk/gpt
new file mode 100755
index 000000000..2de6b1a57
--- /dev/null
+++ b/tests/ts/libfdisk/gpt
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="GPT"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+TESTPROG="$TS_HELPER_LIBFDISK_GPT"
+ts_check_test_command "$TESTPROG"
+ts_check_test_command "$TS_CMD_SFDISK"
+
+TEST_IMAGE_NAME=$(ts_image_init 10)
+
+ts_init_subtest "all-defaults"
+$TS_CMD_SFDISK --unit S ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 <<EOF
+label: gpt
+label-id: b181c399-4711-4c52-8b65-9e764541218d
+
+size=5M, attrs="RequiredPartiton,48"
+attrs="52,53,62"
+EOF
+ts_fdisk_clean ${TEST_IMAGE_NAME}
+ts_finalize_subtest
+
+ts_init_subtest "getattr"
+ts_valgrind $TESTPROG --getattr ${TEST_IMAGE_NAME} 1 >> $TS_OUTPUT 2>&1
+ts_valgrind $TESTPROG --getattr ${TEST_IMAGE_NAME} 2 >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "setattr"
+ts_valgrind $TESTPROG --setattr ${TEST_IMAGE_NAME} 1 0xff00000000000000 >> $TS_OUTPUT 2>&1
+ts_valgrind $TESTPROG --setattr ${TEST_IMAGE_NAME} 2 0x4 >> $TS_OUTPUT 2>&1
+$TS_CMD_SFDISK --part-attrs ${TEST_IMAGE_NAME} 1 >> $TS_OUTPUT 2>&1
+$TS_CMD_SFDISK --part-attrs ${TEST_IMAGE_NAME} 2 >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+ts_finalize