From e74c568b07b50b97873fb4ee1d776dedefbd54d6 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Fri, 1 Oct 2021 23:05:04 +0200 Subject: New upstream version 1.32.12 --- src/core/tests/test-core.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/core/tests/test-core.c') diff --git a/src/core/tests/test-core.c b/src/core/tests/test-core.c index 8698c406..f28c4178 100644 --- a/src/core/tests/test-core.c +++ b/src/core/tests/test-core.c @@ -11,16 +11,36 @@ /* need math.h for isinf() and INFINITY. No need to link with -lm */ #include +#include "libnm-glib-aux/nm-uuid.h" #include "NetworkManagerUtils.h" -#include "nm-core-internal.h" +#include "libnm-core-intern/nm-core-internal.h" #include "nm-core-utils.h" -#include "systemd/nm-sd-utils-core.h" +#include "libnm-systemd-core/nm-sd-utils-core.h" #include "dns/nm-dns-manager.h" #include "nm-connectivity.h" #include "nm-test-utils-core.h" +/*****************************************************************************/ + +static void +test_config_h(void) +{ +#define ABSOLUTE_PATH(path) \ + G_STMT_START \ + { \ + g_assert_cmpstr("" path "", !=, ""); \ + g_assert("" path ""[0] == '/'); \ + } \ + G_STMT_END + + ABSOLUTE_PATH(IPTABLES_PATH); + ABSOLUTE_PATH(NFT_PATH); +} + +/*****************************************************************************/ + /* Reference implementation for nm_utils_ip6_address_clear_host_address. * Taken originally from set_address_masked(), src/ndisc/nm-lndp-ndisc.c **/ @@ -867,7 +887,7 @@ test_connection_no_match_vlan(void) /* Check that the connections do not match if VLAN flags differ */ s_vlan_orig = nm_connection_get_setting_vlan(orig); g_assert(s_vlan_orig); - g_object_set(G_OBJECT(s_vlan_orig), NM_SETTING_VLAN_FLAGS, NM_VLAN_FLAG_REORDER_HEADERS, NULL); + g_object_set(G_OBJECT(s_vlan_orig), NM_SETTING_VLAN_FLAGS, _NM_VLAN_FLAG_REORDER_HEADERS, NULL); s_vlan_copy = nm_connection_get_setting_vlan(copy); g_assert(s_vlan_copy); @@ -2231,7 +2251,7 @@ test_utils_file_is_in_path(void) g_assert(!nm_utils_file_is_in_path("//b///a/", "/b//")); g_assert(!nm_utils_file_is_in_path("//b///a/", "/b/a/")); g_assert(!nm_utils_file_is_in_path("//b///a", "/b/a/")); - g_assert(nm_utils_file_is_in_path("//b///a/.", "/b/a/")); + g_assert(!nm_utils_file_is_in_path("//b///a/.", "/b/a/")); g_assert(nm_utils_file_is_in_path("//b///a/..", "/b/a/")); } @@ -2569,6 +2589,8 @@ main(int argc, char **argv) { nmtst_init_with_logging(&argc, &argv, NULL, "ALL"); + g_test_add_func("/general/test_config_h", test_config_h); + g_test_add_func("/general/test_logging_domains", test_logging_domains); g_test_add_func("/general/test_logging_error", test_logging_error); -- cgit 1.3.0-6-gf8a5 From 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 13 Jan 2022 22:30:39 +0100 Subject: New upstream version 1.34.0 --- src/core/tests/test-core.c | 168 ++++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 84 deletions(-) (limited to 'src/core/tests/test-core.c') diff --git a/src/core/tests/test-core.c b/src/core/tests/test-core.c index f28c4178..3524cb17 100644 --- a/src/core/tests/test-core.c +++ b/src/core/tests/test-core.c @@ -1728,86 +1728,86 @@ test_nm_utils_strbuf_append(void) char buf[NM_STRLEN(BUF_ORIG) + 1]; char str[NM_STRLEN(BUF_ORIG) + 1]; -#define _strbuf_append(buf, len, format, ...) \ - G_STMT_START \ - { \ - char ** _buf = (buf); \ - gsize * _len = (len); \ - const char * _str_iter; \ - gs_free char *_str = NULL; \ - \ - switch (nmtst_get_rand_uint32() % 4) { \ - case 0: \ - nm_utils_strbuf_append(_buf, _len, (format), __VA_ARGS__); \ - break; \ - case 1: \ - _str = g_strdup_printf((format), __VA_ARGS__); \ - nm_utils_strbuf_append_str(_buf, _len, _str); \ - break; \ - case 2: \ - _str = g_strdup_printf((format), __VA_ARGS__); \ - nm_utils_strbuf_append_bin(_buf, _len, _str, strlen(_str)); \ - break; \ - case 3: \ - _str = g_strdup_printf((format), __VA_ARGS__); \ - if (!_str[0]) \ - nm_utils_strbuf_append_str(_buf, _len, _str); \ - for (_str_iter = _str; _str_iter[0]; _str_iter++) \ - nm_utils_strbuf_append_c(_buf, _len, _str_iter[0]); \ - break; \ - } \ - } \ +#define _strbuf_append(buf, len, format, ...) \ + G_STMT_START \ + { \ + char ** _buf = (buf); \ + gsize * _len = (len); \ + const char * _str_iter; \ + gs_free char *_str = NULL; \ + \ + switch (nmtst_get_rand_uint32() % 4) { \ + case 0: \ + nm_strbuf_append(_buf, _len, (format), __VA_ARGS__); \ + break; \ + case 1: \ + _str = g_strdup_printf((format), __VA_ARGS__); \ + nm_strbuf_append_str(_buf, _len, _str); \ + break; \ + case 2: \ + _str = g_strdup_printf((format), __VA_ARGS__); \ + nm_strbuf_append_bin(_buf, _len, _str, strlen(_str)); \ + break; \ + case 3: \ + _str = g_strdup_printf((format), __VA_ARGS__); \ + if (!_str[0]) \ + nm_strbuf_append_str(_buf, _len, _str); \ + for (_str_iter = _str; _str_iter[0]; _str_iter++) \ + nm_strbuf_append_c(_buf, _len, _str_iter[0]); \ + break; \ + } \ + } \ G_STMT_END -#define _strbuf_append_str(buf, len, str) \ - G_STMT_START \ - { \ - char ** _buf = (buf); \ - gsize * _len = (len); \ - const char *_str = (str); \ - \ - switch (nmtst_get_rand_uint32() % 4) { \ - case 0: \ - nm_utils_strbuf_append(_buf, _len, "%s", _str ?: ""); \ - break; \ - case 1: \ - nm_utils_strbuf_append_str(_buf, _len, _str); \ - break; \ - case 2: \ - nm_utils_strbuf_append_bin(_buf, _len, _str, _str ? strlen(_str) : 0); \ - break; \ - case 3: \ - if (!_str || !_str[0]) \ - nm_utils_strbuf_append_str(_buf, _len, _str); \ - for (; _str && _str[0]; _str++) \ - nm_utils_strbuf_append_c(_buf, _len, _str[0]); \ - break; \ - } \ - } \ +#define _strbuf_append_str(buf, len, str) \ + G_STMT_START \ + { \ + char ** _buf = (buf); \ + gsize * _len = (len); \ + const char *_str = (str); \ + \ + switch (nmtst_get_rand_uint32() % 4) { \ + case 0: \ + nm_strbuf_append(_buf, _len, "%s", _str ?: ""); \ + break; \ + case 1: \ + nm_strbuf_append_str(_buf, _len, _str); \ + break; \ + case 2: \ + nm_strbuf_append_bin(_buf, _len, _str, _str ? strlen(_str) : 0); \ + break; \ + case 3: \ + if (!_str || !_str[0]) \ + nm_strbuf_append_str(_buf, _len, _str); \ + for (; _str && _str[0]; _str++) \ + nm_strbuf_append_c(_buf, _len, _str[0]); \ + break; \ + } \ + } \ G_STMT_END -#define _strbuf_append_c(buf, len, ch) \ - G_STMT_START \ - { \ - char **_buf = (buf); \ - gsize *_len = (len); \ - char _ch = (ch); \ - \ - switch (nmtst_get_rand_uint32() % 4) { \ - case 0: \ - nm_utils_strbuf_append(_buf, _len, "%c", _ch); \ - break; \ - case 1: \ - nm_utils_strbuf_append_str(_buf, _len, ((char[2]){_ch, 0})); \ - break; \ - case 2: \ - nm_utils_strbuf_append_bin(_buf, _len, &_ch, 1); \ - break; \ - case 3: \ - nm_utils_strbuf_append_c(_buf, _len, _ch); \ - break; \ - } \ - } \ +#define _strbuf_append_c(buf, len, ch) \ + G_STMT_START \ + { \ + char **_buf = (buf); \ + gsize *_len = (len); \ + char _ch = (ch); \ + \ + switch (nmtst_get_rand_uint32() % 4) { \ + case 0: \ + nm_strbuf_append(_buf, _len, "%c", _ch); \ + break; \ + case 1: \ + nm_strbuf_append_str(_buf, _len, ((char[2]){_ch, 0})); \ + break; \ + case 2: \ + nm_strbuf_append_bin(_buf, _len, &_ch, 1); \ + break; \ + case 3: \ + nm_strbuf_append_c(_buf, _len, _ch); \ + break; \ + } \ + } \ G_STMT_END for (buf_len = 0; buf_len < 10; buf_len++) { @@ -1854,28 +1854,28 @@ test_nm_utils_strbuf_append(void) if (t_len > 0 && strlen(str) >= buf_len && (nmtst_get_rand_uint32() % 2)) { /* the string was truncated by g_snprintf(). That means, at the last position in the * buffer is now NUL. - * Replace the NUL by the actual character, and check that nm_utils_strbuf_seek_end() + * Replace the NUL by the actual character, and check that nm_strbuf_seek_end() * does the right thing: NUL terminate the buffer and seek past the end of the buffer. */ g_assert_cmpmem(t_buf, t_len - 1, str, t_len - 1); g_assert(t_buf[t_len - 1] == '\0'); g_assert(str[t_len - 1] != '\0'); t_buf[t_len - 1] = str[t_len - 1]; - nm_utils_strbuf_seek_end(&t_buf, &t_len); + nm_strbuf_seek_end(&t_buf, &t_len); g_assert(t_len == 0); g_assert(t_buf == &buf[buf_len]); g_assert(t_buf[-1] == '\0'); } else { - nm_utils_strbuf_seek_end(&t_buf, &t_len); + nm_strbuf_seek_end(&t_buf, &t_len); if (buf_len > 0 && strlen(str) + 1 > buf_len) { /* the buffer was truncated by g_snprintf() above. * - * But nm_utils_strbuf_seek_end() does not recognize that and returns + * But nm_strbuf_seek_end() does not recognize that and returns * a remaining length of 1. * - * Note that other nm_utils_strbuf_append*() functions recognize + * Note that other nm_strbuf_append*() functions recognize * truncation, and properly set the remaining length to zero. - * As the assertions below check for the behavior of nm_utils_strbuf_append*(), - * we assert here that nm_utils_strbuf_seek_end() behaved as expected, and then + * As the assertions below check for the behavior of nm_strbuf_append*(), + * we assert here that nm_strbuf_seek_end() behaved as expected, and then * adjust t_buf/t_len according to the "is-truncated" case. */ g_assert(t_len == 1); g_assert(t_buf == &buf[buf_len - 1]); @@ -2594,7 +2594,7 @@ main(int argc, char **argv) g_test_add_func("/general/test_logging_domains", test_logging_domains); g_test_add_func("/general/test_logging_error", test_logging_error); - g_test_add_func("/general/nm_utils_strbuf_append", test_nm_utils_strbuf_append); + g_test_add_func("/general/nm_strbuf_append", test_nm_utils_strbuf_append); g_test_add_func("/general/nm_utils_ip6_address_clear_host_address", test_nm_utils_ip6_address_clear_host_address); -- cgit 1.3.0-6-gf8a5