diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-05-31 13:44:00 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-05-31 13:48:13 +0200 |
commit | 7767b83f4a98a59b6d023f1296a5e2742c50453e (patch) | |
tree | d118c629ea74b4476055a1e1fb6a12844e61c955 /src/test/test-gpt.c | |
parent | gpt: Use FOREACH_ARRAY (diff) | |
download | systemd-7767b83f4a98a59b6d023f1296a5e2742c50453e.tar.xz systemd-7767b83f4a98a59b6d023f1296a5e2742c50453e.zip |
gpt: Add gpt_partition_type_override_architecture()
Let's add a function that allows changing the architecture of a given
partition type.
Diffstat (limited to 'src/test/test-gpt.c')
-rw-r--r-- | src/test/test-gpt.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/test-gpt.c b/src/test/test-gpt.c index 5ad30fab44..fa5923eb27 100644 --- a/src/test/test-gpt.c +++ b/src/test/test-gpt.c @@ -81,4 +81,31 @@ TEST(type_alias_same) { } } +TEST(override_architecture) { + GptPartitionType x, y; + + assert_se(gpt_partition_type_from_string("root-x86-64", &x) >= 0); + assert_se(x.arch == ARCHITECTURE_X86_64); + + assert_se(gpt_partition_type_from_string("root-arm64", &y) >= 0); + assert(y.arch == ARCHITECTURE_ARM64); + + x = gpt_partition_type_override_architecture(x, ARCHITECTURE_ARM64); + assert_se(x.arch == y.arch); + assert_se(x.designator == y.designator); + assert_se(sd_id128_equal(x.uuid, y.uuid)); + assert_se(streq(x.name, y.name)); + + /* If the partition type does not have an architecture, nothing should change. */ + + assert_se(gpt_partition_type_from_string("esp", &x) >= 0); + y = x; + + x = gpt_partition_type_override_architecture(x, ARCHITECTURE_ARM64); + assert_se(x.arch == y.arch); + assert_se(x.designator == y.designator); + assert_se(sd_id128_equal(x.uuid, y.uuid)); + assert_se(streq(x.name, y.name)); +} + DEFINE_TEST_MAIN(LOG_INFO); |