From: Sebastian Parschauer <sparschauer@suse.de>
Date: Wed Sep 13 11:14:42 2017 +0200
Subject: tests: Adapt to SUSE parted
Patch-mainline: no, custom SUSE patch

Sync with SLE15 parted
Tests: t2310

msdos type flag
Tests: t2200, t2310, t3300, t4100, t6002, t9042
For: parted-type.patch

Change dm partition name from 'pN' to '-partN'
Tests: t6001, t6002
For: libparted-partition-naming.patch
---
---
 tests/t2200-dos-label-recog.sh                  |    2 -
 tests/t2310-dos-extended-2-sector-min-offset.sh |   25 ++++++++----------------
 tests/t3300-palo-prep.sh                        |    8 +++----
 tests/t4100-msdos-partition-limits.sh           |    4 +--
 tests/t4100-msdos-starting-sector.sh            |    2 -
 tests/t6001-psep.sh                             |    8 +++----
 tests/t6002-dm-busy.sh                          |   14 ++++++-------
 tests/t9042-dos-partition-limit.sh              |    4 +--
 8 files changed, 30 insertions(+), 37 deletions(-)

--- a/tests/t2200-dos-label-recog.sh
+++ b/tests/t2200-dos-label-recog.sh
@@ -45,7 +45,7 @@ printf FAT | dd bs=1c seek=82 count=3 of
 # print the partition table
 parted -m -s $dev unit s p > out || fail=1
 tail -2 out > k && mv k out || fail=1
-printf "1:2048s:4095s:2048s:::;\n2:4096s:8191s:4096s:::;\n" > exp || fail=1
+printf "1:2048s:4095s:2048s:::type=83;\n2:4096s:8191s:4096s:::type=83;\n" > exp || fail=1
 
 compare exp out || fail=1
 
--- a/tests/t4100-msdos-starting-sector.sh
+++ b/tests/t4100-msdos-starting-sector.sh
@@ -56,7 +56,7 @@ cat <<EOF > exp || fail=1
 BYT;
 path:${N}s:file:$ss:$ss:msdos::;
 1:32s:2047s:2016s:free;
