Commit graph

151 commits

Author SHA1 Message Date
luz.paz 58510ed566 docs: misc. typos pt2
Remainder of typos found using `codespell -q 3 --skip="./shared,./src/systemd,*.po" -I ../NetworkManager-word-whitelist.txt` whereby whitelist consists of:
 ```
ans
busses
cace
cna
conexant
crasher
iff
liftime
creat
nd
sav
technik
uint
```

https://github.com/NetworkManager/NetworkManager/pull/205
2018-09-17 11:26:13 +02:00
Beniamino Galvani 10ca2444b9 build: support meson builds in create-exports script
(cherry picked from commit 9b4bc0824c)
2018-09-13 14:35:25 +02:00
Thomas Haller 921db9132e build: fix whitelisting c-siphash symbols in NetworkManager.ver for device plugin
NetworkManager.ver needs to whitelist symbols needed by device,
settings, and ppp plugin. Fix the generator script to also allow
using c_siphash_*() symbols. These are needed by nm_hash_*().

Without this, wifi device plugin is broken.

Fixes: ccf36ff4ce
2018-09-05 16:55:45 +02:00
Lubomir Rintel d70185ddf1 all: point git references to the GitLab instance
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/2
2018-08-27 11:36:56 +02:00
Thomas Haller 9730961a02 tests/trivial: rename ip4_addr_ne32() to ip4_addr_be32() in test-networkmanager-service.py
The function is supposed to return the IPv4 address as 32 bit integer in
network byte order (bit endian). The ip4_addr_ne32() name is confusing,
because "ne" commonly stands for "native endianness".

Compare also "unaligned.h" and unaligned_read_ne32(), which also
stands for native endianness (host order), not network order (big
endian).

Rename.
2018-07-11 17:53:44 +02:00
Lubomir Rintel 4fa1a49542 docs: include missing documentation in libnm and D-Bus docs
Check that we don't repeat the omission in future.

(cherry picked from commit cb1172ee3d)
2018-06-28 20:43:26 +02:00
Thomas Haller 296da44235 tests: don't exit test-networkmanager-service.py after 20 seconds
Tests might just take longer than 20 seconds.

Also, we already watch stdin to determine whether the service
should exit.

(cherry picked from commit 4e18ef49bf)
2018-06-18 11:33:15 +02:00
Thomas Haller efddb0cef5 tests: improve NetworkManager stub service for Wi-Fi scanning
Now that nmcli initiates a scan before displaying Wi-Fi networks,
the stub service must properly support that as well.

For the moment, the stub service chooses "now" as LastScan timestamp.
This causes nmcli not to trigger a new scan, because nmcli gives
unstable output if multiple nmcli processes in parallel race to
trigger a Wi-Fi scan. That should be fixed.

(cherry picked from commit 56a0488bba)
2018-06-18 10:58:05 +02:00
Thomas Haller e05ce581b6 tests: fix race in setting signal strength for Wi-Fi AP in NM stub
This opens the tests up to races. If we want to change the strength, we
need to do it in a controlled, race-free manner. This is especially the
case, because clients/tests run a large number of nmcli instances in
parallel, and it's thus racy which signal the nmcli processes will
see.

This also fixes a bug at

    self._dbus_property_set(IFACE_WIFI_AP, PRP_WIFI_AP_STRENGTH, strength)

@strength must be a D-Bus type, so that python-dbus knows the correct
type for serialization.

(cherry picked from commit 7e118c0091)
2018-06-18 10:58:04 +02:00
Lubomir Rintel cfa3a02b91 tools/test-service: utilize nm_utils_get_timestamp_msec()
This is probably better than a hardcoded timestamp.
2018-06-15 16:23:30 +02:00
Lubomir Rintel 07fd0502f6 wifi: expose LastScan as milliseconds not seconds
This doesn't wrap around in 68 years of uptime and is consistent with
o.fd.NM.Checkpoint.Created.
2018-06-15 16:23:30 +02:00
Thomas Haller 9a14f9caa5 clients/tests: fix unstable tests for Python2 vs. Python3
Currently, nmcli does not sort the list of available connections
for display. Instead, it shows them in the order as NetworkManager
exposes them on D-Bus.

Previously, test-networkmanager-service.py, would generate the list
of available connections by iterating the connections dictionary.
In Python (at least until Python 3.6), the order when iterating over
dictionaries is undefined. This inconsistancy lets tests behave
differently depending on the python version. Possibly with Python
3.4 and 3.5, tests might even behave differently between individual
runs (since Python there uses siphash with a randomized hash seed).
2018-06-14 16:38:33 +02:00
Lubomir Rintel c00e17578f wifi: expose the LastScan property
This is the time when the last Wi-Fi scan finished. It will help clients
decide whether the AP list is fresh enough.
2018-06-13 14:44:06 +02:00
Lubomir Rintel f037aaeb90 tools/test-service: mock o.fd.NM.Settings.Connection.Filename property 2018-06-11 15:06:49 +02:00
Thomas Haller f671fa5137 clients/tests: expose IP and DHCP configs in test-networkmanager-service.py stub
For adding tests what nmcli shows regarding IP and DHCP configuration,
let the stub service generate config instances.
2018-06-11 11:20:31 +02:00
Thomas Haller dd2da759de clients/tests: seed generated numbers for test-networkmanager-service.py
At several places, "test-networkmanager-service.py" uses generated numbers
with a defined seed. For example, generated connection's UUID is
generated in a predictable, but randomized way (if you forgive the
inprecise use of the word "random" in context of using a deterministic
seed).

Aside the connection's UUID, this becomes more interesting in the next commit
where the stub server generates a list of IP and DHCP settings in a predictable
randomized way.

For "clients/tests" we spawn the test service multiple times, but also
create similar environments by calling init_001(). This is done for
convenience, where out of lazyness all the tests share one setup. But it's
still a good idea that these tests generate slightly different setups,
wherever applicable. this increases the possible setups which get tested.
For example, the number of static IPv4 addresses (the following commit) is
interested to explicitly test for zero or a non-zero number of
addresses. If all tests happen to use the same seed, the tests are expected
to also generate the same number of addresses, and we miss an opportunity to
hit interesting test cases.

There is still no guarantee that all interesting cases are hit, the chances are just
better. The approach of generating the setup randomly, does not preclude that
the stub-server allows to explicitly configure the setup. However, due to the
sheer number of combinations that might be interesting to test, it's much simpler
to rely on some randomization and have the justifid hope we catch interesting cases.
Also in terms of runtime of the test, the cli unit tests should complete within
few seconds. Testing every combination would result in huge tests and long runtimes.

Also, the patch refactors generating random numbers in
"test-networkmanager-service.py". For example, it introduces
Util.RandomSeed(), which can be used to generate a sequence of different
random numbers. It works by having an internal state and a counter which is
combined to chain the seed and generate different numbers on each call.
2018-06-11 11:20:31 +02:00
Thomas Haller 2a53555faa tests: simulate available-connections in test-networkmanager-service.py 2018-06-11 10:30:27 +02:00
Thomas Haller 3255a97b3a tests: fix dry-run for _dbus_property_set() in test-networkmanager-service.py 2018-06-11 10:30:27 +02:00
Thomas Haller 2e22c931f9 clients/tests: test creating and activating VPN connection 2018-06-06 10:27:35 +02:00
Thomas Haller 360f952399 clients/tests: test nmcli con mod command with different locale
Just to give it some variety. Also, note how the message from the
server cannot be translated. Which is the case with real NetworkManager
as well, and is a major usability issue.
2018-06-05 20:08:03 +02:00
Thomas Haller f3dddcff2a clients/tests: verify connections in test-networkmanager-service.py using libnm
The real NetworkManager service has a clear understanding how a valid
connection looks like. This is what nm_connection_verify() returns.

Let also our stub-service verify connections the same way.

Note that this is cumbersome, because the stub service uses python's
dbus module, while libnm only accepts creating NMConnection instances
from GVariant. Thus, we need to a cumbersome conversion first.

It would be better if test-networkmanager-service.py would also expose
normalized connections on D-Bus. But that requires the inverse converion
from GVariant to python dbus.
2018-06-05 20:08:03 +02:00
Thomas Haller 780af4cffb tests: nest custom exceptions in common namespace 2018-06-05 20:08:03 +02:00
Thomas Haller ef612b8e23 tests: reorder definitions in test-networkmanager-service.py
Define all custom exception types together.
2018-06-05 20:08:03 +02:00
Thomas Haller e862e67f48 tests: use libnm defines for NM test stub
These names are unique and well-known.
2018-06-05 20:08:03 +02:00
Thomas Haller 78576794eb tests: rename local variables in NM test stub (2)
lso, the name "connection" and "con" is overused.

Use "con_inst" where we mean an instance of a "Connection" class,
that is, the object exposed on D-Bus.
2018-06-05 20:08:03 +02:00
Thomas Haller 9cc1876fd7 tests: rename local variables in NM test stub (1)
- don't use "hash" for a local variable in python.
  The editor highlights it like a special python name.

- don't use "settings" for Connection.settings. Name it
  Connection.con_hash. The name "settings" is over-used already.
  "con_hash" really is the nested dictionary that we expose/receive
  from D-Bus. If we would use libnm for it, it would be an
  NMSimpleConnection instance, but we don't.
2018-06-05 20:08:03 +02:00
Thomas Haller 3645be6484 clients/tests: add test for showing invisible connection in nmcli
It also shows how we handle invisible connections wrongly, when we have
multiple active-connections that reference them.
2018-06-01 16:03:23 +02:00
Beniamino Galvani af94687161 tests: implement Update2() in NetworkManager stub 2018-05-28 11:21:07 +02:00
Thomas Haller d424de10bf clients/tests: add SetProperties operation to test-networkmanager-service.py stub
It is a hook to set one or several D-Bus properties at once. Properties that are
to be set-able, have to be whitelisted in the stub.
2018-05-24 16:40:17 +02:00
Thomas Haller c834a8e822 tests: don't return path name from obj.get_managed_ifaces() in test-networkmanager-service.py 2018-05-24 16:40:17 +02:00
Thomas Haller c905ee94f0 tests: fix quitting mainloop in test-networkmanager-service.py
Previously, the callbacks would return gl.mainloop.quit(), which is None
and thus the source got removed already. The later GLib.source_remove()
would thus use an invalid source-id.

Fix that, by no removing the source id from the callback.

Fixes: b1ff82eba5
2018-05-15 11:44:47 +02:00
Thomas Haller 2ef24490a3 tests: explicitly export/unexport objects
Instead of exporting exported-objects during construction, export
them right before we register them (for example, in case of device
instances, before we add the device to the manager's device list).

Likewise, when removing the object from the list, always explicitly
unexport them.

Without explicitly unexporting the objects, they can also not be
removed, because object-manage and D-Bus library keep references
to them.
2018-05-15 10:32:02 +02:00
Thomas Haller 39118a1f42 tests/trivial: move code 2018-05-15 10:06:38 +02:00
Thomas Haller b1ff82eba5 tests: rework handling of D-Bus properties in NetworkManager stub service
Instead of registering a __get_props() function which constructs the
entire hash anew each time, register a props dictionary. This dictionary
is used as cache for the properies.

In most cases, we don't need to additionally cache the properties
outside the props dictionary. Also, add _dbus_property_set() which
sets the property and emits the notification.

Also, cleanup the property names by giving them a PRP_ prefix.
2018-05-15 10:04:13 +02:00
Thomas Haller 0d302caab8 tests: better implement ActivateConnection in NetworkManager stub service
Transition the states, so that `nmcli con up` can succeed.
2018-05-14 17:53:03 +02:00
Thomas Haller f563a6dfeb tests: various refactoring in tools/test-networkmanager-service.py
- no more global variables, except those in the new variable "gl".

- don't pass that bus instance around. Use the singleton gl.bus.

- separate creation of ExportedObj from exporting on D-Bus.

- use enum values loaded from NM via GObject introspection.

- the visible change is that the generated D-Bus paths now start
  counting at one. That is also how NetworkManager behaves, and
  it looks nicer to have no zero ID for an object.
2018-05-14 17:53:03 +02:00
Thomas Haller 6d34d5e41b tests: refactor finding device in NetworkManager stub
- add find_devices() and find_device_first() functions,
  to not re-implement iterating the device list.

- for test functions, accept the device's "ident", instead
  of ifname. The "ident" must b unique, contrary to the "ifname".
2018-05-11 16:51:20 +02:00
Thomas Haller d4093a3a2c clients/tests: add python test script for nmcli tests
Add a test which runs nmcli against our stub NetworkManager
service and compares the output.

The output formats of nmcli are complicated and not easily understood.
For example how --mode tabular|multiline interacts with selecting
output-fields (--fields) and output modes ([default]|--terse|--pretty).
Also, there are things like `nmcli connection show --order $FIELD_SPEC`.

We need unit tests to ensure that we don't change the output
accidentally.
2018-05-11 16:51:20 +02:00
Thomas Haller 9628aabc2f tests: use libnm via pygobject in tools/test-networkmanager-service.py
tools/test-networkmanager-service.py is our NetworkManager stub server.

NetworkManager uses libnm(-core) heavily, for example to decide whether
a connection verifies (nm_connection_verify()) and for normalizing
connections (nm_connection_normalize()).

If the stub server wants to mimic NetworkManager, it also must use these
function. Luckily, we already can do so, by loading libnm using python
GObject introspection.

We already correctly set GI_TYPELIB_PATH search path, so that the
correct libnm is loaded -- provided that we build with introspection
enabled.

We still need to gracefully fail, if starting the stub server fails.
That requries some extra effort. If the stub server notices that
something is missing, it shall exit with status 77. That will cause
the tests to g_test_skip().
2018-05-11 16:51:20 +02:00
Thomas Haller 3934a2c392 build: set LD_LIBRARY_PATH and GI_TYPELIB_PATH variables in run-nm-test.sh
With autotools, we use libtool so that the right libraries are
automatically found. Still, we won't find the right GI typelib.

Add a mechanism so that when make/meson invokes the run-nm-test.sh
runner, it passes the build-root directory.

Also, try to autodetect when invoked manually.
2018-05-11 16:51:20 +02:00
Beniamino Galvani a2479b95c0 build: meson: use run-nm-test.sh to run tests
Like autotools, use the wrapper script 'run-nm-test.sh' that starts a
separate D-Bus session when needed.
2018-04-12 09:21:10 +02:00
Thomas Haller 4116fa1044 tools/run-nm-test.sh: add -d option to set NMTST_DEBUG=d
For convenience, by passing "-d" to tools/run-nm-test.sh,
we set NMTST_DEBUG=d (if $NMTST_DEBUG is unset previously).
2018-04-09 20:16:30 +02:00
Thomas Haller 0474441e22 settings: drop unmaintained ifnet settings plugin of Gentoo
Even Gentoo disables this plugin since before 0.9.8 release
of NetworkManager. Time to say goodbye.

If somebody happens to show up to maintain it, we may resurrect it
later.

If "$distro_plugins=ifnet" was set, configure.ac would use that
to autodetect --with-hostname-persist=gentoo. Replace that autodetect
part by checking for /etc/gentoo-release file.
2017-12-21 10:50:33 +01:00
Yifan J 797d9c4403 python: make dbus, gi examples, and debug-helper.py python3 ready
https://bugzilla.gnome.org/show_bug.cgi?id=791121
2017-12-04 11:21:40 +01:00
Lubomir Rintel aa0707005c tools: fix the PowerPC build
On ppc archtecture the "nm_bt_vtable_network_server" symbol in the small
objects section instead of .bss, represencted by a "S" letter. Also
include "G" which is an equivalent thing for initialized data. We don't
seem to have such objects at the moment, but when we do it could result
in a nasty surprise.
2017-06-28 18:35:23 +02:00
Thomas Haller 484d666485 build: fix nm binutils tool when building with LTO
When building with -flto, we need to use linker plugins.
In case of binutils' nm, it means to prefer gcc-nm if
available.

Like for ranlib and ar, prefer gcc-nm.

- replace AC_PATH_TOOL() by AC_CHECK_TOOLS(). That is consistent
  with what we do for ar,ranlib and suggested on bgo#783311.
- instead of using the variable $BINUTILS_NM, replace it by
  $NM, which is more common according to bgo#783311.
- Keep recognizing $BINUTILS_NM environment, which was introduced
  by commit 8bc88bcc7c. This is purely to keep previous build
  scripts working. Originally I named it "$BINUTILS_NM" because
  using $NM in NetworkManager seemed confusing. But well...

https://bugs.gentoo.org/show_bug.cgi?id=620052
https://bugzilla.gnome.org/show_bug.cgi?id=782525
https://bugzilla.gnome.org/show_bug.cgi?id=783311
2017-06-01 12:51:31 +02:00
Thomas Haller a81b604cc1 tests: accept trailing arguments to "tools/run-nm-test.sh"
Previously, the test runner would only accept leading options,
an optional "--" separator, followed by "$TEST" and optional arguments
for the test.

Like

  ./tools/run-nm-test.sh -m src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh

That is annoying, because to toggle an option you have to seek the
curser in the before the test name.

Now, accept a "--test" option, so that the above can be done with trialing
arguments:

  ./tools/run-nm-test.sh -t src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh -m

However, the arguments for the tests still must come last:

  ./tools/run-nm-test.sh -m [--] src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh -p /settings/plugins/ifcfg-rh/bridge/write-master
  ./tools/run-nm-test.sh -t src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh -m [--] -p /settings/plugins/ifcfg-rh/bridge/write-master
2017-03-02 16:08:54 +01:00
Thomas Haller 61f7dd7284 tests: fix "tools/run-nm-test.sh" to build test first
./tools/run-nm-test.sh -m src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh

makes the test before running it. However, that failed if the
test didn't exist already. Reorder the code so that we always
try to make the test before trying to run it.
2017-03-02 16:08:54 +01:00
Lubomir Rintel eb0228713d tools: only consider SOs that exist when finding symbols to export
Also, set pipefail to catch the failures of all components of a
pipeline.
2017-02-16 16:12:02 +01:00
Thomas Haller 8bc88bcc7c build: allow configuring path to binutils's nm tool during build
`nm` is used by "tools/create-exports-NetworkManager.sh" script.
Alloc configuring an explicit path during configure.

  BINUTILS_NM=/usr/bin/nm ./configure
2017-02-08 16:52:23 +01:00