--- /dev/null
+Disk <removed>: 100 MiB, 104857600 bytes, 204800 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+
+>>> Script header accepted.
+>>> Script header accepted.
+>>> Script header accepted.
+>>> Script header accepted.
+>>> Created a new <removed>.
+<removed>1: Created a new <removed>.
+<removed>2: Created a new <removed>.
+<removed>3: Created a new <removed>.
+<removed>4: Created a new <removed>.
+<removed>5: Created a new <removed>.
+<removed>6: Created a new <removed>.
+<removed>7: Done.
+
+New situation:
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 4095 2048 1M 83 Linux
+<removed>2 4096 6143 2048 1M 83 Linux
+<removed>3 6144 108543 102400 50M 5 Extended
+<removed>4 108544 110591 2048 1M 83 Linux
+<removed>5 8192 10239 2048 1M 83 Linux
+<removed>6 12288 108543 96256 47M 83 Linux
+
+Partition table entries are not in disk order.
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
+Disk <removed>: 100 MiB, 104857600 bytes, 204800 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Old situation:
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 4095 2048 1M 83 Linux
+<removed>2 4096 6143 2048 1M 83 Linux
+<removed>3 6144 108543 102400 50M 5 Extended
+<removed>4 108544 110591 2048 1M 83 Linux
+<removed>5 8192 10239 2048 1M 83 Linux
+<removed>6 12288 108543 96256 47M 83 Linux
+
+Partition table entries are not in disk order.
+
+<removed>4:
+New situation:
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 4095 2048 1M 83 Linux
+<removed>2 4096 6143 2048 1M 83 Linux
+<removed>3 6144 108543 102400 50M 5 Extended
+<removed>4 108544 204799 96256 47M 83 Linux
+<removed>5 8192 10239 2048 1M 83 Linux
+<removed>6 12288 108543 96256 47M 83 Linux
+
+Partition table entries are not in disk order.
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
# GPT
test_label_resize gpt
+
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+
+ts_init_subtest "dos-unsorted"
+# create layout where partition #4 is the last on disk (by offset)
+# and there is freespace at the end of the disk. Note that #4 is not the last
+# partno on the disk. The libfdisk has to be able to check for the free space
+# independently on the partno, only offset+size matters.
+$TS_CMD_SFDISK --no-reread ${TS_DEVICE} >> $TS_OUTPUT 2>&1 <<EOF
+label: dos
+label-id: 0xda2e45ac
+device: ${TS_DEVICE}
+unit: sectors
+
+${TS_DEVICE}1 : start= 2048, size= 2048, type=83
+${TS_DEVICE}2 : start= 4096, size= 2048, type=83
+${TS_DEVICE}3 : start= 6144, size= 102400, type=5
+${TS_DEVICE}4 : start= 108544, size= 2048, type=83
+${TS_DEVICE}5 : start= 8192, size= 2048, type=83
+${TS_DEVICE}6 : start= 12288, size= 96256, type=83
+EOF
+# enlarge to use all space behind partition #4
+echo ',+,' | $TS_CMD_SFDISK --no-reread -N 4 ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
ts_finalize