From 83a97f887bf0aea97cf9056f22e17b11e50fdf2b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 7 Feb 2021 10:23:00 +0100 Subject: [PATCH] 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. --- Makefile.am | 6 ++++++ meson.build | 5 +++++ tools/check-tree.sh | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100755 tools/check-tree.sh diff --git a/Makefile.am b/Makefile.am index 8f1ef335f7..e57e32be0a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/meson.build b/meson.build index 59ff11b99a..6f1ab6282f 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/tools/check-tree.sh b/tools/check-tree.sh new file mode 100755 index 0000000000..8437c4752d --- /dev/null +++ b/tools/check-tree.sh @@ -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