487e5ad94c
Resolves: rhbz#2116505
76 lines
2.6 KiB
Diff
76 lines
2.6 KiB
Diff
From 3deaae7a19ebfbc2dad6ad67ba65409e7238efc8 Mon Sep 17 00:00:00 2001
|
|
From: "Brian C. Lane" <bcl@redhat.com>
|
|
Date: Mon, 8 Aug 2022 15:06:03 -0700
|
|
Subject: [PATCH 9/9] tests: Add a libparted test for ped_partition_set_system
|
|
on msdos
|
|
|
|
Test the libparted API to make sure the flag is not cleared by calling
|
|
ped_partition_set_system.
|
|
---
|
|
libparted/tests/flags.c | 35 +++++++++++++++++++++++++++++++++++
|
|
1 file changed, 35 insertions(+)
|
|
|
|
diff --git a/libparted/tests/flags.c b/libparted/tests/flags.c
|
|
index c83a361..c4b290b 100644
|
|
--- a/libparted/tests/flags.c
|
|
+++ b/libparted/tests/flags.c
|
|
@@ -54,6 +54,34 @@ START_TEST (test_gpt_flag)
|
|
}
|
|
END_TEST
|
|
|
|
+/* TEST: Test partition type flag on msdos disklabel */
|
|
+START_TEST (test_msdos_flag)
|
|
+{
|
|
+ PedDevice* dev = ped_device_get (temporary_disk);
|
|
+ if (dev == NULL)
|
|
+ return;
|
|
+
|
|
+ PedDisk* disk = ped_disk_new_fresh (dev, ped_disk_type_get ("msdos"));
|
|
+ PedConstraint *constraint = ped_constraint_any (dev);
|
|
+ PedPartition *part = ped_partition_new (disk, PED_PARTITION_NORMAL,
|
|
+ ped_file_system_type_get("ext4"), 2048, 4096);
|
|
+ ped_partition_set_flag(part, PED_PARTITION_BLS_BOOT, 1);
|
|
+ // Type should remain set to BIOS_GRUB
|
|
+ ped_partition_set_system(part, ped_file_system_type_get("ext4"));
|
|
+
|
|
+ ped_disk_add_partition (disk, part, constraint);
|
|
+ ped_disk_commit (disk);
|
|
+ ped_constraint_destroy (constraint);
|
|
+
|
|
+ // Check flag to confirm it is still set
|
|
+ part = ped_disk_get_partition (disk, 1);
|
|
+ fail_if (ped_partition_get_flag(part, PED_PARTITION_BLS_BOOT) != 1, "BLS_BOOT flag not set");
|
|
+
|
|
+ ped_disk_destroy (disk);
|
|
+ ped_device_destroy (dev);
|
|
+}
|
|
+END_TEST
|
|
+
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
@@ -61,6 +89,7 @@ main (int argc, char **argv)
|
|
int number_failed;
|
|
Suite* suite = suite_create ("Partition Flags");
|
|
TCase* tcase_gpt = tcase_create ("GPT");
|
|
+ TCase* tcase_msdos = tcase_create ("MSDOS");
|
|
|
|
/* Fail when an exception is raised */
|
|
ped_exception_set_handler (_test_exception_handler);
|
|
@@ -71,6 +100,12 @@ main (int argc, char **argv)
|
|
tcase_set_timeout (tcase_gpt, 0);
|
|
suite_add_tcase (suite, tcase_gpt);
|
|
|
|
+ tcase_add_checked_fixture (tcase_msdos, create_disk, destroy_disk);
|
|
+ tcase_add_test (tcase_msdos, test_msdos_flag);
|
|
+ /* Disable timeout for this test */
|
|
+ tcase_set_timeout (tcase_msdos, 0);
|
|
+ suite_add_tcase (suite, tcase_msdos);
|
|
+
|
|
SRunner* srunner = srunner_create (suite);
|
|
srunner_run_all (srunner, CK_VERBOSE);
|
|
|
|
--
|
|
2.37.1
|
|
|