[parted-devel] [PATCH 2/4] tests: Update tests for new behavior

Brian C. Lane bcl at redhat.com
Sat Mar 29 03:46:17 UTC 2014


In gpt-header-move.py LastUsableLBA needs to be updated when moving the
header, otherwise it overlaps and that's not what we are testing for.

Fixup the expected text in the test to use the 'use more space' prompt.

* tests/gpt-header-move.py: Update LastUsableLBA
* tests/t0210-gpt-resized-partition-entry-array.sh: Use correct prompt.
* tests/t0282-gpt-move-backup.sh: Use correct prompt
---
 tests/gpt-header-move.py                         |  6 +++++-
 tests/t0210-gpt-resized-partition-entry-array.sh | 26 +++++++++++++++++++++---
 tests/t0282-gpt-move-backup.sh                   |  4 ++--
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/tests/gpt-header-move.py b/tests/gpt-header-move.py
index 69d1479..78709f6 100644
--- a/tests/gpt-header-move.py
+++ b/tests/gpt-header-move.py
@@ -1,5 +1,5 @@
 # open img file, subtract 33 from altlba address, and move the last 33 sectors
-# back by 33 sectors
+# back by 33 sectors. Also adjust the LastUsableLBA value by -33
 
 from struct import *
 from zipfile import crc32
@@ -9,8 +9,10 @@ file = open(sys.argv[1],'rb+')
 file.seek(512)
 gptheader = file.read(512)
 altlba = unpack_from('q', gptheader,offset=32)[0]
+lastlba = unpack_from('q', gptheader,offset=48)[0]
 gptheader = array.array('c',gptheader)
 pack_into('Q', gptheader, 32, altlba-33)
+pack_into('Q', gptheader, 48, lastlba-33)
 #zero header crc
 pack_into('L', gptheader, 16, 0)
 #compute new crc
@@ -26,6 +28,8 @@ altlba -= 33
 gptheader = array.array('c',gptheader)
 #update mylba
 pack_into('Q', gptheader, 24, altlba)
+#update the LastUsableLBA
+pack_into('Q', gptheader, 48, lastlba-33)
 #update table lba
 pack_into('Q', gptheader, 72, altlba-32)
 #zero header crc
diff --git a/tests/t0210-gpt-resized-partition-entry-array.sh b/tests/t0210-gpt-resized-partition-entry-array.sh
index 512f342..8e0a251 100755
--- a/tests/t0210-gpt-resized-partition-entry-array.sh
+++ b/tests/t0210-gpt-resized-partition-entry-array.sh
@@ -23,6 +23,7 @@ require_perl_digest_crc_
 if test $(uname -m) != x86_64; then
   skip_ 'this test only works on little-endian systems'
 fi
+require_512_byte_sector_size_
 
 ss=$sector_size_
 
@@ -38,9 +39,28 @@ compare /dev/null out || fail=1
 
 gpt-header-munge --sector-size=$ss --n=9 $dev || fail=1
 
-parted -m -s $dev u s p > out 2>&1 || fail=1
-sed 's/.*:gpt:/:gpt:/' out > k && mv k out
-printf 'BYT;\n:gpt::;\n' > exp || fail=1
+# Changing the number of PTE entries to 9 from 128 triggers the extra space detection
+# and it will offer to fix the it to use the extra space.
+parted -s $dev print > out 2>&1 || fail=1
+
+# Transform the actual output, to avoid spurious differences when
+# $PWD contains a symlink-to-dir.  Also, remove the ^M      ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s,
   *
,,g;s, $,," \
+                      -e "s,^.*/lt-parted: ,parted: ," o2 > out
+
+# check for expected diagnostic
+cat <<EOF > exp || fail=1
+Warning: Not all of the space available to DEVICE appears to be used, you can fix the GPT to use all of the space (an extra 30 blocks) or continue with the current setting?
+Model:  (file)
+Disk DEVICE: 2097kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+Disk Flags:
+
+Number  Start  End  Size  File system  Name  Flags
+
+EOF
 compare exp out || fail=1
 
 Exit $fail
diff --git a/tests/t0282-gpt-move-backup.sh b/tests/t0282-gpt-move-backup.sh
index 9750ed7..2d10cd3 100644
--- a/tests/t0282-gpt-move-backup.sh
+++ b/tests/t0282-gpt-move-backup.sh
@@ -53,7 +53,7 @@ mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s,
   *
,,g;s, $,," \
 
 # check for expected diagnostic
 cat <<EOF > exp || fail=1
-Error: The backup GPT table is not at the end of the disk, as it should be.  Fix, by moving the backup to the end (and removing the old backup)?
+Warning: Not all of the space available to DEVICE appears to be used, you can fix the GPT to use all of the space (an extra 33 blocks) or continue with the current setting?
 Model:  (file)
 Disk DEVICE: 2560kB
 Sector size (logical/physical): 512B/512B
@@ -76,7 +76,7 @@ mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s,
   *
,,g;s, $,," \
 
 # check for expected diagnostic
 cat <<EOF > exp || fail=1
-Error: The backup GPT table is not at the end of the disk, as it should be.  Fix, by moving the backup to the end (and removing the old backup)?
+Warning: Not all of the space available to DEVICE appears to be used, you can fix the GPT to use all of the space (an extra 33 blocks) or continue with the current setting?
 Fix/Ignore? f
 Model:  (file)
 Disk DEVICE: 2560kB
-- 
1.8.5.3




More information about the parted-devel mailing list