summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArvin Schnell <aschnell@suse.com>2022-05-11 14:02:21 +0000
committerBrian C. Lane <bcl@redhat.com>2022-05-13 10:32:06 -0700
commit61b3a9733c0e0a79ccc43096642d378c8706add6 (patch)
tree48d20b665ea5ea3f8a85d550046902f56a20404a /tests
parentcec533a00a2cd0b64a7a0f5debc26554f6025831 (diff)
downloadparted-61b3a9733c0e0a79ccc43096642d378c8706add6.tar.gz
parted: add type command
Include the partition type-id and type-uuid in the JSON output. Also add the the command 'type' to set them. Remove redundant flags from DosPartitionData and use only the system variable. Signed-off-by: Brian C. Lane <bcl@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rwxr-xr-xtests/t0800-json-gpt.sh2
-rwxr-xr-xtests/t0801-json-msdos.sh5
-rwxr-xr-xtests/t0900-type-gpt.sh69
-rwxr-xr-xtests/t0901-type-gpt-invalid.sh35
-rwxr-xr-xtests/t0910-type-dos.sh69
-rwxr-xr-xtests/t0911-type-dos-invalid.sh35
-rw-r--r--tests/t2400-dos-hfs-partition-type.sh2
-rwxr-xr-xtests/t3300-palo-prep.sh8
-rw-r--r--tests/t3310-flags.sh4
10 files changed, 227 insertions, 6 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5cb7aa3..2da653b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -43,6 +43,10 @@ TESTS = \
t0501-duplicate.sh \
t0800-json-gpt.sh \
t0801-json-msdos.sh \
+ t0900-type-gpt.sh \
+ t0901-type-gpt-invalid.sh \
+ t0910-type-dos.sh \
+ t0911-type-dos-invalid.sh \
t1100-busy-label.sh \
t1101-busy-partition.sh \
t1102-loop-label.sh \
diff --git a/tests/t0800-json-gpt.sh b/tests/t0800-json-gpt.sh
index 8dd1862..354c0bd 100755
--- a/tests/t0800-json-gpt.sh
+++ b/tests/t0800-json-gpt.sh
@@ -62,6 +62,7 @@ cat <<EOF > exp || fail=1
"end": "20479s",
"size": "10240s",
"type": "primary",
+ "type-uuid": "0fc63daf-8483-4772-8e79-3d69d8477de4",
"name": "test1"
},{
"number": 2,
@@ -69,6 +70,7 @@ cat <<EOF > exp || fail=1
"end": "61439s",
"size": "40960s",
"type": "primary",
+ "type-uuid": "a19d880f-05fc-4d3b-a006-743f0f84911e",
"name": "test2",
"flags": [
"raid"
diff --git a/tests/t0801-json-msdos.sh b/tests/t0801-json-msdos.sh
index a14a5af..c5446d8 100755
--- a/tests/t0801-json-msdos.sh
+++ b/tests/t0801-json-msdos.sh
@@ -52,13 +52,15 @@ cat <<EOF > exp || fail=1
"start": "5.00MiB",
"end": "10.0MiB",
"size": "5.00MiB",
- "type": "primary"
+ "type": "primary",
+ "type-id": "0x83"
},{
"number": 2,
"start": "10.0MiB",
"end": "30.0MiB",
"size": "20.0MiB",
"type": "extended",
+ "type-id": "0x0f",
"flags": [
"lba"
]
@@ -68,6 +70,7 @@ cat <<EOF > exp || fail=1
"end": "20.0MiB",
"size": "10.0MiB",
"type": "logical",
+ "type-id": "0x8e",
"flags": [
"lvm"
]
diff --git a/tests/t0900-type-gpt.sh b/tests/t0900-type-gpt.sh
new file mode 100755
index 0000000..2014820
--- /dev/null
+++ b/tests/t0900-type-gpt.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+# Test type command with GPT label
+
+# Copyright (C) 2022 SUSE LLC
+
+# This program 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 3 of the License, or
+# (at your option) any later version.
+
+# This program 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.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+
+dev=loop-file
+
+# create device
+truncate --size 50MiB "$dev" || fail=1
+
+# create gpt label and one partition
+parted --script "$dev" mklabel gpt > out 2>&1 || fail=1
+parted --script "$dev" mkpart "''" "linux-swap" 10% 20% > out 2>&1 || fail=1
+
+# set type-uuid
+parted --script "$dev" type 1 "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f" || fail=1
+
+# print with json format
+parted --script --json "$dev" unit s print > out 2>&1 || fail=1
+
+cat <<EOF > exp || fail=1
+{
+ "disk": {
+ "path": "loop-file",
+ "size": "102400s",
+ "model": "",
+ "transport": "file",
+ "logical-sector-size": 512,
+ "physical-sector-size": 512,
+ "label": "gpt",
+ "max-partitions": 128,
+ "partitions": [
+ {
+ "number": 1,
+ "start": "10240s",
+ "end": "20479s",
+ "size": "10240s",
+ "type": "primary",
+ "type-uuid": "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f"
+ }
+ ]
+ }
+}
+EOF
+
+# remove full path of device from actual output
+mv out o2 && sed "s,\"/.*/$dev\",\"$dev\"," o2 > out || fail=1
+
+# check for expected output
+compare exp out || fail=1
+
+Exit $fail
diff --git a/tests/t0901-type-gpt-invalid.sh b/tests/t0901-type-gpt-invalid.sh
new file mode 100755
index 0000000..681df3a
--- /dev/null
+++ b/tests/t0901-type-gpt-invalid.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Test type command with GPT label
+
+# Copyright (C) 2022 SUSE LLC
+
+# This program 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 3 of the License, or
+# (at your option) any later version.
+
+# This program 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.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+
+dev=loop-file
+
+# create device
+truncate --size 50MiB "$dev" || fail=1
+
+# create gpt label and one partition
+parted --script "$dev" mklabel gpt > out 2>&1 || fail=1
+parted --script "$dev" mkpart "''" "linux-swap" 10% 20% > out 2>&1 || fail=1
+
+# set type-uuid
+parted --script "$dev" type 1 "invalidd-a4ab-43c4-84e5-0933c84b4f4f" && fail=1
+
+Exit $fail
diff --git a/tests/t0910-type-dos.sh b/tests/t0910-type-dos.sh
new file mode 100755
index 0000000..d7cc37f
--- /dev/null
+++ b/tests/t0910-type-dos.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+# Test type command with MS-DOS label
+
+# Copyright (C) 2022 SUSE LLC
+
+# This program 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 3 of the License, or
+# (at your option) any later version.
+
+# This program 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.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+
+dev=loop-file
+
+# create device
+truncate --size 50MiB "$dev" || fail=1
+
+# create msdos label and one partition
+parted --script "$dev" mklabel msdos > out 2>&1 || fail=1
+parted --script "$dev" mkpart primary "linux-swap" 10% 20% > out 2>&1 || fail=1
+
+# set type-id
+parted --script "$dev" type 1 "0x83" || fail=1
+
+# print with json format
+parted --script --json "$dev" unit s print > out 2>&1 || fail=1
+
+cat <<EOF > exp || fail=1
+{
+ "disk": {
+ "path": "loop-file",
+ "size": "102400s",
+ "model": "",
+ "transport": "file",
+ "logical-sector-size": 512,
+ "physical-sector-size": 512,
+ "label": "msdos",
+ "max-partitions": 4,
+ "partitions": [
+ {
+ "number": 1,
+ "start": "10240s",
+ "end": "20479s",
+ "size": "10240s",
+ "type": "primary",
+ "type-id": "0x83"
+ }
+ ]
+ }
+}
+EOF
+
+# remove full path of device from actual output
+mv out o2 && sed "s,\"/.*/$dev\",\"$dev\"," o2 > out || fail=1
+
+# check for expected output
+compare exp out || fail=1
+
+Exit $fail
diff --git a/tests/t0911-type-dos-invalid.sh b/tests/t0911-type-dos-invalid.sh
new file mode 100755
index 0000000..f1036d1
--- /dev/null
+++ b/tests/t0911-type-dos-invalid.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Test type command with MS-DOS label
+
+# Copyright (C) 2022 SUSE LLC
+
+# This program 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 3 of the License, or
+# (at your option) any later version.
+
+# This program 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.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+
+dev=loop-file
+
+# create device
+truncate --size 50MiB "$dev" || fail=1
+
+# create msdos label and one partition
+parted --script "$dev" mklabel msdos > out 2>&1 || fail=1
+parted --script "$dev" mkpart primary "linux-swap" 10% 20% > out 2>&1 || fail=1
+
+# set type-id
+parted --script "$dev" type 1 "0x101" && fail=1
+
+Exit $fail
diff --git a/tests/t2400-dos-hfs-partition-type.sh b/tests/t2400-dos-hfs-partition-type.sh
index 6733683..8c54ec4 100644
--- a/tests/t2400-dos-hfs-partition-type.sh
+++ b/tests/t2400-dos-hfs-partition-type.sh
@@ -24,7 +24,7 @@ n_sectors=8000
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || framework_failure
-# create a GPT partition table
+# create a MS-DOS partition table
parted -s $dev mklabel msdos \
mkpart pri hfs 2048s 4095s \
mkpart pri hfs+ 4096s 6143s > out 2>&1 || fail=1
diff --git a/tests/t3300-palo-prep.sh b/tests/t3300-palo-prep.sh
index 5005e0e..efe54db 100755
--- a/tests/t3300-palo-prep.sh
+++ b/tests/t3300-palo-prep.sh
@@ -20,9 +20,9 @@
ss=$sector_size_
cat > exp <<EOF || framework_failure
-1:2048s:4095s:2048s:ext2::lba, palo;
-1:2048s:4095s:2048s:ext2::lba, prep;
-1:2048s:4095s:2048s:ext2::lba, palo;
+1:2048s:4095s:2048s:ext2::palo;
+1:2048s:4095s:2048s:ext2::prep;
+1:2048s:4095s:2048s:ext2::palo;
EOF
dev=dev-file
@@ -37,7 +37,7 @@ parted -m -s $dev mklabel msdos \
set 1 palo on u s print \
> out 2> err || fail=1
-grep -E '^1:2048s:4095s:2048s:ext2::lba, p...;$' out > k; mv k out
+grep -E '^1:2048s:4095s:2048s:ext2::p...;$' out > k; mv k out
compare exp out || fail=1
diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh
index f2001c5..b35d443 100644
--- a/tests/t3310-flags.sh
+++ b/tests/t3310-flags.sh
@@ -91,6 +91,10 @@ for table_type in aix amiga atari bsd dvh gpt mac msdos pc98 sun loop; do
# test to fail.
flags=`echo "$flags" | egrep -v 'lvm|raid'`
;;
+ msdos) # FIXME: Exclude flags that can only be set in combination
+ # with certain other flags.
+ flags=`echo "$flags" | egrep -v 'hidden|lba'`
+ ;;
esac
for mode in on_only on_and_off ; do