From 2cad3544a087eda2031854fe20dd4c5ebdcf1a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20P=C3=BCschel?= Date: Tue, 5 May 2026 12:20:49 +0200 Subject: [PATCH] Test DHCP request option changed signal Test that the DHCP request option functions trigger the changed signal if they modify the list of request options. Note that clearing is treated differently than an empty list of options, as an empty list overrides the default options. --- src/libnm-core-impl/tests/test-general.c | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/libnm-core-impl/tests/test-general.c b/src/libnm-core-impl/tests/test-general.c index 7de85757fb..f8d2629936 100644 --- a/src/libnm-core-impl/tests/test-general.c +++ b/src/libnm-core-impl/tests/test-general.c @@ -5436,6 +5436,24 @@ test_setting_ip4_changed_signal(void) ASSERT_UNCHANGED(nm_setting_ip_config_remove_dns_option(s_ip4, 1)); g_test_assert_expected_messages(); + ASSERT_CHANGED(nm_setting_ip_config_add_dhcp_request_option(s_ip4, 43)); + ASSERT_CHANGED(nm_setting_ip_config_remove_dhcp_request_option(s_ip4, 0)); + + ASSERT_CHANGED(nm_setting_ip_config_add_dhcp_request_option(s_ip4, 43)); + ASSERT_UNCHANGED(nm_setting_ip_config_remove_dhcp_request_option_by_value(s_ip4, 44)); + ASSERT_CHANGED(nm_setting_ip_config_remove_dhcp_request_option_by_value(s_ip4, 43)); + + NMTST_EXPECT_LIBNM_CRITICAL( + NMTST_G_RETURN_MSG(idx < nm_g_array_len(priv->dhcp_request_options))); + ASSERT_UNCHANGED(nm_setting_ip_config_remove_dhcp_request_option(s_ip4, 1)); + g_test_assert_expected_messages(); + + ASSERT_CHANGED(nm_setting_ip_config_clear_dhcp_request_options(s_ip4)); + + nm_setting_ip_config_add_dhcp_request_option(s_ip4, 69); + ASSERT_CHANGED(nm_setting_ip_config_clear_dhcp_request_options(s_ip4)); + ASSERT_UNCHANGED(nm_setting_ip_config_clear_dhcp_request_options(s_ip4)); + nm_ip_address_unref(addr); nm_ip_route_unref(route); g_object_unref(connection); @@ -5533,6 +5551,24 @@ test_setting_ip6_changed_signal(void) nm_setting_ip_config_add_route(s_ip6, route); ASSERT_CHANGED(nm_setting_ip_config_clear_routes(s_ip6)); + ASSERT_CHANGED(nm_setting_ip_config_add_dhcp_request_option(s_ip6, 17)); + ASSERT_CHANGED(nm_setting_ip_config_remove_dhcp_request_option(s_ip6, 0)); + + ASSERT_CHANGED(nm_setting_ip_config_add_dhcp_request_option(s_ip6, 17)); + ASSERT_UNCHANGED(nm_setting_ip_config_remove_dhcp_request_option_by_value(s_ip6, 18)); + ASSERT_CHANGED(nm_setting_ip_config_remove_dhcp_request_option_by_value(s_ip6, 17)); + + NMTST_EXPECT_LIBNM_CRITICAL( + NMTST_G_RETURN_MSG(idx < nm_g_array_len(priv->dhcp_request_options))); + ASSERT_UNCHANGED(nm_setting_ip_config_remove_dhcp_request_option(s_ip6, 1)); + g_test_assert_expected_messages(); + + ASSERT_CHANGED(nm_setting_ip_config_clear_dhcp_request_options(s_ip6)); + + nm_setting_ip_config_add_dhcp_request_option(s_ip6, 65535); + ASSERT_CHANGED(nm_setting_ip_config_clear_dhcp_request_options(s_ip6)); + ASSERT_UNCHANGED(nm_setting_ip_config_clear_dhcp_request_options(s_ip6)); + nm_ip_address_unref(addr); nm_ip_route_unref(route); g_object_unref(connection);