parted/0125-Fix-python-test-scripts-for-distribution.patch
Brian C. Lane 73aa139585 - Rebase on parted master commit 1da239e2ebd2
- libparted: Fix bug with dupe and empty name
2014-06-13 09:52:56 -07:00

246 lines
7.6 KiB
Diff

From 78ba2fe96dc7f39e585c508bfbc3549cc50aefff Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Jun 2014 11:00:39 -0700
Subject: [PATCH 125/125] Fix python test scripts for distribution
make distcheck was failing because these scripts were not being
included.
Make them both executable and and add the path to the tests that use
them. They also need to be included in the distribution so update
Makefile.am
* tests/Makefile.am: Add python test scripts
* tests/gpt-header-move.py: rename to gpt-header-move and make it
executable
* tests/msdos-overlap.py: rename to overlap.py
* tests/t0282-gpt-move-backup.sh: add path to scripts and use new name
* tests/t0283-overlap-partitions.sh: same
---
tests/Makefile.am | 3 ++-
tests/gpt-header-move | 41 +++++++++++++++++++++++++++++++++++++++
tests/gpt-header-move.py | 39 -------------------------------------
tests/msdos-overlap | 25 ++++++++++++++++++++++++
tests/msdos-overlap.py | 25 ------------------------
tests/t0282-gpt-move-backup.sh | 4 ++--
tests/t0283-overlap-partitions.sh | 4 ++--
7 files changed, 72 insertions(+), 69 deletions(-)
create mode 100755 tests/gpt-header-move
delete mode 100644 tests/gpt-header-move.py
create mode 100755 tests/msdos-overlap
delete mode 100755 tests/msdos-overlap.py
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 26226cf..0b5b1b6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -85,7 +85,8 @@ TESTS = \
EXTRA_DIST = \
$(TESTS) t-local.sh t-lvm.sh \
- init.cfg init.sh t-lib-helpers.sh gpt-header-munge
+ init.cfg init.sh t-lib-helpers.sh gpt-header-munge \
+ gpt-header-move msdos-overlap
check_PROGRAMS = print-align print-max dup-clobber duplicate fs-resize
fs_resize_LDADD = \
diff --git a/tests/gpt-header-move b/tests/gpt-header-move
new file mode 100755
index 0000000..05cdc65
--- /dev/null
+++ b/tests/gpt-header-move
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+
+# open img file, subtract 33 from altlba address, and move the last 33 sectors
+# back by 33 sectors
+
+from struct import *
+from zipfile import crc32
+import array
+import sys
+file = open(sys.argv[1],'rb+')
+file.seek(512)
+gptheader = file.read(512)
+altlba = unpack_from('<q', gptheader,offset=32)[0]
+gptheader = array.array('c',gptheader)
+pack_into('<Q', gptheader, 32, altlba-33)
+#zero header crc
+pack_into('<L', gptheader, 16, 0)
+#compute new crc
+newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
+pack_into('<L', gptheader, 16, newcrc)
+file.seek(512)
+file.write(gptheader)
+file.seek(512*altlba)
+gptheader = file.read(512)
+file.seek(512*(altlba-32))
+backup = file.read(512*32)
+altlba -= 33
+gptheader = array.array('c',gptheader)
+#update mylba
+pack_into('<Q', gptheader, 24, altlba)
+#update table lba
+pack_into('<Q', gptheader, 72, altlba-32)
+#zero header crc
+pack_into('<L', gptheader, 16, 0)
+#compute new crc
+newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
+pack_into('<L', gptheader, 16, newcrc)
+file.seek(512*(altlba-32))
+file.write(backup)
+file.write(gptheader)
+file.write("\0" * (512 * 33))
diff --git a/tests/gpt-header-move.py b/tests/gpt-header-move.py
deleted file mode 100644
index 8bee6bb..0000000
--- a/tests/gpt-header-move.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# open img file, subtract 33 from altlba address, and move the last 33 sectors
-# back by 33 sectors
-
-from struct import *
-from zipfile import crc32
-import array
-import sys
-file = open(sys.argv[1],'rb+')
-file.seek(512)
-gptheader = file.read(512)
-altlba = unpack_from('<q', gptheader,offset=32)[0]
-gptheader = array.array('c',gptheader)
-pack_into('<Q', gptheader, 32, altlba-33)
-#zero header crc
-pack_into('<L', gptheader, 16, 0)
-#compute new crc
-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
-pack_into('<L', gptheader, 16, newcrc)
-file.seek(512)
-file.write(gptheader)
-file.seek(512*altlba)
-gptheader = file.read(512)
-file.seek(512*(altlba-32))
-backup = file.read(512*32)
-altlba -= 33
-gptheader = array.array('c',gptheader)
-#update mylba
-pack_into('<Q', gptheader, 24, altlba)
-#update table lba
-pack_into('<Q', gptheader, 72, altlba-32)
-#zero header crc
-pack_into('<L', gptheader, 16, 0)
-#compute new crc
-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
-pack_into('<L', gptheader, 16, newcrc)
-file.seek(512*(altlba-32))
-file.write(backup)
-file.write(gptheader)
-file.write("\0" * (512 * 33))
diff --git a/tests/msdos-overlap b/tests/msdos-overlap
new file mode 100755
index 0000000..5bddfb0
--- /dev/null
+++ b/tests/msdos-overlap
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+"""
+ Write an overlapping partition to a msdos disk
+
+ Call with disk image/device to mangle
+"""
+import sys
+
+BAD_ENTRY = (0x72, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x10, 0x83, 0x03, 0x20, 0x4f, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x50, 0x83, 0x00, 0x0a, 0x7a, 0xff, 0x27,
+ 0x00, 0x00, 0x0a, 0x15, 0x00, 0x00, 0x00, 0x00 )
+OFFSET = 0x1b8
+
+if len(sys.argv) < 2:
+ print "%s: <image or device>"
+ sys.exit(1)
+
+data = "".join(chr(c) for c in BAD_ENTRY)
+with open(sys.argv[1], "rb+") as f:
+ f.seek(OFFSET, 0)
+ f.write(data)
+
+sys.exit(0)
diff --git a/tests/msdos-overlap.py b/tests/msdos-overlap.py
deleted file mode 100755
index 5bddfb0..0000000
--- a/tests/msdos-overlap.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-"""
- Write an overlapping partition to a msdos disk
-
- Call with disk image/device to mangle
-"""
-import sys
-
-BAD_ENTRY = (0x72, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x10, 0x83, 0x03, 0x20, 0x4f, 0x00, 0x08,
- 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x50, 0x83, 0x00, 0x0a, 0x7a, 0xff, 0x27,
- 0x00, 0x00, 0x0a, 0x15, 0x00, 0x00, 0x00, 0x00 )
-OFFSET = 0x1b8
-
-if len(sys.argv) < 2:
- print "%s: <image or device>"
- sys.exit(1)
-
-data = "".join(chr(c) for c in BAD_ENTRY)
-with open(sys.argv[1], "rb+") as f:
- f.seek(OFFSET, 0)
- f.write(data)
-
-sys.exit(0)
diff --git a/tests/t0282-gpt-move-backup.sh b/tests/t0282-gpt-move-backup.sh
index b827672..c197279 100644
--- a/tests/t0282-gpt-move-backup.sh
+++ b/tests/t0282-gpt-move-backup.sh
@@ -17,7 +17,7 @@
# 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
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir
require_512_byte_sector_size_
dev=loop-file
@@ -40,7 +40,7 @@ printf "BYT;\n$dev:${n_sectors}s:file:$sector_size_:$sector_size_:gpt::;\n" \
compare exp out || fail=1
# move the backup
-python ../gpt-header-move.py $dev || fail=1
+gpt-header-move $dev || fail=1
# printing must warn, but not fix in script mode
parted -s $dev print > out 2>&1 || fail=1
diff --git a/tests/t0283-overlap-partitions.sh b/tests/t0283-overlap-partitions.sh
index f9a3aff..7928c94 100644
--- a/tests/t0283-overlap-partitions.sh
+++ b/tests/t0283-overlap-partitions.sh
@@ -17,13 +17,13 @@
# 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
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir
require_512_byte_sector_size_
dev=loop-file
truncate -s 10m $dev || framework_failure
parted -s $dev mklabel msdos || framework_failure
-python ../msdos-overlap.py $dev || framework_failure
+msdos-overlap $dev || framework_failure
# print the empty table
parted ---pretend-input-tty $dev <<EOF > out 2>&1 || fail=1
--
1.9.3