Commit graph

138 commits

Author SHA1 Message Date
Thomas Haller 7c66a6be17 build: merge "libnm-util/tests/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Thomas Haller 274de2555b build/trivial: rename VALGRIND_RULES in Makefile.am to NM_LOG_COMPILER 2016-10-19 15:26:30 +02:00
Thomas Haller a83eb773ce all: modify line separator comments to be 80 chars wide
sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
2016-10-03 12:01:15 +02:00
Beniamino Galvani 0e96d23733 crypto: don't try to decrypt PKCS#8 key if no password is supplied
crypto_verify_private_key_data() must try to decrypt the key only when
a password is supplied.

Previously the decrypt test always passed because we detected an
unsupported cipher and faked success. Now since version 3.5.4 gnutls
supports PBES1-DES-CBC-MD5 and the key is actually decrypted when a
password is supplied.

Also, don't assert that a wrong password works because we're now able
to actually verify it (only with recent gnutls).

https://bugzilla.gnome.org/show_bug.cgi?id=771623
2016-09-23 18:05:54 +02:00
Thomas Haller 4b288136e1 shared: move shared files to subdirectory "shared/nm-utils/"
The "shared" directory contains files that are possibly used by all components
of NetworkManager repository.

Some of these files are even copied as-is to other projects (VPN plugins, nm-applet)
and used there without modification. Move those files to a separate directory.
By moving them to a common directory, it is clearer that they belong
together. Also, you can easier compare the copied versions to their
original via

  $ diff -r ./shared/nm-utils/ /path/to/nm-vpn-plugin/shared/nm-utils/
2016-06-16 10:45:53 +02:00
Thomas Haller fa973afa19 tests: add macro NMTST_G_RETURN_MSG for expecting g_return*() failures
A failure to g_return*() by default prints a g_critical() with stringifing the
condition. Add a macro NMTST_G_RETURN_MSG() that reproduces that line to more
accurately match the failure message.
2016-06-09 12:03:39 +02:00
Thomas Haller b769b4dfcb tests: use absolute path for certs test directory
Allows to run the test without first switching directory
  ./libnm-core/tests/test-secrets
2016-06-06 16:35:23 +02:00
Beniamino Galvani 9aad9022e8 libnm-util: skip linking test when address sanitizer is enabled
The linking test causes a crash to check whether libnm and libnm-util
are both linked. If abrt or systemd-coredump are enabled, the core
dump processing will take a long time when the address sanitizer is
enabled, due to the huge process address space. It seems a good choice
to disable the test when NM was compiled with -fsanitize=address.
2016-06-03 22:19:38 +02:00
Thomas Haller 9152dec99f build: disable deprecation checks for internal compilation
For internal compilation we want to be able to use deprecated
API without warnings.

Define the version min/max macros to effectively disable deprecation
warnings.

However, don't do it via CFLAGS option in the makefiles, instead hack it
to "nm-default.h". After all, *every* source file that is for internal
compilation needs to include this header as first.
2016-04-05 22:22:58 +02:00
Thomas Haller 8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Thomas Haller 34b7d49ea6 libnm/tests: convert test cases to use g_assert() instead of ASSERT() (test-setting-8021x.c) 2016-02-14 23:48:00 +01:00
Thomas Haller 432796817e libnm/tests: convert test cases to use g_assert() instead of ASSERT() (test-crypto.c) 2016-02-14 23:48:00 +01:00
Thomas Haller fde5f7bfab libnm/tests: convert test cases to use g_assert() instead of ASSERT() (test-secrets.c) 2016-02-14 20:43:21 +01:00
Thomas Haller 29aa13dc84 libnm/tests: convert test cases to use g_assert() instead of ASSERT() 2016-02-14 14:57:19 +01:00
Dan Williams 80d9a43a25 tests: get rid of FAIL macro 2016-02-11 09:50:29 -06:00
Thomas Haller c510323368 all/tests: fix messages for ASSERT() macro
These places pass an invalid arguments for the given
format string. Fix them, by dropping the overly verbose
ASSERT() macro.
2016-02-03 12:37:43 +01:00
Thomas Haller db80ec05ab build: rename directory "include" to "shared"
Up to now, the "include" directory contained (only) header files that were
used project-wide by libs, core, clients, et al.

