Commit Graph

24 Commits

Author SHA1 Message Date
Dan Winship
c81fb49aa5 all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).

Fix this by changing the include guards in the non-API-stable parts of
the tree:

  - libnm-glib/nm-ip4-config.h remains   NM_IP4_CONFIG_H
  - libnm/nm-ip4-config.h now uses     __NM_IP4_CONFIG_H__
  - src/nm-ip4-config.h now uses       __NETWORKMANAGER_IP4_CONFIG_H__

And likewise for all other headers.

The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-16 10:17:14 -04:00
Thomas Haller
df2711f197 nmtst: fix memory leak in nmtst_create_minimal_connection()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-07 22:26:28 +02:00
Thomas Haller
d83f3777ad nmtst: add nmtst_create_minimal_connection() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-07 15:43:43 -04:00
Dan Winship
2570c5a17c libnm-util, libnm-glib: whitespace fixes
Fix indentation, kill trailing whitespace, split some long lines.
2014-07-15 09:44:55 -04:00
Dan Winship
cb7e1893e7 libnm-util, libnm-glib: standardize copyright/license headers
- Remove list of authors from files that had them; these serve no
  purpose except to quickly get out of date (and were only used in
  libnm-util and not libnm-glib anyway).

- Just say "Copyright", not "(C) Copyright" or "Copyright (C)"

- Put copyright statement after the license, not before

- Remove "NetworkManager - Network link manager" from the few files
  that contained it, and "libnm_glib -- Access network status &
  information from glib applications" from the many files that
  contained it.

- Remove vim modeline from nm-device-olpc-mesh.[ch], add emacs modeline
  to files that were missing it.
2014-07-15 09:44:54 -04:00
Thomas Haller
362c4fe188 nmtst: ensure call to nm_utils_get_monotonic_timestamp_s() in nmtst_init()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-10 13:27:12 +02:00
Thomas Haller
48b5ba7cea nmtst: add NMTST_DEBUG=no-expect-message for debugging assert_message tests
Some tests want to assert against the messages logged using g_test_expect_message().
In this mode, nmtst will not log anything itself.

Interpret the option no-expect-message which turns g_test_expect_message()
into a NOP and turns logging on. The use of this is for debugging such
tests, without asserting against the messages but printing them instead.

For tests that are not in the assert_message mode, the option has no
effect.

Example:
  NMTST_DEBUG=debug,no-expect-message make -C src/settings/plugins/keyfile/tests/ check

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
9114794f65 nmtst: turn on g_debug() messages in nmtst_init() when debug logging is enabled
In tests nm-logging will directly write using g_log. Also, non-core components
use g_log() for logging. glib will not print messages with level
G_LOG_LEVEL_INFO or G_LOG_LEVEL_DEBUG unless G_MESSAGES_DEBUG is set.

When the user specifies NMTST_DEBUG turning on 'debug' or
'log-level=DEBUG' it can be reasonably assumed that he wants to see
debug messages. nmtst_init() now sets G_MESSAGES_DEBUG=all.

The user can disable this behaviour, by setting instead G_MESSAGES_DEBUG='',
because nmtst_init() will not reset an existing G_MESSAGES_DEBUG.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
8ce1eb3837 nmtst: add new mode where tests assert against logged messages (assert_messages)
In this mode, nmtst itself will not log anything and not set the logging
level. Also, it will set g_log_set_always_fatal().

This is for tests that want to assert against all logged messages via
g_test_expect_message().

In this mode also setting the logging level via NMTST_DEBUG variable has
no effect. The test is expected to manage the logging level itself and
changing the logging level might interfere with the test.

As a showcase, move keyfile/tests/test-keyfile.c to nmtst.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
ed868a388b core: add compatibility wrapper for g_test_skip() to nm-glib-compat.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
284ef00d16 nmtst: call nm_utils_init() in nmtst_init()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
5d3bef5d3f nmtst: add nmtst_spawn_sync()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
7a7dd9203d nmtst: add nmtst_reexec_sudo() function
Interpret environment variable NMTST_DEBUG which allows
to specify 'sudo-cmd=CMD'. If the test program calls
nmtst_reexec_sudo(), it will `exec CMD "$0" "$@"`.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
9df3a23d26 nmtst: add nmtst_free()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
8af001eae4 nmtst: combine files nm-test-helpers.h and nm-test-utils.h
Move the content of nm-test-helpers.h to nm-test-utils.h
which completly replaces the older file.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
0e9cd4f6fc nmtst: add functions nmtst_platform_ip[46]_routes_equal
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
be56b26c7d nmtst: add functions nmtst_static_SIZE_NUM() to create a copy of a string returned from an internal buffer
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
5a58afcec9 nmtst: add nmtst_is_debug() and interpret environment NMTST_DEBUG
Also enable "DEBUG" logging conditionally depending on is_debug().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
64d09e5afe nmtst: add nmtst_initialized()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
86693d2378 nmtst: add parameter to nmtst_init to setup nm-logging
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
17c300b816 nmtst: include missing header file glib-object.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
d29cd00d2b nmtst: return const address from nmtst_inet6_from_string()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
237ee05887 nmtst: make all test functions "inline static"
'inline' is needed to avoid compiler warnings about unused
functions.
Marking them only as 'inline' was simply wrong and leads to
linker errors when including the header in different translation
units.

By making them "inline static" we also don't need to foward declare the
function prototype to avoid another compiler warning.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
a268b825d7 nmtst: move header file to include/ directory
https://bugzilla.gnome.org/show_bug.cgi?id=706293

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00