I have separated the test for creating and reading disklabels.
Moreover I have added an extra check to verify that the disk label
read is of the same type as the one that was created.
Please find attached the patch for this.
Happy hacking,
Debarshi
--
GPG key ID: 63D4A5A7
Key server: pgp.mit.edu
diff --git a/libparted/tests/label.c b/libparted/tests/label.c
index 898dbe3..ad14406 100644
--- a/libparted/tests/label.c
+++ b/libparted/tests/label.c
@@ -40,13 +40,6 @@ START_TEST (test_create_label)
disk = _create_disk_label (dev, type);
ped_disk_destroy (disk);
-
- /* Try to read the label */
- disk = ped_disk_new (dev);
- fail_if (!disk,
- "Failed to read the just created label of type: %s",
- type->name);
- ped_disk_destroy (disk);
}
ped_device_destroy (dev);
}
@@ -84,6 +77,39 @@ START_TEST (test_probe_label)
}
END_TEST
+/* TEST: Read the disk label of a loop device. */
+START_TEST (test_read_label)
+{
+ PedDevice* dev = ped_device_get (temporary_disk);
+ if (dev == NULL)
+ return;
+
+ PedDiskType* type;
+ PedDisk* disk;
+
+ for (type = ped_disk_type_get_next (NULL); type;
+ type = ped_disk_type_get_next (type)) {
+ if (!_implemented_disk_label (type->name))
+ continue;
+
+ disk = _create_disk_label (dev, type);
+ ped_disk_destroy (disk);
+
+ /* Try to read the disk label. */
+ disk = ped_disk_new (dev);
+ fail_if (!disk,
+ "Failed to read the just created label of type: %s",
+ type->name);
+ fail_if (strcmp (disk->type->name, type->name) != 0,
+ "Read returned label of type: %s as type: %s",
+ type->name, disk->type->name);
+
+ ped_disk_destroy (disk);
+ }
+ ped_device_destroy (dev);
+}
+END_TEST
+
/* TEST: Clone the disk label of a loop device. */
START_TEST (test_clone_label)
{
@@ -122,6 +148,7 @@ main (void)
Suite* suite = suite_create ("Disk Label");
TCase* tcase_basic = tcase_create ("Create");
TCase* tcase_probe = tcase_create ("Probe");
+ TCase* tcase_read = tcase_create ("Read");
TCase* tcase_clone = tcase_create ("Clone");
/* Fail when an exception is raised */
@@ -139,6 +166,12 @@ main (void)
tcase_set_timeout (tcase_probe, 0);
suite_add_tcase (suite, tcase_probe);
+ tcase_add_checked_fixture (tcase_read, create_disk, destroy_disk);
+ tcase_add_test (tcase_read, test_read_label);
+ /* Disable timeout for this test. */
+ tcase_set_timeout (tcase_read, 0);
+ suite_add_tcase (suite, tcase_read);
+
tcase_add_checked_fixture (tcase_clone, create_disk, destroy_disk);
tcase_add_test (tcase_clone, test_clone_label);
/* Disable timeout for this test. */
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel