build: check that the list of supported config options is up to date

Add a script run during 'make check' to verify that all config options
are in the list of supported ones.
This commit is contained in:
Beniamino Galvani 2018-11-09 18:08:45 +01:00
parent 32f4abe90b
commit 2e45d4ada6
5 changed files with 48 additions and 2 deletions

View file

@ -1486,6 +1486,11 @@ noinst_LTLIBRARIES += \
src/libNetworkManager.la \
src/libsystemd-nm.la
check-config-options:
$(srcdir)/tools/check-config-options.sh "$(srcdir)"
check_local += check-config-options
###############################################################################
src_libsystemd_nm_la_cppflags = \
@ -5158,6 +5163,7 @@ EXTRA_DIST += \
shared/nm-version-macros.h.in \
shared/meson.build \
\
tools/check-config-options.sh \
tools/check-docs.sh \
tools/check-exports.sh \
tools/create-exports-NetworkManager.sh \

View file

@ -309,3 +309,9 @@ if enable_tests
env: ['LD_BIND_NOW=1', 'LD_PRELOAD=' + plugin.full_path()])
endforeach
endif
test(
'check-config-options',
find_program(join_paths(meson.source_root(), 'tools', 'check-config-options.sh')),
args: [meson.source_root()]
)

View file

@ -743,6 +743,9 @@ typedef struct {
bool is_connection:1;
} ConfigGroup;
/* The following comment is used by check-config-options.sh, don't remove it. */
/* START OPTION LIST */
static const ConfigGroup config_groups[] = {
{
.group = NM_CONFIG_KEYFILE_GROUP_MAIN,
@ -837,6 +840,9 @@ static const ConfigGroup config_groups[] = {
{ } /* sentinel */
};
/* The following comment is used by check-config-options.sh, don't remove it. */
/* END OPTION LIST */
static gboolean
check_config_key (const char *group, const char *key)
{

View file

@ -105,8 +105,8 @@
#define NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE "match-device"
#define NM_CONFIG_KEYFILE_KEY_STOP_MATCH "stop-match"
#define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was"
#define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE "enable"
#define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was" /* check-config-options skip */
#define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE "enable" /* check-config-options skip */
#define NM_CONFIG_KEYFILE_KEYPREFIX_WAS ".was."
#define NM_CONFIG_KEYFILE_KEYPREFIX_SET ".set."

28
tools/check-config-options.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
srcdir=${1:-.}
get_supported_options()
{
awk '/START OPTION LIST/{flag=1;next}/END OPTION LIST/{flag=0}flag' "$srcdir/src/nm-config.c" |
grep -o 'NM_CONFIG_KEYFILE_KEY_\w*'
}
get_missing()
{
grep -v '/\* check-config-options skip \*/' "$srcdir/src/nm-config.h" |
grep -o 'NM_CONFIG_KEYFILE_KEY_\w*' |
grep -v -Fx -f <(get_supported_options)
}
missing=$(get_missing)
if [ -n "$missing" ]; then
echo "***"
echo "*** Error: the following configuration options are defined but not present in the list of supported options"
echo "***"
echo "$missing"
exit 1
fi
exit 0