Since the directory now also contains a non-header file, the "include"
name is misleading. Instead of adding yet another directory that is
project-wide, with non-header-only content, rename the "include"
directory to "shared".
2015-12-24 11:42:37 +01:00
Thomas Haller 9fdc5e6596 libnm-util/test: use "nm-test-utils.h" in test-setting-dcb 2015-10-10 19:41:42 +02:00
Lubomir Rintel c17ab1b6ff libnm-util: add ipv4.dhcp-timeout property
https://bugzilla.redhat.com/show_bug.cgi?id=1262922
2015-10-06 14:16:55 +02:00
Thomas Haller 7bf10a75db build: extract version macros from "nm-version.h" to new header file "nm-version-macros.h"
For libnm library, "nm-dbus-interface.h" contains defines like the D-Bus
paths of NetworkManager. It is desirable to have this header usable without
having a dependency on "glib.h", for example for a QT application. For that,
commit c0852964a8 removed that dependancy.

For libnm-glib library, the analog to "nm-dbus-interface.h" is
"NetworkManager.h", and the same applies there. Commit
159e827a72 removed that include.
However, that broke build on PackageKit [1] which expected to get the
version macros by including "NetworkManager.h". So at least for libnm-glib,
we need to preserve old behavior so that a user including
"NetworkManager.h" gets the version macros, but not "glib.h".

Extract the version macros to a new header file "nm-version-macros.h".
This header doesn't include "glib.h" and can be included from
"NetworkManager.h". This gives as previous behavior and a glib-free
include.

