summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-02-28 16:22:13 +0100
committerThomas Haller <thaller@redhat.com>2023-02-28 16:33:07 +0100
commitdd5e769f2480b29e55cd51265ec305ca784e975a (patch)
tree99ef68d0939c6809b7c738bf0b7730aa46c87c9b /tools
parente3ae3b1732964abd2e49c9a12f0b4d3064c56d10 (diff)
downloadNetworkManager-dd5e769f2480b29e55cd51265ec305ca784e975a.tar.gz
build: add test for checking consistency of "nm-autoptr.h"
Diffstat (limited to 'tools')
-rwxr-xr-xtools/check-nm-autoptr.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/check-nm-autoptr.sh b/tools/check-nm-autoptr.sh
new file mode 100755
index 0000000000..466958c89b
--- /dev/null
+++ b/tools/check-nm-autoptr.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+set -e
+
+die() {
+ printf "%s\n" "$*" >&2
+ exit 1
+}
+
+cd "$(dirname "$(readlink -f "$0")")/.." || die "cannot change to srcdir"
+
+AUTOPTR_H=./src/libnm-client-public/nm-autoptr.h
+
+for s in $( sed -n 's/^ *typedef \+struct \+.*[A-Za-z0-9_]\+ \+\(NMSetting[A-Za-z0-9_]\+\)\> *;$/\1/p' ./src/libnm-core-public/nm-core-types.h ) ; do
+ grep -q "^ *G_DEFINE_AUTOPTR_CLEANUP_FUNC *( *\\<$s\\> *, *g_object_unref *)" -- "$AUTOPTR_H" || die "didn't see setting '$s' in \"$AUTOPTR_H\""
+done
+
+for s in $( grep -h -o '\<NMDevice[A-Za-z0-9_]\+\>' ./src/libnm-client-public/nm-device-*.h | sort -u | grep -v 'Class$') ; do
+ case "$s" in
+ NMDeviceModemCapabilities| \
+ NMDeviceWifiCapabilities)
+ continue
+ ;;
+ esac
+ grep -q "^ *G_DEFINE_AUTOPTR_CLEANUP_FUNC *( *\\<$s\\> *, *g_object_unref *)" -- "$AUTOPTR_H" || die "didn't see device '$s' in \"$AUTOPTR_H\""
+done