[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Debarshi Ray rishi-guest at alioth.debian.org
Tue May 1 04:27:23 UTC 2007


 libparted/tests/label.c |   47 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 7 deletions(-)

New commits:
commit e736648c24372fd7532fef7c568a5424395b3a7a
Author: Debarshi Ray <rishi at gnu.org>
Date:   Tue May 1 10:01:50 2007 +0530

    [tests] Separate and improved test for reading of disk labels.

diff --git a/libparted/tests/label.c b/libparted/tests/label.c
index c1f8b4e..54f40c3 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)
 {
@@ -127,6 +153,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 */
@@ -144,6 +171,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. */



More information about the Parted-commits mailing list