about summary refs log tree commit diff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/config/nm-test-device.c1
-rw-r--r--src/tests/config/nm-test-device.h1
-rw-r--r--src/tests/config/test-config.c1
-rw-r--r--src/tests/meson.build10
-rw-r--r--src/tests/test-core-with-expect.c (renamed from src/tests/test-general-with-expect.c)10
-rw-r--r--src/tests/test-core.c (renamed from src/tests/test-general.c)34
-rw-r--r--src/tests/test-dcb.c1
-rw-r--r--src/tests/test-ip4-config.c1
-rw-r--r--src/tests/test-ip6-config.c1
-rwxr-xr-xsrc/tests/test-secret-agent.py1
-rw-r--r--src/tests/test-systemd.c11
-rw-r--r--src/tests/test-utils.c1
-rw-r--r--src/tests/test-wired-defname.c1
13 files changed, 40 insertions, 34 deletions
diff --git a/src/tests/config/nm-test-device.c b/src/tests/config/nm-test-device.c
index 3a8ef266..dd624b44 100644
--- a/src/tests/config/nm-test-device.c
+++ b/src/tests/config/nm-test-device.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager -- Network link manager
  *
  * This program is free software; you can redistribute it and/or modify
diff --git a/src/tests/config/nm-test-device.h b/src/tests/config/nm-test-device.h
index c193b860..586bbe6d 100644
--- a/src/tests/config/nm-test-device.h
+++ b/src/tests/config/nm-test-device.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager -- Network link manager
  *
  * This program is free software; you can redistribute it and/or modify
diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c
index 10084b7f..a5ef1431 100644
--- a/src/tests/config/test-config.c
+++ b/src/tests/config/test-config.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 17857676..b2bc13ab 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -1,8 +1,8 @@
 subdir('config')
 
 test_units = [
-  'test-general',
-  'test-general-with-expect',
+  'test-core',
+  'test-core-with-expect',
   'test-ip4-config',
   'test-ip6-config',
   'test-dcb',
@@ -18,7 +18,7 @@ foreach test_unit: test_units
   )
 
   test(
-    'src/' + test_unit,
+    test_unit,
     test_script,
     args: test_args + [exe.full_path()],
     timeout: default_test_timeout,
@@ -34,7 +34,7 @@ cflags = [
 
 exe = executable(
   test_unit,
-  [test_unit + '.c'],
+  test_unit + '.c',
   include_directories: src_inc,
   dependencies: libnm_core_dep,
   c_args: cflags,
@@ -45,7 +45,7 @@ exe = executable(
 )
 
 test(
-  'src/' + test_unit,
+  test_unit,
   test_script,
   args: test_args + [exe.full_path()],
 )
diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-core-with-expect.c
index 8339fa5d..d38025ec 100644
--- a/src/tests/test-general-with-expect.c
+++ b/src/tests/test-core-with-expect.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -385,7 +384,12 @@ test_nm_utils_kill_child (void)
 		err = waitpid (child_pid, &exit_status, 0);
 	} while (err == -1 && errno == EINTR);
 	g_assert (err == child_pid);
-	g_assert (WIFEXITED (exit_status) && WEXITSTATUS(exit_status) == 0);
+	if (WIFEXITED (exit_status))
+		g_assert_cmpint (WEXITSTATUS (exit_status), ==, 0);
+	else {
+		g_assert_cmpint (exit_status, ==, 0);
+		g_assert_not_reached ();
+	}
 }
 
 /*****************************************************************************/
@@ -541,7 +545,7 @@ test_nm_utils_new_vlan_name (void)
 			guint vlan_id;
 
 			/* Create a random VLAN id between 0 and 4094 */
-			vlan_id = nmtst_get_rand_int () % 4095;
+			vlan_id = nmtst_get_rand_uint32 () % 4095;
 
 			vlan_id_s = g_strdup_printf (".%d", vlan_id);
 
diff --git a/src/tests/test-general.c b/src/tests/test-core.c
index 0dee566e..3eaad104 100644
--- a/src/tests/test-general.c
+++ b/src/tests/test-core.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -109,6 +108,17 @@ test_nm_utils_ip6_address_clear_host_address (void)
 /*****************************************************************************/
 
 static void
+test_logging_domains (void)
+{
+	const char *s;
+
+	s = nm_logging_all_domains_to_string ();
+	g_assert (s && s[0]);
+}
+
+/*****************************************************************************/
+
+static void
 _test_same_prefix (const char *a1, const char *a2, guint8 plen)
 {
 	struct in6_addr a = *nmtst_inet6_from_string (a1);
@@ -136,7 +146,7 @@ test_nm_utils_ip6_address_same_prefix (void)
 		nmtst_rand_buf (NULL, a.ptr, sizeof (a));
 		nmtst_rand_buf (NULL, b.ptr, sizeof (b));
 again_plen:
-		plen = nmtst_get_rand_int () % 129;
+		plen = nmtst_get_rand_uint32 () % 129;
 		if (!is_same && NM_IN_SET (plen, 0, 128))
 			goto again_plen;
 
@@ -170,7 +180,7 @@ again_plen:
 	for (n = 0; n < N; n++) {
 		nmtst_rand_buf (NULL, a.ptr, sizeof (a));
 		nmtst_rand_buf (NULL, b.ptr, sizeof (b));
-		plen = nmtst_get_rand_int () % 129;
+		plen = nmtst_get_rand_uint32 () % 129;
 
 		memset (addrmask.ptr, 0xFF, sizeof (addrmask));
 		nm_utils_ip6_address_clear_host_address (&addrmask.val, &addrmask.val, plen);
@@ -187,7 +197,7 @@ again_plen:
 
 		nmtst_rand_buf (NULL, a.ptr, sizeof (a));
 		nmtst_rand_buf (NULL, b.ptr, sizeof (b));
-		plen = nmtst_get_rand_int () % 129;
+		plen = nmtst_get_rand_uint32 () % 129;
 
 		if (!plen)
 			continue;
@@ -1445,7 +1455,7 @@ test_nm_utils_strbuf_append (void)
 		const char *_str_iter; \
 		gs_free char *_str = NULL; \
 		\
-		switch (nmtst_get_rand_int () % 4) { \
+		switch (nmtst_get_rand_uint32 () % 4) { \
 		case 0: \
 			nm_utils_strbuf_append (_buf, _len, (format), __VA_ARGS__); \
 			break; \
@@ -1473,7 +1483,7 @@ test_nm_utils_strbuf_append (void)
 		gsize *_len = (len); \
 		const char *_str = (str); \
 		\
-		switch (nmtst_get_rand_int () % 4) { \
+		switch (nmtst_get_rand_uint32 () % 4) { \
 		case 0: \
 			nm_utils_strbuf_append (_buf, _len, "%s", _str ?: ""); \
 			break; \
@@ -1498,7 +1508,7 @@ test_nm_utils_strbuf_append (void)
 		gsize *_len = (len); \
 		char _ch = (ch); \
 		\
-		switch (nmtst_get_rand_int () % 4) { \
+		switch (nmtst_get_rand_uint32 () % 4) { \
 		case 0: \
 			nm_utils_strbuf_append (_buf, _len, "%c", _ch); \
 			break; \
@@ -1516,7 +1526,7 @@ test_nm_utils_strbuf_append (void)
 
 	for (buf_len = 0; buf_len < 10; buf_len++) {
 		for (rep = 0; rep < 50; rep++) {
-			const int s_len = nmtst_get_rand_int () % (sizeof (str) - 5);
+			const int s_len = nmtst_get_rand_uint32 () % (sizeof (str) - 5);
 			char *t_buf;
 			gsize t_len;
 			int test_mode;
@@ -1532,7 +1542,7 @@ test_nm_utils_strbuf_append (void)
 			t_buf = buf;
 			t_len = buf_len;
 
-			test_mode = nmtst_get_rand_int () % 5;
+			test_mode = nmtst_get_rand_uint32 () % 5;
 
 			switch (test_mode) {
 			case 0:
@@ -1557,7 +1567,7 @@ test_nm_utils_strbuf_append (void)
 				g_snprintf (t_buf, t_len, "%s", str);
 				if (   t_len > 0
 				    && strlen (str) >= buf_len
-				    && (nmtst_get_rand_int () % 2)) {
+				    && (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()
@@ -1677,7 +1687,7 @@ test_duplicate_decl_specifier (void)
 		(_a > _b ? _a : _b); \
 	})
 
-	v_result[0] = TEST_MAX (v_const[0], nmtst_get_rand_int () % 5) + v2;
+	v_result[0] = TEST_MAX (v_const[0], nmtst_get_rand_uint32 () % 5) + v2;
 
 	NM_PRAGMA_WARNING_REENABLE
 }
@@ -2180,6 +2190,8 @@ main (int argc, char **argv)
 {
 	nmtst_init_with_logging (&argc, &argv, NULL, "ALL");
 
+	g_test_add_func ("/general/test_logging_domains", test_logging_domains);
+
 	g_test_add_func ("/general/nm_utils_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);
diff --git a/src/tests/test-dcb.c b/src/tests/test-dcb.c
index 6291f254..55206f1d 100644
--- a/src/tests/test-dcb.c
+++ b/src/tests/test-dcb.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c
index f98c84c3..d4d0c1bb 100644
--- a/src/tests/test-ip4-config.c
+++ b/src/tests/test-ip4-config.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c
index 8f5f41d7..bc212ba7 100644
--- a/src/tests/test-ip6-config.c
+++ b/src/tests/test-ip6-config.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/tests/test-secret-agent.py b/src/tests/test-secret-agent.py
index d3f82802..d8cabc65 100755
--- a/src/tests/test-secret-agent.py
+++ b/src/tests/test-secret-agent.py
@@ -1,5 +1,4 @@
 #!/usr/bin/env python
-# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
 from gi.repository import GLib
 import sys
diff --git a/src/tests/test-systemd.c b/src/tests/test-systemd.c
index 20cbd50e..090dd691 100644
--- a/src/tests/test-systemd.c
+++ b/src/tests/test-systemd.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -157,7 +156,7 @@ test_sd_event (void)
 
 		g_assert_cmpint (sd_event_default (NULL), ==, 0);
 
-		for (i = 0, n = (nmtst_get_rand_int () % (G_N_ELEMENTS (other_events) + 1)); i < n; i++) {
+		for (i = 0, n = (nmtst_get_rand_uint32 () % (G_N_ELEMENTS (other_events) + 1)); i < n; i++) {
 			r = sd_event_default (&other_events[i]);
 			g_assert (r >= 0 && other_events[i]);
 		}
@@ -177,7 +176,7 @@ test_sd_event (void)
 		g_assert (!user_data.event_source);
 
 		event = sd_event_unref (event);
-		for (i = 0, n = (nmtst_get_rand_int () % (G_N_ELEMENTS (other_events) + 1)); i < n; i++)
+		for (i = 0, n = (nmtst_get_rand_uint32 () % (G_N_ELEMENTS (other_events) + 1)); i < n; i++)
 			other_events[i] = sd_event_unref (other_events[i]);
 		nm_clear_g_source (&sd_id);
 		for (i = 0, n = G_N_ELEMENTS (other_events); i < n; i++)
@@ -311,15 +310,15 @@ test_nm_sd_utils_unbase64mem (void)
 	_test_unbase64mem ("YQ==", "a");
 	_test_unbase64mem_inval ("YQ==a");
 
-	rnd_len = nmtst_get_rand_int () % sizeof (rnd_buf);
+	rnd_len = nmtst_get_rand_uint32 () % sizeof (rnd_buf);
 	for (i = 0; i < rnd_len; i++)
-		rnd_buf[i] = nmtst_get_rand_int () % 256;
+		rnd_buf[i] = nmtst_get_rand_uint32 () % 256;
 	rnd_base64 = g_base64_encode (rnd_buf, rnd_len);
 	_test_unbase64mem_mem (rnd_base64, rnd_buf, rnd_len);
 
 	_test_unbase64char ('=', FALSE);
 	for (i = 0; i < 10; i++) {
-		char ch = nmtst_get_rand_int () % 256;
+		char ch = nmtst_get_rand_uint32 () % 256;
 
 		if (ch != '=')
 			_test_unbase64char (ch, TRUE);
diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c
index c326f790..f3eb66ef 100644
--- a/src/tests/test-utils.c
+++ b/src/tests/test-utils.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/tests/test-wired-defname.c b/src/tests/test-wired-defname.c
index 97a6c319..27e0590b 100644
--- a/src/tests/test-wired-defname.c
+++ b/src/tests/test-wired-defname.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by