diff options
author | Debarshi Ray <rishi@gnu.org> | 2007-04-21 00:59:15 +0530 |
---|---|---|
committer | Debarshi Ray <rishi@sunflower.(none)> | 2007-04-21 00:59:15 +0530 |
commit | b40a7a0976280fc861d5afa7563b28f561818b55 (patch) | |
tree | 25f99a0965f220e76afa3432bf3c392472725c70 /libparted/tests | |
parent | ddb9cf870adfa5c3a3d89ac5fea967923f1be31b (diff) | |
download | parted-b40a7a0976280fc861d5afa7563b28f561818b55.tar.gz |
[tests] New test for probing of disk labels.
Diffstat (limited to 'libparted/tests')
-rw-r--r-- | libparted/tests/label.c | 39 |
1 files changed, 39 insertions, 0 deletions
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. */ |