For libnm we still don't include "nm-version-macros.h" to "nm-dbus-interface.h".
Very few users will actually need the version macros, but not using
libnm.
Users that use libnm, should just include (libnm's) "NetworkManager.h" to
get all headers.
As a special case, a user who doesn't want to use glib/libnm, but still
needs both "nm-dbus-interface.h" and "nm-version-macros.h", can include
them both separately.

[1] https://github.com/hughsie/PackageKit/issues/85

Fixes: 4545a7fe96
2015-09-30 23:10:29 +02:00
Dan Winship 1cf35cb26b core: final gdbus porting
Port remaining bits to gdbus and remove stray dbus-glib references

Drop the dbus-glib version check from configure, since nothing depends
on new dbus-glib any more.

Move nm-dbus-glib-types.h and nm-gvaluearray-compat.h from include/ to
libnm-util/ since they are now only used by libnm-util and libnm-glib.
2015-08-10 09:41:26 -04:00
Dan Winship 22e1a97e12 all: drop includes to <glib/gi18n.h> for "nm-default.h"
The localization headers are now included via "nm-default.h".

Also fixes several places, where we wrongly included <glib/gi18n-lib.h>
instead of <glib/gi18n.h>. For example under "clients/" directory.
2015-08-05 15:35:51 +02:00
Thomas Haller 19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Dan Winship 3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04:00
Thomas Haller 904e961464 all: remove #if GLIB_CHECK_VERSION conditionals around g_type_init()
g_type_init() is now provided by nm-glib-compat.h as nm_g_type_init().
2015-07-12 13:56:52 +02:00
Lubomir Rintel c47c06470a builds: only enable TAP driver for glib >= 2.37.6
No TAP support for previous versions and --tap argument is silently ignored,
confusing the TAP driver.
2015-05-28 12:51:24 +02:00
Lubomir Rintel 6463ce5dd9 tests: use the TAP formatter
The test results in standard format are easily integrated into CI systems.
2015-05-26 13:51:45 +02:00
Lubomir Rintel f627d6db8e tests: move all asserts into tests
Otherwise the TAP formatter would produce a plan-less output.
2015-05-26 13:51:44 +02:00
Lubomir Rintel 2981839bde test: initialize auto-destructed pointers
Otherwise the compiler complains that they could be left uninitialized in case
the function returns too early.

Fixes: 76745817c3
2015-02-09 15:19:30 +01:00
Thomas Haller c50f30e79c tests: enable valgrind tests for tests 2015-02-09 11:51:07 +01:00
Thomas Haller ae73320b8c libnm/tests: fix memleaks in tests for valgrind 2015-02-09 11:51:07 +01:00
Thomas Haller 027ab3efaa libnm-util: only unref and don't destroy hash in nm_connection_to_hash()
The returned hash from nm_connection_to_hash() used to destroy the
nested hashes, instead of only unrefing them.
2015-02-09 11:51:05 +01:00
Thomas Haller 87f2b92da3 libnm-util/tests: fix invalid g_test_expect_message() pattern
A failure to g_return_*() prints a critical warning which contains
G_STRFUNC. Depending on the compiler this contains only the function
name or the entire signature.

Relax the assertion pattern to check the function name.
2014-12-04 17:57:35 +01:00
Thomas Haller e67425347a libnm/test: add test for nm_utils_uuid_generate_from_string() 2014-12-04 17:02:22 +01:00
Dan Winship 539fac8b67 libnm-util: Note that nm_utils_deinit() is a no-op
nm_utils_deinit() is a no-op, so don't suggest that people need to
call it.
2014-12-04 08:39:54 -05:00
Jiří Klimeš ad73a7a1e9 libnm-util: return empty hash, not NULL in nm_setting_to_hash() (bgo #740681)
The function was changed to return NULL instead of empty hash by commit
ad56cfa914. Later, the condition had to be
relaxed for NMSettingGeneric (commit 4d32618264).
Unforfunately, it shows up that there are other use cases that require
presence of a setting (that might have all properties default), such as
NMSettingBridgePort for bridge slave connections.

libnm already behaves this way, since commit
6325c596c0.

https://bugzilla.gnome.org/show_bug.cgi?id=740681
2014-11-25 18:35:41 +01:00
Dan Winship 1313658829 libnm-core, libnm-util: move test cert files to libnm-core/
Move the certificate files used by the libnm-util and libnm-core tests
from libnm-util/tests/certs/ to libnm-core/tests/certs/.
2014-11-21 08:40:09 -05:00
Dan Winship 3bfb163a74 all: consistently include config.h
config.h should be included from every .c file, and it should be
included before any other include. Fix that.

(As a side effect of how I did this, this also changes us to
consistently use "config.h" rather than <config.h>. To the extent that
it matters [which is not much], quotes are more correct anyway, since
we're talking about a file in our own build tree, not a system
include.)
2014-11-13 17:18:42 -05:00
Thomas Haller ce7fc351db libnm: add NMSettingIPConfig:route-metric
https://bugzilla.gnome.org/show_bug.cgi?id=735512
https://bugzilla.redhat.com/show_bug.cgi?id=663730

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller b77567b225 build: fix -Wstrict-prototypes warnings
We disabled -Wstrict-prototypes in commit
db9b1df0e4 .
Fix compiler warnings.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-29 12:30:11 +01:00
Dan Williams e7381662fe trivial: don't shadow rand(3)
Reported by Jordan Messina

(cherry picked from commit 365ca198c0)
2014-08-20 14:18:14 -05:00
Dan Winship 964b9f3513 libnm-core, libnm-util: convert test-crypto, test-setting-8021x.c to gtestutils
Rather than having test-crypto and test-setting-8021x be programs that
you have to pass arguments to to get them to run a single test, just
have them run all of the tests themselves.

This lets us get rid of the big "check-local" rule in Makefile.am and
just use TESTS to run everything.

https://bugzilla.gnome.org/show_bug.cgi?id=734388
2014-08-07 15:57:19 -04:00
Thomas Haller 242d350fcf libnm-util/test: fix tests not to write a core file
test_libnm_linking() executes ./test-libnm-linking which
is supposed to crash. When the user set `ulimit -c unlimited`
before, this will leave a left-over core file.

In case of `make distcheck`, this is quite bad because it lets
the make target fail:

    ERROR: files left in build directory after distclean:
    ./libnm-util/tests/core.31481

Fix this by setting the (soft) rlimit for writing core files
to 0 before executing the test binary.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-04 16:17:36 +02:00
Thomas Haller 536029a96d libnm-util/tests: fix build for older glib with unknown G_SPAWN_DEFAULT
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-04 13:30:37 +02:00
Thomas Haller cb5a976191 libnm-util/test: fix build for clang due to deprecated warning
For clang, we have to include nm-glib-compat.h to redefine
G_GNUC_BEGIN_IGNORE_DEPRECATIONS.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 21:42:04 +02:00
Dan Winship d7b56c7b7e libnm, libnm-utils: error out if mixed libnm/libnm-util symbols are detected
If a program accidentally ends up linking in both libnm and libnm-util
(presumably via different dependencies), error out immediately.
2014-08-01 14:34:40 -04:00
Dan Winship b9fef07fff libnm-util: remove NM_UTIL_PRIVATE_CALL, NMSettingIP4Config:address-labels
Since libnm-util is no longer used from within NM, its copy of
NM_UTIL_PRIVATE_CALL is now useless, and the internal-only
NMSettingIP4Config:address-labels property is no longer needed.
2014-08-01 14:34:05 -04:00
Dan Winship 30c74c6007 build: more srcdir!=builddir fixes
nm-version.h was getting disted, making srcdir!=builddir work for
tarball builds, but not for git builds.

Also, remove "-I${top_builddir}/include" from all Makefile.ams, since
there's nothing generated in include/ any more.
2014-07-15 11:37:19 -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