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

Debarshi Ray rishi-guest at alioth.debian.org
Fri Apr 20 19:24:53 UTC 2007


 libparted/tests/label.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+)

New commits:
commit b40a7a0976280fc861d5afa7563b28f561818b55
Author: Debarshi Ray <rishi at gnu.org>
Date:   Sat Apr 21 00:59:15 2007 +0530

    [tests] New test for probing of disk labels.

diff --git a/libparted/tests/label.c b/libparted/tests/label.c
index 9338de5..898dbe3 100644
--- a/libparted/tests/label.c
+++ b/libparted/tests/label.c
@@ -52,6 +52,38 @@ START_TEST (test_create_label)
 }
 END_TEST
 
+/* TEST: Probe the disk label of a loop device. */
+START_TEST (test_probe_label)
+{
+        PedDevice* dev = ped_device_get (temporary_disk);
+        if (dev == NULL)
+                return;
+
+        PedDiskType* probed;
+        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 probe the disk label. */
+                probed = ped_disk_probe (dev);
+                fail_if (!probed,
+                         "Failed to probe the just created label of type: %s",
+                         type->name);
+                fail_if (strcmp (probed->name, type->name) != 0,
+                         "Probe returned label of type: %s as type: %s",
+                         type->name, probed->name);
+        }
+        ped_device_destroy (dev);
+}
+END_TEST
+
 /* TEST: Clone the disk label of a loop device. */
 START_TEST (test_clone_label)
 {
@@ -89,6 +121,7 @@ main (void)
         int number_failed;
         Suite* suite = suite_create ("Disk Label");
         TCase* tcase_basic = tcase_create ("Create");
+        TCase* tcase_probe = tcase_create ("Probe");
         TCase* tcase_clone = tcase_create ("Clone");
 
         /* Fail when an exception is raised */
@@ -100,6 +133,12 @@ main (void)
         tcase_set_timeout (tcase_basic, 0);
         suite_add_tcase (suite, tcase_basic);
 
+        tcase_add_checked_fixture (tcase_probe, create_disk, destroy_disk);
+        tcase_add_test (tcase_probe, test_probe_label);
+        /* Disable timeout for this test. */
+        tcase_set_timeout (tcase_probe, 0);
+        suite_add_tcase (suite, tcase_probe);
+
         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