tests: add tests for generating stable UUIDs for keyfile/initrd

Fixes: 7ee0da3eaf ('build: don't "update-po" during make dist')
This commit is contained in:
Thomas Haller
2022-11-02 22:02:18 +01:00
parent 545edb7093
commit dc26e65928
2 changed files with 25 additions and 5 deletions

View File

@@ -2292,14 +2292,19 @@ test_read_missing_vlan_flags(void)
static void
test_read_missing_id_uuid(void)
{
gs_unref_object NMConnection *connection = NULL;
gs_free char *expected_uuid = NULL;
const char *FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID";
gs_unref_object NMConnection *connection = NULL;
gs_free char *expected_uuid = NULL;
gs_free char *expected_uuid2 = NULL;
const char *FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID";
const char F[] = "keyfile\0" TEST_KEYFILES_DIR "/Test_Missing_ID_UUID";
expected_uuid = nm_uuid_generate_from_strings_old("keyfile", FILENAME);
connection = keyfile_read_connection_from_file(FILENAME);
expected_uuid2 =
nm_uuid_generate_from_string_str(F, sizeof(F), NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1);
g_assert_cmpstr(expected_uuid, ==, expected_uuid2);
connection = keyfile_read_connection_from_file(FILENAME);
g_assert_cmpstr(nm_connection_get_id(connection), ==, "Test_Missing_ID_UUID");
g_assert_cmpstr(nm_connection_get_uuid(connection), ==, expected_uuid);
}

View File

@@ -13,6 +13,7 @@
#include <sys/socket.h>
#include "libnm-core-intern/nm-core-internal.h"
#include "libnm-glib-aux/nm-uuid.h"
#include "nm-initrd-generator/nm-initrd-generator.h"
@@ -1664,7 +1665,11 @@ test_ibft_ip_dev(void)
{
const char *const *ARGV = NM_MAKE_STRV("ip=eth0:ibft");
NMSettingConnection *s_con;
gs_unref_object NMConnection *connection = NULL;
gs_unref_object NMConnection *connection = NULL;
const char *s_hwaddr = "00:53:00:ab:00:01";
const char *s_vlanid = "666";
const char *s_ipaddr = "2001:0db8:0000:0000:0000:0000:0000:0002";
gs_free char *expected_uuid = NULL;
connection = _parse_con(ARGV, "eth0");
@@ -1674,6 +1679,16 @@ test_ibft_ip_dev(void)
==,
NM_SETTING_VLAN_SETTING_NAME);
g_assert_cmpstr(nm_setting_connection_get_interface_name(s_con), ==, NULL);
expected_uuid = nm_uuid_generate_from_strings_old("ibft",
s_hwaddr,
s_vlanid ? "V" : "v",
s_vlanid ? s_vlanid : "",
s_ipaddr ? "A" : "DHCP",
s_ipaddr ? s_ipaddr : "");
g_assert_cmpstr(expected_uuid, ==, "16d9bd1c-e2ab-31ef-9196-860078e81a23");
g_assert_cmpstr(nm_connection_get_uuid(connection), ==, expected_uuid);
}
static void