Compare commits

...

No commits in common. "c8" and "af3a58ca52a97e81302396502d16c90d5177db2b" have entirely different histories.

12 changed files with 536 additions and 122 deletions

View File

@ -1 +1 @@
9a74bbe7805d562316e92417f71e4b03155308e6 SOURCES/gptfdisk-1.0.3.tar.gz
406ab2596e1911c916dce677ce7e903076d94c6d gptfdisk-1.0.7.tar.gz

22
.gitignore vendored
View File

@ -1 +1,21 @@
SOURCES/gptfdisk-1.0.3.tar.gz
gdisk-0.6.8.tgz
/gdisk-0.6.13.tgz
/gdisk-0.6.14.tgz
/gptfdisk-0.7.1.tgz
/gptfdisk-0.7.2.tar.gz
/gptfdisk-0.8.1.tar.gz
/gptfdisk-0.8.2.tar.gz
/gptfdisk-0.8.4.tar.gz
/gptfdisk-0.8.5.tar.gz
/gptfdisk-0.8.6.tar.gz
/gptfdisk-0.8.7.tar.gz
/gptfdisk-0.8.8.tar.gz
/gptfdisk-0.8.9.tar.gz
/gptfdisk-0.8.10.tar.gz
/gptfdisk-1.0.0.tar.gz
/gptfdisk-1.0.1.tar.gz
/gptfdisk-1.0.3.tar.gz
/gptfdisk-1.0.4.tar.gz
/gptfdisk-1.0.5.tar.gz
/gptfdisk-1.0.6.tar.gz
/gptfdisk-1.0.7.tar.gz

View File

