Commit 2e45d4ad authored by Beniamino Galvani's avatar Beniamino Galvani

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.
parent 32f4abe9
......@@ -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 \
......
......@@ -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()]
)
......@@ -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)
{
......
......@@ -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."
......
#!/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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment