Commit graph

268 commits

Author SHA1 Message Date
Thomas Haller dd595c6c1d
tools: fix bogus code in "tools/generate-docs-nm-property-infos.py"
Coverity warns about this:

  2. NetworkManager-1.32.2/tools/generate-docs-nm-property-infos.py:117: identical_branches:
  The same code is executed regardless of whether "temp.index(subelement) < len(temp) - 1" is
  true, because the then and else branches are identical. Should one of the branches be modified,
  or the entire 'if' statement replaced?

Fixes: c3504f7e62 ('Rewrite `./tools/generate-docs-nm-property-infos.py` with XML library')
2021-07-06 09:08:36 +02:00
Wen Liang 0b87d8d6c5 Support new attribute tag description-docbook
`description-docbook` is the alternative tag to `description`, the
difference is that `description-docbook` expects docbook XML but not
plaintext.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-06-23 08:59:45 -04:00
Frederic Martinsons 8dc64c7bdd
tools: correct NetworkManager top object set_state function
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-06-23 13:56:15 +02:00
Frederic Martinsons e27141fb90
tools: suppress duplicate state change in deactivation step of active connection
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-06-23 13:56:15 +02:00
Thomas Haller 85c6ab97ef
tools: add debug printf statements to "tools/generate-docs-nm-settings-docs-merge.py"
It's hard to understand what "tools/generate-docs-nm-settings-docs-merge.py"
does. Add dbg() statements that are all NOP by default. But the user can
easily patch the code to print what is happening. This is only for
debugging the script.
2021-06-09 12:46:32 +02:00
Thomas Haller 26f0fb0604
python: remove unused imports
They are flagged by lgtm.com. Avoid the warning by dropping unused
includes.
2021-05-27 08:52:30 +02:00
Thomas Haller c3d3429916
tools: drop spurious whitespace in "src/libnm-client-impl/nm-property-infos-*.xml"
<nm-setting-docs>
  -  <setting name="6lowpan">
  +<setting name="6lowpan">
   </setting>
2021-05-26 15:33:29 +02:00
Wen Liang c3504f7e62
Rewrite ./tools/generate-docs-nm-property-infos.py with XML library
Instead of writing XML text word by word, it is less error prone to
write with XML library.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-20 10:41:20 +02:00
Wen Liang dd38eb1f76
Adjust property tag format in nm-property-infos-*.xml
In order to make the generated XML file format consistent before and
after using XML library, adjust `property` tag format.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-20 10:41:19 +02:00
Thomas Haller c34e36bb8d
Revert "Rewrite ./tools/generate-docs-nm-property-infos.py with XML library"
This breaks build on RHEL7, probably due to an older python version.
Revert for now.

This reverts commit a83fb33840.
2021-05-18 16:00:25 +02:00
Wen Liang a83fb33840
Rewrite ./tools/generate-docs-nm-property-infos.py with XML library
Instead of writing XML text word by word, it is less error prone to
write with XML library.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang 403d776730
Remove unnecessary escaping for single quote
When writing XML text with XML library, single quote will not be
escaped. So remove the escaping for single quote in current tool.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang f6e52708a2
Add paired property tag to nm-property-infos-*.xml
In order to make the generated XML file format consistent before and
after using XML library, replace self-closing `property` tag with
paired `property` tag.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang 90422ddd1a
Remove line breaks in attribute value of nm-property-infos-*.xml
Since line breaks are not needed for XML's attribute tag, remove the
unnecessary line breaks.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Thomas Haller b6a195cf81
tools: remove deprecated PropertiesChanged signal in "test-networkmanager-service.py" 2021-05-14 10:57:35 +02:00
Wen Liang 86dcb31ab3
build: replace ./tools/generate-docs-nm-property-infos.pl with python script
In order to have more structured settings in man page and make it more
manageable to generate the docbook, it is recommended to use python
script to replace `./tools/generate-docs-nm-property-infos.pl` (this
tool is used to parse the comment section starting with `---nmcli---`,
`---dbus---`, `---keyfile---`, `---ifcfg-rh---`).

Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/824
2021-05-05 15:28:17 +02:00
orbea 68913466af
tools: use libtool --mode=execute
Better fix for https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732