@ -1,43 +0,0 @@
From e44306f00bd12f4dca2db20eaba103ff2f260d87 Mon Sep 17 00:00:00 2001
From: Rod Smith <rodsmith@rodsbooks.com>
Date: Mon, 14 Sep 2020 10:08:18 -0400
Subject: [PATCH 1/2] Fix segfault on some weird data structures
---
gpt.cc | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gpt.cc b/gpt.cc
index 03a2156..d0242d3 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -983,6 +983,14 @@ int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector
} // if
*crcOk = CheckHeaderCRC(&tempHeader);
+ if (tempHeader.sizeOfPartitionEntries != sizeof(GPTPart)) {
+ cerr << "Warning: Partition table header claims that the size of partition table\n";
+ cerr << "entries is " << tempHeader.sizeOfPartitionEntries << " bytes, but this program ";
+ cerr << " supports only " << sizeof(GPTPart) << "-byte entries.\n";
+ cerr << "Adjusting accordingly, but partition table may be garbage.\n";
+ tempHeader.sizeOfPartitionEntries = sizeof(GPTPart);
+ }
+
if (allOK && (numParts != tempHeader.numParts) && *crcOk) {
allOK = SetGPTSize(tempHeader.numParts, 0);
}
@@ -1000,7 +1008,10 @@ int GPTData::LoadPartitionTable(const struct GPTHeader & header, DiskIO & disk,
uint32_t sizeOfParts, newCRC;
int retval;
- if (disk.OpenForRead()) {
+ if (header.sizeOfPartitionEntries != sizeof(GPTPart)) {
+ cerr << "Error! GPT header contains invalid partition entry size!\n";
+ retval = 0;
+ } else if (disk.OpenForRead()) {
if (sector == 0) {
retval = disk.Seek(header.partitionEntriesLBA);
} else {
--
2.35.1

View File

@ -1,27 +0,0 @@
From 28ac93e737ae4e2055ff23f2ea6021b1127b40a2 Mon Sep 17 00:00:00 2001
From: Rod Smith <rodsmith@rodsbooks.com>
Date: Wed, 13 Jan 2021 10:29:24 -0500
Subject: [PATCH 2/2] Fix bug that could cause crash if a badly-formatted MBR
disk was read.
---
basicmbr.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/basicmbr.cc b/basicmbr.cc
index 8fbffd1..2da56db 100644
--- a/basicmbr.cc
+++ b/basicmbr.cc
@@ -258,7 +258,8 @@ int BasicMBRData::ReadLogicalParts(uint64_t extendedStart, int partNum) {
if (EbrLocations[i] == offset) { // already read this one; infinite logical partition loop!
cerr << "Logical partition infinite loop detected! This is being corrected.\n";
allOK = -1;
- partNum -= 1;
+ if (partNum > 0) //don't go negative
+ partNum -= 1;
} // if
} // for
EbrLocations[partNum] = offset;
--
2.35.1

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -1,24 +1,24 @@
From a7eaefd9bc4a91a4ca26146f784d40725cfe15fa Mon Sep 17 00:00:00 2001
From 49ed9305afae9865d9b748ef419b4f923ae4e86d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
Date: Wed, 29 Sep 2021 15:33:33 +0200
Date: Wed, 29 Sep 2021 15:46:37 +0200
Subject: [PATCH] Fix incorrect byte order of partition names on big-endian
systems
---
gdisk.8 | 8 ++++++++
gptcl.cc | 11 +++++++++++
gptpart.cc | 14 +++++++-------
gptpart.cc | 13 +++++++------
gptpart.h | 1 +
gpttext.cc | 20 ++++++++++++++++++++
gpttext.h | 1 +
sgdisk.8 | 8 ++++++++
7 files changed, 56 insertions(+), 7 deletions(-)
7 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/gdisk.8 b/gdisk.8
index c2cf83d..071756c 100644
index 62f6bd2..0029b75 100644
--- a/gdisk.8
+++ b/gdisk.8
@@ -416,6 +416,14 @@ set features for each partition. \fBgdisk\fR supports four attributes:
@@ -419,6 +419,14 @@ set features for each partition. \fBgdisk\fR supports four attributes:
aren't translated into anything useful. In practice, most OSes seem to
ignore these attributes.
@ -34,7 +34,7 @@ index c2cf83d..071756c 100644
.B c
Change partition GUID. You can enter a custom unique GUID for a partition
diff --git a/gptcl.cc b/gptcl.cc
index 6c36738..58afc8a 100644
index 2304091..65a99e9 100644
--- a/gptcl.cc
+++ b/gptcl.cc
@@ -64,6 +64,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
@ -70,18 +70,10 @@ index 6c36738..58afc8a 100644
SaveGPTBackup(backupFile);
free(backupFile);
diff --git a/gptpart.cc b/gptpart.cc
index 17d6f15..82aeab0 100644
index b268cf0..b83254d 100644
--- a/gptpart.cc
+++ b/gptpart.cc
@@ -83,7 +83,6 @@ string GPTPart::GetDescription(void) {
size_t pos = 0 ;
while ( ( pos < NAME_SIZE ) && ( name[ pos ] != 0 ) ) {
uint16_t cp = name[ pos ++ ] ;
- if ( ! IsLittleEndian() ) ReverseBytes( & cp , 2 ) ;
// first to utf32
uint32_t uni ;
if ( cp < 0xd800 || cp > 0xdfff ) {
@@ -234,7 +233,6 @@ void GPTPart::SetName(const string & theName) {
@@ -242,7 +242,6 @@ void GPTPart::SetName(const string & theName) {
// then to utf16le
if ( uni < 0x10000 ) {
name[ pos ] = (uint16_t) uni ;
@ -89,7 +81,7 @@ index 17d6f15..82aeab0 100644
pos ++ ;
} // if
else {
@@ -244,10 +242,8 @@ void GPTPart::SetName(const string & theName) {
@@ -252,10 +251,8 @@ void GPTPart::SetName(const string & theName) {
} // if
uni -= 0x10000 ;
name[ pos ] = (uint16_t)( uni >> 10 ) | 0xd800 ;
@ -100,7 +92,7 @@ index 17d6f15..82aeab0 100644
pos ++ ;
}
} // for
@@ -407,14 +403,18 @@ int GPTPart::DoTheyOverlap(const GPTPart & other) {
@@ -415,14 +412,18 @@ int GPTPart::DoTheyOverlap(const GPTPart & other) {
// Reverse the bytes of integral data types and of the UTF-16LE name;
// used on big-endian systems.
void GPTPart::ReversePartBytes(void) {
@ -123,10 +115,10 @@ index 17d6f15..82aeab0 100644
/****************************************
* Functions requiring user interaction *
diff --git a/gptpart.h b/gptpart.h
index 657b3f9..ac8a725 100644
index fac514e..51bfb38 100644
--- a/gptpart.h
+++ b/gptpart.h
@@ -93,6 +93,7 @@ class GPTPart {
@@ -94,6 +94,7 @@ class GPTPart {
void BlankPartition(void); // empty partition of data
int DoTheyOverlap(const GPTPart & other); // returns 1 if there's overlap
void ReversePartBytes(void); // reverse byte order of all integer fields
@ -135,7 +127,7 @@ index 657b3f9..ac8a725 100644
// Functions requiring user interaction
void ChangeType(void); // Change the type code
diff --git a/gpttext.cc b/gpttext.cc
index 732d861..6de7121 100644
index ea34444..a5f0fd8 100644
--- a/gpttext.cc
+++ b/gpttext.cc
@@ -341,6 +341,22 @@ int GPTDataTextUI::SetName(uint32_t partNum) {
@ -180,7 +172,7 @@ index 732d861..6de7121 100644
cout << "d\tdisplay the sector alignment value\n";
cout << "e\trelocate backup data structures to the end of the disk\n";
diff --git a/gpttext.h b/gpttext.h
index 98e59af..db27246 100644
index afe4651..6bd22cf 100644
--- a/gpttext.h
+++ b/gpttext.h
@@ -49,6 +49,7 @@ class GPTDataTextUI : public GPTData {
@ -192,7 +184,7 @@ index 98e59af..db27246 100644
int DestroyGPTwPrompt(void); // Returns 1 if user proceeds
void ShowDetails(void);
diff --git a/sgdisk.8 b/sgdisk.8
index 2cb18b9..3bc51f2 100644
index 59a3d3c..3fb7ae6 100644
--- a/sgdisk.8
+++ b/sgdisk.8
@@ -182,6 +182,14 @@ backup will reflect your changes. If the GPT data structures are damaged,
@ -211,5 +203,5 @@ index 2cb18b9..3bc51f2 100644
.B \-c, \-\-change\-name=partnum:name
Change the GPT name of a partition. This name is encoded as a UTF\-16
--
2.35.1
2.32.0

View File

@ -1,17 +1,16 @@
Summary: An fdisk-like partitioning tool for GPT disks
Name: gdisk
Version: 1.0.3
Release: 11%{?dist}
Version: 1.0.7
Release: 5%{?dist}
License: GPLv2
URL: http://www.rodsbooks.com/gdisk/
Group: System Environment/Base
Source0: http://downloads.sourceforge.net/gptfdisk/gptfdisk-%{version}.tar.gz
Patch0: gdisk-1.0.3-byteswap.patch
Patch1: gdisk-CVE-2020-0256.patch
Patch2: gdisk-CVE-2021-0308.patch
BuildRequires: popt-devel
Patch0: gdisk-1.0.7-byteswap.patch
BuildRequires: gcc-c++
BuildRequires: libuuid-devel
BuildRequires: make
BuildRequires: ncurses-devel
BuildRequires: popt-devel
%description
An fdisk-like partitioning tool for GPT disks. GPT fdisk features a
@ -22,8 +21,6 @@ tables, and the ability to convert MBR disks to GPT format.
%prep
%setup -q -n gptfdisk-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
chmod 0644 gdisk_test.sh
%build
@ -48,25 +45,53 @@ done
%{_mandir}/man8/fixparts.8*
%changelog
* Tue Mar 15 2022 Nikola Forró <nforro@redhat.com> - 1.0.3-11
- Fix double byteswap on big-endian systems also while reading partition names
resolves: #2065205
* Wed Mar 02 2022 Nikola Forró <nforro@redhat.com> - 1.0.3-10
- Fix CVE-2021-0308
resolves: #2052364
* Wed Mar 02 2022 Nikola Forró <nforro@redhat.com> - 1.0.3-9
- Fix CVE-2020-0256
resolves: #2052365
* Mon Oct 25 2021 Nikola Forró <nforro@redhat.com> - 1.0.3-8
* Mon Oct 25 2021 Nikola Forró <nforro@redhat.com> - 1.0.7-5
- Add upstream tests as a gating test
related: #1899990
related: #2006964
* Wed Sep 29 2021 Nikola Forró <nforro@redhat.com> - 1.0.3-7
* Wed Sep 29 2021 Nikola Forró <nforro@redhat.com> - 1.0.7-4
- Fix incorrect byte order of partition names on big-endian systems
resolves: #1899990
resolves: #2006964
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.7-3
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.7-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Thu Mar 11 2021 Terje Rosten <terje.rosten@ntnu.no> - 1.0.7-1
- 1.0.7
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jan 19 2021 Terje Rosten <terje.rosten@ntnu.no> - 1.0.6-1
- 1.0.6
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Sun Mar 22 2020 Terje Rosten <terje.rosten@ntnu.no> - 1.0.5-1
- 1.0.5
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jul 14 2018 Terje Rosten <terje.rosten@ntnu.no> - 1.0.4-3
- Add c++ compiler
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Sun Jul 08 2018 Terje Rosten <terje.rosten@ntnu.no> - 1.0.4-1
- 1.0.4
* Fri Feb 23 2018 Florian Weimer <fweimer@redhat.com> - 1.0.3-6
- Use LDFLAGS from redhat-rpm-config

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (gptfdisk-1.0.7.tar.gz) = 8a2067523479e34c76392571692b36e6c9eadcd0aca979f1ba09904930ed92a709bfdcdfa3369230a5ab2b5a751682dc7fb4645fb5f7f1c361ee8d28e104214c

1
tests/gdisk/README Normal file
View File

@ -0,0 +1 @@
gdisk tests modified to run against installed gdisk

402
tests/gdisk/gdisk_test.sh Executable file
View File

@ -0,0 +1,402 @@
#!/bin/bash
# test gdisk and sgdisk by creating a dd file
# Copyright (C) 2011 Guillaume Delacour <gui@iroqwa.org>
#
# 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 2 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# Requires: coreutils (mktemp, dd) and 64M of disk space in /tmp (temp dd disk)
#
# This script test gdisk commands through the following scenario:
# - Initialize a new GPT table
# - Create a single Linux partition
# - Change name of partition
# - Change type of partition
# - Backup to file the GPT table
# - Delete the single partition
# - Restore from backup file the GPT table
# - Wipe the GPT table
# TODO
# Try to generate a wrong GPT table to detect problems (test --verify)
# Create MBR partition table with fdisk and migrate it with gdisk
GDISK_BIN=/usr/sbin/gdisk
SGDISK_BIN=/usr/sbin/sgdisk
OPT_CLEAR="o"
OPT_NEW="n"
OPT_CHANGE_NAME="c"
OPT_CHANGE_TYPE="t"
OPT_BACKUP="b"
OPT_DELETE="d"
OPT_ZAP="z"
# temp disk for testing gdisk
TEMP_DISK=$(mktemp)
# 64 MiB
TEMP_DISK_SIZE=65536
# the test partition to create
TEST_PART_TYPE="8300"
TEST_PART_DEFAULT_NAME="Linux filesystem"
# newname for the partition
TEST_PART_NEWNAME=$(tr -dc "[:alpha:]" < /dev/urandom | head -c 8)
# and new type (swap for example)
TEST_PART_NEWTYPE="8200"
# GPT data backup to filename
GPT_BACKUP_FILENAME=$(mktemp)
# Pretty print string (Red if FAILED or green if SUCCESS)
# $1: string to pretty print
pretty_print() {
if [ "$1" = "SUCCESS" ]
then
# green
color="32"
else
# red
color="31"
fi
printf "\033[0;${color}m**$1**\033[m $2\n"
}
# Verify that the partition exist and has the given type/name
# $1: Partition type to verify (ex.: 8300)
# $2: Partition name to verify (ex.: Linux filesystem)
# $3: Text to print
verify_part() {
partition=$($GDISK_BIN -l $TEMP_DISK | tail -n 1)
echo $partition | grep -q "$1[[:space:]]$2$"
if [ $? -eq 0 ]
then
pretty_print "SUCCESS" "$3"
else
pretty_print "FAILED" "$3"
exit 1
fi
}
#####################################
# Get GUID of disk
#####################################
get_diskguid() {
DISK_GUID=$($GDISK_BIN -l $TEMP_DISK | grep "^Disk identifier (GUID):" | awk '{print $4}')
return $DISK_GUID
}
#####################################
# Create a new empty table
#####################################
create_table() {
case $1 in
gdisk)
$GDISK_BIN $TEMP_DISK << EOF
$OPT_CLEAR
Y
w
Y
EOF
ret=$?
if [ $ret -ne 0 ]
then
pretty_print "FAILED" "gdisk return $ret when creating partition table"
exit 1
fi
;;
sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_CLEAR}
ret=$?
if [ $ret -ne 0 ]
then
pretty_print "FAILED" "sgdisk return $ret when creating partition table"
exit 1
fi
;;
esac
# verify that the table is empty
# only the columns should appear in the table
verify_part "Code" "Name" "Create new empty GPT table"
echo ""
}
#####################################
# First create a new partition
#####################################
create_partition() {
case $1 in
gdisk)
$GDISK_BIN $TEMP_DISK << EOF
$OPT_NEW
1
$TEST_PART_TYPE
w
Y
EOF
;;
sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_NEW} 1 -${OPT_CHANGE_NAME} 1:"${TEST_PART_DEFAULT_NAME}" -${OPT_CHANGE_TYPE} 1:$TEST_PART_TYPE
;;
esac
verify_part "$TEST_PART_TYPE" "$TEST_PART_DEFAULT_NAME" "Create new partition"
echo ""
}
#####################################
# Change name of partition
#####################################
change_partition_name() {
case $1 in
gdisk)
$GDISK_BIN $TEMP_DISK << EOF
$OPT_CHANGE_NAME
$TEST_PART_NEWNAME
w
Y
EOF
;;
sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_CHANGE_NAME} 1:${TEST_PART_NEWNAME}
;;
esac
verify_part "$TEST_PART_TYPE" "$TEST_PART_NEWNAME" "Change partition 1 name ($TEST_PART_DEFAULT_NAME -> $TEST_PART_NEWNAME)"
echo ""
}
change_partition_type() {
#####################################
# Change type of partition
#####################################
case $1 in
gdisk)
$GDISK_BIN $TEMP_DISK << EOF
$OPT_CHANGE_TYPE
$TEST_PART_NEWTYPE
w
Y
EOF
;;
sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_CHANGE_TYPE} 1:${TEST_PART_NEWTYPE}
;;
esac
verify_part "$TEST_PART_NEWTYPE" "$TEST_PART_NEWNAME" "Change partition 1 type ($TEST_PART_TYPE -> $TEST_PART_NEWTYPE)"
echo ""
}
#####################################
# Backup GPT data to file
#####################################
backup_table() {
case $1 in
gdisk)
$GDISK_BIN $TEMP_DISK << EOF
$OPT_BACKUP
$GPT_BACKUP_FILENAME
q
EOF
echo ""
;;
sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_BACKUP} ${GPT_BACKUP_FILENAME}
;;
esac
# if exist and not empty; we will test it after
if [ -s $GPT_BACKUP_FILENAME ]
then
pretty_print "SUCCESS" "GPT data backuped sucessfully"
else
pretty_print "FAILED" "Unable to create GPT backup file !"
exit 1
fi
}
#####################################
# Now, we can delete the partition
#####################################
delete_partition() {
case $1 in
gdisk)
$GDISK_BIN $TEMP_DISK << EOF
$OPT_DELETE
w
Y
EOF
;;
sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_DELETE} 1
;;
esac
# verify that the table is empty (just one partition):
# only the columns should appear in the table
verify_part "Code" "Name" "Delete partition 1"
echo ""
}
#####################################
# Restore GPT table
#####################################
restore_table() {
$GDISK_BIN $TEMP_DISK << EOF
r
r
l
$GPT_BACKUP_FILENAME
w
Y
EOF
verify_part "$TEST_PART_NEWTYPE" "$TEST_PART_NEWNAME" "Restore the GPT backup"
echo ""
}
#####################################
# Change UID of disk
#####################################
change_disk_uid() {
# get UID of disk before changing it
GUID=get_diskguid
case $1 in
gdisk)
$GDISK_BIN $TEMP_DISK << EOF
x
g
R
w
Y
EOF
;;
sgdisk)
$SGDISK_BIN $TEMP_DISK -U=R
;;
esac
# get GUID after change
NEW_DISK_GUID=get_diskguid
# compare them
if [ "$DISK_GUID" != "$NEW_DISK_GUID" ]
then
pretty_print "SUCCESS" "GUID of disk has been sucessfully changed"
else
pretty_print "FAILED" "GUID of disk is the same as the previous one"
exit 1
fi
}
#####################################
# Wipe GPT table
#####################################
wipe_table() {
case $1 in
gdisk)
$GDISK_BIN $TEMP_DISK << EOF
x
$OPT_ZAP
Y
Y
EOF
;;
sgdisk)
$SGDISK_BIN $TEMP_DISK -${OPT_ZAP}
esac
# verify that the table is empty (just one partition):
# only the columns should appear in the table
verify_part "Code" "Name" "Wipe GPT table"
echo ""
}
#####################################
# Test stdin EOF
#####################################
eof_stdin() {
$SGDISK_BIN $TEMP_DISK << EOF
^D
EOF
pretty_print "SUCCESS" "EOF successfully exit gdisk"
}
###################################
# Main
###################################
# create a file to simulate a real device
dd if=/dev/zero of=$TEMP_DISK bs=1024 count=$TEMP_DISK_SIZE > /dev/null 2>&1
if [ -s $TEMP_DISK ]
then
pretty_print "SUCCESS" "Temp disk sucessfully created"
else
pretty_print "FAILED" "Unable to create temp disk !"
exit 1
fi
# test gdisk and sgdisk
for binary in gdisk sgdisk
do
echo ""
printf "\033[0;34m**Testing $binary binary**\033[m\n"
echo ""
create_table "$binary"
create_partition "$binary"
change_partition_name "$binary"
change_partition_type "$binary"
backup_table "$binary"
delete_partition "$binary"
restore_table # only with gdisk
change_disk_uid "$binary"
wipe_table "$binary"
eof_stdin # only with gdisk
done
# remove temp files
rm -f $TEMP_DISK $GPT_BACKUP_FILENAME
exit 0

11
tests/tests.yml Normal file
View File

@ -0,0 +1,11 @@
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- atomic
- classic
- container
tests:
- upstream-tests
required_packages:
- gdisk

26
tests/upstream-tests Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
. /usr/share/beakerlib/beakerlib.sh
TEST="/AppStream/gdisk/Sanity/upstream-tests"
PACKAGES=${PACKAGES:-"gdisk"}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp -r gdisk/* $TmpDir/." 0 "Copying test suite"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "/bin/sh gdisk_test.sh" 0 "Running tests"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd