summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian C. Lane <bcl@redhat.com>2014-06-11 12:13:49 -0700
committerPhillip Susi <psusi@ubuntu.com>2014-06-15 14:27:08 -0400
commit8d2c819b9ec89ca7c29c061eb2fd438c3876d6f8 (patch)
tree4fc0cbdcfd5b475947635d12bea1a5548968444e
parent06241515a818dcf62e7c5728a8328cf165e3a793 (diff)
downloadparted-8d2c819b9ec89ca7c29c061eb2fd438c3876d6f8.tar.gz
tests: check name when duplicating
Create a second partition with a name when supported by the disk label. Check to make sure that the duplicate has copied over the name. The goal with this was to try to catch the bug fixed by the previous commit but I was unable to make it fail. But this should improve our test coverage anyway. * tests/duplicate.c: Add a partition name test.
-rw-r--r--tests/duplicate.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/tests/duplicate.c b/tests/duplicate.c
index 129537c..a9dde84 100644
--- a/tests/duplicate.c
+++ b/tests/duplicate.c
@@ -50,7 +50,7 @@ main (int argc, char **argv)
const PedGeometry *geometry = ped_geometry_new (dev, 34, 1024);
assert (geometry);
PedPartition *part = ped_partition_new (disk, part_type, fs_type,
- geometry->start, geometry->end);
+ geometry->start, geometry->end);
assert (part);
PedConstraint *constraint = ped_constraint_exact (geometry);
assert (constraint);
@@ -65,6 +65,22 @@ main (int argc, char **argv)
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
+ /* Add a 2nd partition with a name (when supported) */
+ geometry = ped_geometry_new (dev, 1500, 500);
+ assert (geometry);
+ part = ped_partition_new (disk, part_type, fs_type,
+ geometry->start, geometry->end);
+ assert (part);
+ constraint = ped_constraint_exact (geometry);
+ assert (constraint);
+ assert (ped_disk_add_partition (disk, part, constraint));
+ ped_constraint_destroy (constraint);
+ assert (ped_partition_set_system (part, fs_type));
+ if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
+ ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
+ if (ped_disk_type_check_feature (part->disk->type, PED_DISK_TYPE_PARTITION_NAME))
+ ped_partition_set_name(part, "foobarbaz");
+
assert (ped_disk_commit(disk));
/* Duplicate it */
@@ -114,14 +130,23 @@ main (int argc, char **argv)
/* Check the flags */
for (PedPartitionFlag flag = PED_PARTITION_FIRST_FLAG;
- flag <= PED_PARTITION_LAST_FLAG; flag++) {
+ flag <= PED_PARTITION_LAST_FLAG; flag++)
+ {
if (!ped_partition_is_flag_available(disk_part, flag))
continue;
fprintf (stderr, "Checking partition flag %d\n", flag);
fprintf (stderr, "%d ? %d\n", ped_partition_get_flag (disk_part, flag),
- ped_partition_get_flag (copy_part, flag));
+ ped_partition_get_flag (copy_part, flag));
assert (ped_partition_get_flag (disk_part, flag)
- == ped_partition_get_flag (copy_part, flag));
+ == ped_partition_get_flag (copy_part, flag));
+ }
+
+ /* Check the name, if supported */
+ if (ped_disk_type_check_feature (part->disk->type, PED_DISK_TYPE_PARTITION_NAME))
+ {
+ const char *disk_name = ped_partition_get_name(disk_part);
+ const char *copy_name = ped_partition_get_name(copy_part);
+ assert (strcmp (disk_name, copy_name) == 0);
}
}