-1:2048s:4095s:2048s:::;
+1:2048s:4095s:2048s:::type=83;
 EOF
 
 # create a partition at the end of the label
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
@@ -31,9 +31,9 @@ linear2_=plinear-$$foo
 d1= d2=
 f1= f2=
 cleanup_fn_() {
-    dmsetup remove ${linear_}p1
+    dmsetup remove ${linear_}-part1
     dmsetup remove $linear_
-    dmsetup remove ${linear2_}1
+    dmsetup remove ${linear2_}-part1
     dmsetup remove $linear2_
     test -n "$d1" && losetup -d "$d1"
     test -n "$d2" && losetup -d "$d2"
@@ -56,7 +56,7 @@ parted -s $dev mklabel msdos mkpart prim
 compare /dev/null out || fail=1
 
 #make sure device name is correct
-wait_for_dev_to_appear_ ${dev}p1 || fail=1
+wait_for_dev_to_appear_ ${dev}-part1 || fail=1
 
 #repeat on name not ending in a digit
 # setup: create a mapping
@@ -68,7 +68,7 @@ parted -s $dev mklabel msdos mkpart prim
 compare /dev/null out || fail=1
 
 #make sure device name is correct
-wait_for_dev_to_appear_ ${dev}1 || fail=1
+wait_for_dev_to_appear_ ${dev}-part1 || fail=1
 
 if [ -n "$fail" ]; then
     ls /dev/mapper
--- a/tests/t9042-dos-partition-limit.sh
+++ b/tests/t9042-dos-partition-limit.sh
@@ -41,7 +41,7 @@ scsi_dev=$(cat dev-name)
 n=$((n_MiB * sectors_per_MiB))
 printf '%s\n' "BYT;" \
     "$scsi_dev:${n}s:scsi:$ss:$ss:msdos:Linux scsi_debug:;" \
-    "1:$((start-2))s:$((n-1))s:$((n-start+2))s:::lba;" \
+    "1:$((start-2))s:$((n-1))s:$((n-start+2))s:::lba, type=0f;" \
   > exp || fail=1
 
 parted -s $scsi_dev mklabel msdos || fail=1
@@ -51,7 +51,7 @@ i=1
 while :; do
     end=$((start + partition_sectors - 2))
     parted -s -a min $scsi_dev mkpart logical ${start}s ${end}s || fail=1
-    printf "$((i+4)):${start}s:${end}s:$((end-start+1))s:::;\n" >> exp
+    printf "$((i+4)):${start}s:${end}s:$((end-start+1))s:::type=83;\n" >> exp
     test $i = $((n_partitions - 1)) && break
     start=$((start + partition_sectors))
     i=$((i+1))
--- a/tests/t4100-msdos-partition-limits.sh
+++ b/tests/t4100-msdos-partition-limits.sh
@@ -82,7 +82,7 @@ do_mkpart $n $end || fail=1
 # print the result
 parted -s $dev unit s p > out 2>&1 || fail=1
 sed -n "/^  *1  *$n/s/  */ /gp" out|sed "s/  *\$//" > k && mv k out || fail=1
-echo " 1 ${n}s ${end}s 4294967295s primary" > exp || fail=1
+echo " 1 ${n}s ${end}s 4294967295s primary type=83" > exp || fail=1
 compare exp out || fail=1
 
 # a partition length of exactly 2^32 sectors provokes failure.
@@ -122,7 +122,7 @@ Partition Table: $table_type
 Disk Flags:
 
 Number  Start        End          Size   Type     File system  Flags
- 1      4294967295s  4294968294s  1000s  primary
+ 1      4294967295s  4294968294s  1000s  primary               type=83
 
 EOF
 
--- a/tests/t2310-dos-extended-2-sector-min-offset.sh
+++ b/tests/t2310-dos-extended-2-sector-min-offset.sh
@@ -1,10 +1,8 @@
 #!/bin/sh
-# Ensure that parted leaves at least 2 sectors between the beginning
+# Ensure that parted allows a single sector between the beginning
 # of an extended partition and the first logical partition.
-# Before parted-2.3, it could be made to leave just one, and that
-# would cause trouble with the Linux kernel.
 
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2014 Free Software Foundation, Inc.
 
 # 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
@@ -25,7 +23,8 @@ require_root_
 require_scsi_debug_module_
 
 # create memory-backed device
-scsi_debug_setup_ dev_size_mb=1 > dev-name ||
+ss=$sector_size_
+scsi_debug_setup_ sector_size=$ss dev_size_mb=1 > dev-name ||
   skip_ 'failed to create scsi_debug device'
 scsi_dev=$(cat dev-name)
 p1=${scsi_dev}1
@@ -33,9 +32,9 @@ p5=${scsi_dev}5
 
 cat <<EOF > exp || framework_failure
 BYT;
-$scsi_dev:2048s:scsi:512:512:msdos:Linux scsi_debug:;
-1:64s:128s:65s:::lba;
-5:66s:128s:63s:::;
+$scsi_dev:$((2048*512/$ss))s:scsi:$ss:$ss:msdos:Linux scsi_debug:;
+1:64s:128s:65s:::lba, type=0f;
+5:65s:128s:64s:::type=83;
 EOF
 
 cat <<EOF > err.exp || framework_failure
@@ -48,15 +47,9 @@ parted --align=min -s $scsi_dev mkpart e
 parted -m -s $scsi_dev u s print
 compare /dev/null out || fail=1
 
-# Provoke a failure by trying to create a partition that starts just
+# Trying to create a partition that starts just
 # one sector after the start of the extended partition.
-parted --align=min -s $scsi_dev mkpart logical 65s 128s > err 2>&1 && fail=1
-compare err.exp err || fail=1
-
-# The above failed, but created the partition nonetheless.  Remove it.
-parted -s $scsi_dev rm 5 || fail=1
-
-parted --align=min -s $scsi_dev mkpart logical 66s 128s > out 2>&1 || fail=1
+parted --align=min -s $scsi_dev mkpart logical 65s 128s > out 2>&1 || fail=1
 compare /dev/null out || fail=1
 
 parted -m -s $scsi_dev u s print > out 2>&1
--- 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:::palo;
-1:2048s:4095s:2048s:::prep;
-1:2048s:4095s:2048s:::palo;
+1:2048s:4095s:2048s:::palo, type=f0;
+1:2048s:4095s:2048s:::prep, type=41;
+1:2048s:4095s:2048s:::palo, type=f0;
 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:::p...;$' out > k; mv k out
+grep -E '^1:2048s:4095s:2048s:::p..., type=..;$' out > k; mv k out
 
 compare exp out || fail=1
 
--- a/tests/t6002-dm-busy.sh
+++ b/tests/t6002-dm-busy.sh
@@ -35,9 +35,9 @@ d1=
 f1=
 dev=
 cleanup_fn_() {
-    umount "${dev}p2" > /dev/null 2>&1
-    dmsetup remove ${linear_}p1
-    dmsetup remove ${linear_}p2
+    umount "${dev}-part2" > /dev/null 2>&1
+    dmsetup remove ${linear_}-part1
+    dmsetup remove ${linear_}-part2
     dmsetup remove $linear_
     test -n "$d1" && losetup -d "$d1"
     rm -f "$f1"
@@ -62,14 +62,14 @@ parted -s $dev -a none mkpart primary fa
 compare /dev/null out || fail=1
 
 # wait for new partition device to appear
-wait_for_dev_to_appear_ ${dev}p2 || fail_ ${dev}p2 did not appear
+wait_for_dev_to_appear_ ${dev}-part2 || fail_ ${dev}-part2 did not appear
 
-mkfs.vfat -F 32 ${dev}p2 || fail_ mkfs.vfat failed
+mkfs.vfat -F 32 ${dev}-part2 || fail_ mkfs.vfat failed
 
 mount_point=$(pwd)/mnt
 
 mkdir $mount_point || fail=1
-mount "${dev}p2" "$mount_point" || fail=1
+mount "${dev}-part2" "$mount_point" || fail=1
 
 # Removal of unmounted partition must succeed.
 parted -s "$dev" rm 1 > /dev/null 2>&1 || fail=1
@@ -84,7 +84,7 @@ sed "s,^$dev,DEV," out > k; mv k out
 cat <<EOF >> exp || fail=1
 BYT;
 DEV:${n}s:dm:512:512:msdos:Linux device-mapper (linear):;
-2:1001s:200000s:199000s:fat32::lba;
+2:1001s:200000s:199000s:fat32::lba, type=0c;
 EOF
 
 compare exp out || fail=1
