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.
This commit is contained in:
Thomas Haller 2021-02-07 10:23:00 +01:00
parent fa3ac35031
commit 83a97f887b
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 33 additions and 0 deletions

View file

@ -5435,6 +5435,7 @@ EXTRA_DIST += \
tools/check-exports.sh \
tools/check-compare-generated.sh \
tools/check-gitlab-ci.sh \
tools/check-tree.sh \
tools/create-exports-NetworkManager.sh \
tools/debug-helper.py \
tools/meson-post-install.sh \
@ -5470,6 +5471,11 @@ endif
###############################################################################
check-tree:
"$(top_srcdir)/tools/check-tree.sh"
check_local += check-tree
check-po-msgfmt:
@echo "check-po-msgfmt: check $(top_srcdir)/po/*.po files with msgfmt -vc"
@for f in "$(top_srcdir)/po"/*.po ; do \

View file

@ -809,6 +809,11 @@ test(
args: [source_root],
)
test(
'check-tree',
find_program(join_paths(source_root, 'tools', 'check-tree.sh')),
)
# Tests, utilities and documentation
tests = get_option('tests')
enable_tests = (tests != 'no')

22
tools/check-tree.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
set -e
TOP_DIR="$(dirname "$0")/.."
die() {
printf 'FAIL: %s\n' "$*" >&2
exit 1
}
check_cmp() {
local a="$1"
local b="$2"
cmp "$TOP_DIR/$a" "$TOP_DIR/$b" && return 0
diff "$TOP_DIR/$a" "$TOP_DIR/$b" || :
die "files \"$a\" and \"$b\" differ!"
}
check_cmp shared/nm-base/nm-ethtool-utils-base.h libnm/nm-ethtool-utils.h