From 06f06dbf0c62d9b347eca0ab6bcdaa1c49581771 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Oct 2018 15:37:32 +0200 Subject: [PATCH 1/6] platform/tests: don't compare dangling pointer in "test-nmp-object.c" This wouldn't even dereference the dangling pointer, but merely comparing it for pointer equality. Still, it's actually undefined behavior. Avoid it. (cherry picked from commit cfc056560461c9444177c3b4f333e395c2cab5df) --- src/platform/tests/test-nmp-object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/tests/test-nmp-object.c b/src/platform/tests/test-nmp-object.c index 047d7a854b..004ea2739a 100644 --- a/src/platform/tests/test-nmp-object.c +++ b/src/platform/tests/test-nmp-object.c @@ -587,7 +587,7 @@ main (int argc, char **argv) while (global.udev_devices) { udev_device_unref (global.udev_devices->data); - global.udev_devices = g_list_remove (global.udev_devices, global.udev_devices->data); + global.udev_devices = g_list_delete_link (global.udev_devices, global.udev_devices); } nm_udev_client_unref (udev_client); From 3505998ef7a3b54052e23457a7e8d042a670710c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Oct 2018 16:11:39 +0200 Subject: [PATCH 2/6] platform/tests: fix test-nmp-object when running on system without udev Fix the test, to check that the nmp-object was deleted. It is no longer visible and no longer alive. (cherry picked from commit 581be6b8d2b34dac0050988d690d83da7c44f517) --- src/platform/tests/test-nmp-object.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform/tests/test-nmp-object.c b/src/platform/tests/test-nmp-object.c index 004ea2739a..12acf4a544 100644 --- a/src/platform/tests/test-nmp-object.c +++ b/src/platform/tests/test-nmp-object.c @@ -267,10 +267,11 @@ test_cache_link (void) struct udev_device *udev_device_3 = g_list_nth_data (global.udev_devices, 0); NMPCacheOpsType ops_type; nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = NULL; + gboolean use_udev = nmtst_get_rand_int () % 2; multi_idx = nm_dedup_multi_index_new (); - cache = nmp_cache_new (multi_idx, nmtst_get_rand_int () % 2); + cache = nmp_cache_new (multi_idx, use_udev); /* if we have a link, and don't set is_in_netlink, adding it has no effect. */ objm1 = nmp_object_new (NMP_OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2); @@ -387,7 +388,8 @@ test_cache_link (void) } else { g_assert (nmp_cache_lookup_obj (cache, objm1) == NULL); g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == NULL); - g_assert (nmp_object_is_visible (obj_new)); + g_assert (!nmp_object_is_alive (obj_new)); + g_assert (!nmp_object_is_visible (obj_new)); } nmp_object_unref (objm1); nmp_object_unref (obj_old); From aca7fd801a5dc84383cef676071825d28c090d80 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 19 Oct 2018 18:48:43 +0200 Subject: [PATCH 3/6] meson: Fix platform tests All platform tests were run twice with the `linux` platform, instead of `fake` and `linux`, as expected. (cherry picked from commit e0b168d6a84141408c48126fb4f358df1222870c) --- src/meson.build | 13 ++++++++++--- src/ndisc/tests/meson.build | 6 ++---- src/platform/tests/meson.build | 26 ++++++++++++-------------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/meson.build b/src/meson.build index 87c576714d..28fcfa8f5c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -214,9 +214,6 @@ if enable_tests test_cflags += ['-DREQUIRE_ROOT_TESTS=1'] endif - platform = (host_machine.system().contains('linux') ? 'linux' : 'fake') - test_cflags_platform = '-DSETUP=nm_' + platform + '_platform_setup' - libnetwork_manager_test = static_library( nm_name + 'Test', sources: sources, @@ -231,6 +228,16 @@ if enable_tests link_with: libnetwork_manager_test ) + test_nm_dep_fake = declare_dependency( + dependencies: test_nm_dep, + compile_args: ['-DSETUP=nm_fake_platform_setup'] + ) + + test_nm_dep_linux = declare_dependency( + dependencies: test_nm_dep, + compile_args: ['-DSETUP=nm_linux_platform_setup'] + ) + subdir('dnsmasq/tests') subdir('ndisc/tests') subdir('platform/tests') diff --git a/src/ndisc/tests/meson.build b/src/ndisc/tests/meson.build index 2f479c2d9f..e0dc9aa6cb 100644 --- a/src/ndisc/tests/meson.build +++ b/src/ndisc/tests/meson.build @@ -3,8 +3,7 @@ test_unit = 'test-ndisc-fake' exe = executable( test_unit, test_unit + '.c', - dependencies: test_nm_dep, - c_args: test_cflags_platform + dependencies: test_nm_dep_fake, ) test( @@ -18,6 +17,5 @@ test = 'test-ndisc-linux' exe = executable( test, test + '.c', - dependencies: test_nm_dep, - c_args: test_cflags_platform + dependencies: test_nm_dep_linux, ) diff --git a/src/platform/tests/meson.build b/src/platform/tests/meson.build index 0571efacff..67582d7766 100644 --- a/src/platform/tests/meson.build +++ b/src/platform/tests/meson.build @@ -1,28 +1,27 @@ test_units = [ - ['test-link-fake', 'test-link.c', 60], - ['test-link-linux', 'test-link.c', 60], - ['test-address-fake', 'test-address.c'], - ['test-address-linux', 'test-address.c'], - ['test-general', 'test-general.c'], - ['test-nmp-object', 'test-nmp-object.c'], - ['test-route-fake', 'test-route.c'], - ['test-route-linux', 'test-route.c'], - ['test-cleanup-fake', 'test-cleanup.c'], - ['test-cleanup-linux', 'test-cleanup.c'], + ['test-link-fake', 'test-link.c', test_nm_dep_fake, 30], + ['test-link-linux', 'test-link.c', test_nm_dep_linux, 90], + ['test-address-fake', 'test-address.c', test_nm_dep_fake, 30], + ['test-address-linux', 'test-address.c', test_nm_dep_linux, 30], + ['test-general', 'test-general.c', test_nm_dep, 30], + ['test-nmp-object', 'test-nmp-object.c', test_nm_dep, 30], + ['test-route-fake', 'test-route.c', test_nm_dep_fake, 30], + ['test-route-linux', 'test-route.c', test_nm_dep_linux, 30], + ['test-cleanup-fake', 'test-cleanup.c', test_nm_dep_fake, 30], + ['test-cleanup-linux', 'test-cleanup.c', test_nm_dep_linux, 30], ] foreach test_unit: test_units exe = executable( 'platform-' + test_unit[0], test_unit[1], - dependencies: test_nm_dep, - c_args: test_cflags_platform + dependencies: test_unit[2], ) test( 'platform/' + test_unit[0], test_script, - timeout: test_unit.length() > 2 ? test_unit[2] : 30, + timeout: test_unit[3], args: test_args + [exe.full_path()] ) endforeach @@ -33,5 +32,4 @@ executable( test, test + '.c', dependencies: test_nm_dep, - c_args: test_cflags_platform ) From 7fc7a893ed1fb02e4ebd91713df309eace73c855 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Oct 2018 16:34:06 +0200 Subject: [PATCH 4/6] contrib: make "contrib/fedora/REQUIRED_PACKAGES" executable script It will be called by .gitlab-ci.yml to install the packages. (cherry picked from commit a487d34fc4b4636496045c0f83306b37f01ec89b) --- contrib/fedora/REQUIRED_PACKAGES | 23 ++++++++++++++++++++--- contrib/fedora/rpm/README | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) mode change 100644 => 100755 contrib/fedora/REQUIRED_PACKAGES diff --git a/contrib/fedora/REQUIRED_PACKAGES b/contrib/fedora/REQUIRED_PACKAGES old mode 100644 new mode 100755 index 2efe95ce95..4a0ee4452d --- a/contrib/fedora/REQUIRED_PACKAGES +++ b/contrib/fedora/REQUIRED_PACKAGES @@ -1,3 +1,5 @@ +#!/bin/bash + # A list of packages useful/needed to build and develop # NetworkManager on Fedora and RHEL. # @@ -8,7 +10,16 @@ # Not all of these packages are strictly speaking necessary. # This is a generous list of related packages. -yum install \ +install() { + if [ "$NM_INSTALL" != "" ]; then + $NM_INSTALL "$@" + else + sudo "$(which dnf &>/dev/null && echo dnf || echo yum)" install -y "$@" + fi +} + +install \ + \ ModemManager-devel \ ModemManager-glib-devel \ audit-libs-devel \ @@ -21,6 +32,7 @@ yum install \ dbus-python \ dbus-x11 \ dhclient \ + gcc-c++ \ gettext-devel \ git \ gnutls-devel \ @@ -35,11 +47,15 @@ yum install \ libselinux-devel \ libtool \ libuuid-devel \ + make \ + meson \ newt-devel \ nss-devel \ polkit-devel \ ppp-devel \ pygobject3-base \ + python3-dbus \ + qt-devel \ readline-devel \ rpm-build \ systemd-devel \ @@ -47,5 +63,6 @@ yum install \ vala-devel \ vala-tools \ valgrind \ - wireless-tools-devel - + wireless-tools-devel \ + \ + #end diff --git a/contrib/fedora/rpm/README b/contrib/fedora/rpm/README index 8cc9c6f0a0..7982a1ef5b 100644 --- a/contrib/fedora/rpm/README +++ b/contrib/fedora/rpm/README @@ -7,7 +7,7 @@ git clone https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git cd NetworkManager git checkout $WHATEVER -sudo sh ./contrib/fedora/REQUIRED_PACKAGES +./contrib/fedora/REQUIRED_PACKAGES # From 91657c77616c40b1511dee4ad6d80e478f6233d7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 22 Oct 2018 12:21:46 +0200 Subject: [PATCH 5/6] checkpatch: add "contrib/scripts/checkpatch-feature-branch.sh" script This takes current HEAD branch, and finds all the commits what are not on master or one of the nm-1-* branches, and runs checkpatch.pl on each. The use is to run checkpatch.pl on all patches of a feature branch. (cherry picked from commit 369446eae69484010a05f61bfccd4dc6b38644ac) --- contrib/scripts/checkpatch-feature-branch.sh | 31 ++++++++++++++++++++ contrib/scripts/checkpatch.pl | 8 +++++ 2 files changed, 39 insertions(+) create mode 100755 contrib/scripts/checkpatch-feature-branch.sh diff --git a/contrib/scripts/checkpatch-feature-branch.sh b/contrib/scripts/checkpatch-feature-branch.sh new file mode 100755 index 0000000000..6741317be2 --- /dev/null +++ b/contrib/scripts/checkpatch-feature-branch.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +die() { + printf "%s\n" "$@" + exit 1 +} + +HEAD="${1:-HEAD}" + +BASE_DIR="$(dirname "$0")" + +BASE_REF="refs/remotes/origin/" + +RANGES=( $(git show-ref | sed 's#^\(.*\) '"$BASE_REF"'\(master\|nm-1-[0-9]\+\)$#\1..'"$HEAD"'#p' -n) ) + +[ "${#RANGES[@]}" != 0 ] || die "cannot detect git-ranges (HEAD is $(git rev-parse HEAD))" + +REFS=( $(git log --reverse --format='%H' "${RANGES[@]}") ) + +[ "${#REFS[@]}" != 0 ] || die "no refs detected (HEAD is $(git rev-parse HEAD))" + +SUCCESS=0 +for H in ${REFS[@]}; do + export NM_CHECKPATCH_HEADER=$'\n'">>> VALIDATE \"$(git log --oneline -n1 "$H")\"" + git format-patch -U65535 --stdout -1 "$H" | "$BASE_DIR/checkpatch.pl" + if [ $? != 0 ]; then + SUCCESS=1 + fi +done + +exit $SUCCESS diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index f06ac7fc05..20188061a0 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -70,11 +70,19 @@ sub new_file @functions_seen = (); } +my $header = $ENV{'NM_CHECKPATCH_HEADER'}; + sub complain { my $message = shift; return unless $check_line; + + if (defined($header)) { + warn "$header\n"; + undef $header; + } + warn "$filename:$line_no: $message:\n"; warn "> $line\n\n"; $seen_error = 1; From e29d62bcf56bb3d203eb4d26a031fefed3bfc2a7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 15 Oct 2018 13:17:22 +0200 Subject: [PATCH 6/6] gitlab: add .gitlab-ci.yml for gitlab CI See-also: https://docs.gitlab.com/ee/ci/yaml/ (cherry picked from commit a0a082456496aefc5fee4e24d31c171f0b7645c0) --- .gitlab-ci.yml | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000..33c95bd957 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,91 @@ +# Quick syntax check: +# python -c 'import sys, yaml; yaml.dump (yaml.load (sys.stdin), sys.stdout)' <.gitlab-ci.yml + +# If things don't seem to work, this can help: +# https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/ci/lint + +stages: + - test + - deploy + +.fedora_install: &fedora_install + before_script: + - NM_INSTALL="dnf install -y" ./contrib/fedora/REQUIRED_PACKAGES + +checkpatch: + image: fedora:28 + stage: test + script: + - dnf install -y git + - contrib/scripts/checkpatch-feature-branch.sh 2>&1 | tee checkpatch-out.txt + allow_failure: true + artifacts: + when: on_failure + paths: + - checkpatch-out.txt + +f28_build_default: + <<: *fedora_install + image: fedora:28 + stage: test + script: + - dnf install -y glibc-langpack-pl + - locale -a + - NOCONFIGURE=1 ./autogen.sh + - mkdir ./build + - cd ./build + - ../configure + --prefix="$PWD/INST" + --enable-gtk-doc=yes + --with-systemd-logind=yes + --enable-more-warnings=error + --enable-tests=yes + --with-crypto=gnutls + --with-libnm-glib=yes + --with-iwd=yes + --with-ofono=yes + --enable-teamdctl=yes + --with-dhcpcanon=yes + --with-dhcpcd=yes + --with-dhclient=yes + --with-netconfig=/bin/nowhere/netconfig + --with-resolvconf=/bin/nowhere/resolvconf + --enable-ifcfg-rh=yes + --enable-config-plugin-ibft=yes + --enable-ifupdown=yes + - make -j 6 + - make install + - NM_TEST_CLIENT_CHECK_L10N=1 make -j 6 -k check + - cd .. + - mv build/INST/share/gtk-doc/html docs-html + artifacts: + expire_in: 1 day + paths: + - docs-html + +f28_rpm_autotools_dbg: + <<: *fedora_install + image: fedora:28 + stage: test + script: + - ./contrib/fedora/rpm/build_clean.sh -g -w crypto_gnutls -w debug -w iwd -w test + +f28_rpm_meson_dbg: + <<: *fedora_install + image: fedora:28 + stage: test + script: + - ./contrib/fedora/rpm/build_clean.sh -g -w crypto_gnutls -w debug -w iwd -w meson -w test + +pages: + stage: deploy + dependencies: + - f28_build_default + script: + - mv docs-html public + artifacts: + expire_in: 20 days + paths: + - public + only: + - master