The original issue was that when compiling NetworkManager with slibtool
the create-exports-NetworkManager.sh script gave the NetworkManager-all-sym
slibtool wrapper script to nm(1) instead of the actual binary. This is
because slibtool and GNU libtool do not place the compiled programs in
the same location. The original fix was to test both locations, but this
is bit of a hack especially since the build system should not be using the
.libs directory directly. However with $(LIBTOOL) --mode=execute this is
not a problem since both implementations can figure out where the correct
binary is.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/805
2021-04-04 09:27:35 +02:00
Thomas Haller d8dd6e94e6
tui: move from "clients/tui/" to "src/nmtui/" 2021-03-15 17:10:54 +01:00
Thomas Haller 61f99307c6
cli: move from "clients/cli/" to "src/nmcli/" 2021-03-15 17:10:54 +01:00
Thomas Haller 7767aaaee2
build: move "clients/nm-online.c" to "src/nm-online/" 2021-03-02 08:38:26 +01:00
Thomas Haller 54976f23cd
build: move "clients/common/" to "src/libnmc-{base,setting}/" 2021-03-02 08:38:25 +01:00
Thomas Haller 9bba4871f3
build: move "libnm/" to "src/" and split it
Like with "libnm-core/", split "libnm/" into different directories for
the public headers, for the implementation and for the helper "aux"
library.
2021-02-24 12:48:37 +01:00
Thomas Haller 4d12a6ac3d
build: move "shared/nm-{base,udev-aux}" to "src/libnm-{base,udev-aux}" 2021-02-24 12:48:19 +01:00
Thomas Haller fdf9614ba7
build: move "libnm-core/" to "src/" and split it
"libnm-core/" is rather complicated. It provides a static library that
is linked into libnm.so and NetworkManager. It also contains public
headers (like "nm-setting.h") which are part of public libnm API.

Then we have helper libraries ("libnm-core/nm-libnm-core-*/") which
only rely on public API of libnm-core, but are themself static
libraries that can be used by anybody who uses libnm-core. And
"libnm-core/nm-libnm-core-intern" is used by libnm-core itself.

Move "libnm-core/" to "src/". But also split it in different
directories so that they have a clearer purpose.

The goal is to have a flat directory hierarchy. The "src/libnm-core*/"
directories correspond to the different modules (static libraries and set
of headers that we have). We have different kinds of such modules because
of how we combine various code together. The directory layout now reflects
this.
2021-02-18 19:46:51 +01:00
Thomas Haller b13a2b27e9
all: move shared/nm-meta-setting.[hc] to libnm-core and clients
"shared/nm-meta-setting.[hc]" contains meta data about settings.
As such it is similarly used by libnm-core (as internal API) and
by clients (as extension of public API of libnm). However, it must
be compiled twice, because while it defines in both cases a
NMMetaSettingInfo type, these types are different between internal and
public API.
Hence, the files must also be compiled twice (and differently), once
against libnm-core and once against the client helper library.

Previously, the file was under "shared/", but there it's a bit odd
it doesn't clearly belong anywhere.

There are two goals here:

 - copy the file to the two places where it is used. We also have
   a "check-tree" unit test that ensures those files don't diverge in
   the future.

 - we no longer require CFLAGS set during built. Instead, the sources
   should control the build. For that we have new (simple) headers
   "nm-meta-setting-base.h" that define the right behavior for the
   impl files.

There is still an ugliness (among several): the files must be named the
same for libnm-core and clients/common. Preferably, all our sources have
unique names, but that is not possible with this scheme (without
introducing other ugliness). To mitigate that, include the files only at
one exact place.
2021-02-09 12:38:19 +01:00
Thomas Haller 83a97f887b
tests: add "tools/check-tree.sh" script for checking consistency of sources
Our source tree also has certain consistency requirements. Since the
source is in git, this is a rather static check. However, we want to
ensure that future changes don't break it by adding a test.
2021-02-09 12:38:18 +01:00
Thomas Haller ac1a9e03e4
all: move "src/" directory to "src/core/"
Currently "src/" mostly contains the source code of the daemon.
I say mostly, because that is not true, there are also the device,
settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp
helper, and probably more.

Also we have source code under libnm-core/, libnm/, clients/, and
shared/ directories. That is all confusing.

We should have one "src" directory, that contains subdirectories. Those
subdirectories should contain individual parts (libraries or
applications), that possibly have dependencies on other subdirectories.
There should be a flat hierarchy of directories under src/, which
contains individual modules.

As the name "src/" is already taken, that prevents any sensible
restructuring of the code.

As a first step, move "src/" to "src/core/". This gives space to
reorganize the code better by moving individual components into "src/".

For inspiration, look at systemd's "src/" directory.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
2021-02-04 09:45:55 +01:00
Thomas Haller 81369ac83c
libnm/docs: hook up new nm-keyfile API in libnm documentation (fix)
Fixes: 25d64c861c ('libnm/docs: hook up new nm-keyfile API in libnm documentation')
2021-02-02 16:14:04 +01:00
Frederic Martinsons 38331fc02c
tests: add a dbus test function to change delay of active connection state change
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/740
2021-02-02 10:42:33 +01:00
Thomas Haller 484b699c78
tools/tests: add usage to "tools/run-nm-test.sh"
Also support specifying the test name after "--".
2021-01-29 08:43:11 +01:00
orbea e643662348
tools: find the NetworkManager-all-sym binary location
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732
2021-01-26 19:34:00 +01:00
Thomas Haller 462668b0c3
tools: fix parameters to "tools/run-nm-test.sh" in mixed order
Fixes: 608b5f0515 ('tools: parse parameters to "tools/run-nm-test.sh" in mixed order')
2021-01-22 13:15:27 +01:00
Thomas Haller 608b5f0515
tools: parse parameters to "tools/run-nm-test.sh" in mixed order
When "tools/run-nm-test.sh" is called from the build scripts,
it has as first argument "--called-from-make". Then all arguments
must follow in a well defined order, which autotools/meson understand
and follow.

Another main use is however to call "tools/run-nm-test.sh" form the command
line. In that case, we want to have the command line parsing convenient.

Some of the parameters to the script are interpreted by the script, and
some are passed on to the test. The user can use "--" to separate the
parameters:

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -- -p /general/test_strv_cmp

Otherwise, on the first unknown argument "tools/run-nm-test.sh" would
assume all following arguments are for the test. So this worked too:

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -p /general/test_strv_cmp

However, if you now want to run the test with valgrind, you need to edit
the command line before the test arguments, like

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -v -p /general/test_strv_cmp

That is inconvenient because I call the script from the shell history and
the cursor is at the end of the line. Instead, assume that all unknown parameters
are for the test (until "--" is encountered).

Now this works:

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -p /general/test_strv_cmp -v

Arguably, now also

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -p -v /general/test_strv_cmp

works, which is a bid odd.
2021-01-22 12:13:33 +01:00
Thomas Haller 977ea352a0
all: update deprecated SPDX license identifiers
These SPDX license identifiers are deprecated ([1]). Update them.

[1] https://spdx.org/licenses/

  sed \
     -e '1 s%^/\* SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+ \*/$%/* SPDX-License-Identifier: \1-or-later */%' \
     -e '1,2 s%^\(--\|#\|//\) SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+$%\1 SPDX-License-Identifier: \2-or-later%' \
     -i \
     $(git grep -l SPDX-License-Identifier -- \
         ':(exclude)shared/c-*/' \
         ':(exclude)shared/n-*/' \
         ':(exclude)shared/systemd/src' \
         ':(exclude)src/systemd/src')
2021-01-05 09:46:21 +01:00
Thomas Haller d07cd5dbf2
all: avoid GNU "which" from shell scripts
"which" is a separate package and may not be installed.
Also, shell has a built-in command for the same purpose.
Use that.
2020-12-11 16:42:23 +01:00
Thomas Haller b9d4026f85
tools: improve detection of "ci-fairy" command in "tools/check-gitlab-ci.sh"
The previous implementation would print

    ./tools/check-gitlab-ci.sh: line 22: ci-fairy: command not found

also, it's not nice to execute the program, just to find out whether
we have it.
2020-12-11 16:08:47 +01:00
Thomas Haller 76f3cf41ac
tests: allow to skip check-local-gitlab-ci via "$NMTST_SKIP_CHECK_GITLAB_CI"
This will be used on our gitlab-ci tests. We do have a separate,
dedicated test on gitlab-ci for checking that "gitlab-ci.yml" is
correct.

We may intentionally want to violate that condition, but then our
`make check` should not fail.

Add a way to skip that test.
2020-12-11 16:08:46 +01:00
Thomas Haller bef8166893
build: add make-check step to check and generate ".gitlab-ci.yml" 2020-11-17 13:19:14 +01:00
Thomas Haller 62411390e2
build: rename "tools/check-settings-docs.sh" to "check-compare-generated.sh"
It's a better name, because the script merely compiles files and
is not specific to "settings-docs.h".
2020-11-03 15:41:39 +01:00
Thomas Haller 82ebd73bec
build: cleanup "tools/check-settings-docs.sh" script 2020-11-03 15:41:39 +01:00
Thomas Haller 85a60f9d53
tools: fix "check-config-options.sh" for detecting multiple NM_CON_DEFAULT() on one line
If there are multiple NM_CON_DEFAULT() mentionings on the same line,
previously the script would not parse them all. Adjust, by first wrapping
the line.
2020-10-30 16:52:55 +01:00
Frederic Martinsons c8b13dc92f
Manage deactivation of active connection
Like what was done for activating an active connection, so
some state change are simulated and a dbus test method is added

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Frederic Martinsons 51dd9ed89a
Enhance device state and active connection management
Add reason for device state change.
Add dbus test method to force failure of activation, set the
device state and the active connection state.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Frederic Martinsons a3f596e273
Add basic modem device support
The modem device will have hardcoded capability which make it
compatible with GSM connection settings.
It will be seen with hardcoded ModemManager manager dbus object path
for the UDI property.
Add also a dbus test method to add the modem device.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Frederic Martinsons f225148754
Initialize correctly _dbus_error_name in BusErr classes
To be consistent with dbus.DbusException classes which do the
following in __init__:

    def __init__(self, *args, **kwargs):
        name = kwargs.pop('name', None)
        if name is not None or getattr(self, '_dbus_error_name', None) is None:
            self._dbus_error_name = name
        if kwargs:
            raise TypeError('DBusException does not take keyword arguments: %s'
                            % ', '.join(kwargs.keys()))
        Exception.__init__(self, *args)

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Frederic Martinsons 7bc01ea14c
Add dbus.Int32 support for variant parsing
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Thomas Haller 7fe76f54e3
build: fix "create-exports-NetworkManager.sh" to fail if "nm" fails
Despite `set -e`, the shell script does not fail if the command in the
here document fails. This can happen if binutils' "nm" fails.

  NM=/bin/false "./tools/create-exports-NetworkManager.sh" --called-from-build "."
2020-10-06 13:30:50 +02:00
Thomas Haller 12823f60af
format: replace tabs with spaces in sheell scripts 2020-09-29 09:19:29 +02:00
Antonio Cardace 471c5b7c1d
tools: update script for new code-style
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 15:08:42 +02:00
Thomas Haller 7141537097
l3cfg/tests: add unit test for NML3Cfg 2020-09-24 09:44:04 +02:00