meson: drop the list of valid net naming schemes

We used 'combo' type for the scheme list. For a while we forgot to add
new names, and recently aa0a23ec86 added v241, v243, v245, and v247.
I want to allow defining new values during configuration, which means
that we can't use meson to verify the list of options. So any value is
allowed, but then two tests are added: one that will fail compilation if some
invalid name is given (other than "latest"), and one that converts
DEFAULT_NET_NAMING_SCHEME to a NamingScheme pointer.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-09-28 14:22:37 +02:00
parent acaa636866
commit 77faadfdd3
6 changed files with 47 additions and 4 deletions
+2
View File
@@ -429,6 +429,8 @@ tests += [
[['src/test/test-firewall-util.c']],
[['src/test/test-net-naming-scheme.c']],
[['src/test/test-netlink-manual.c'],
[],
[libkmod],
+31
View File
@@ -0,0 +1,31 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "netif-naming-scheme.h"
#include "string-util.h"
#include "tests.h"
static void test_default_net_naming_scheme(void) {
log_info("/* %s */", __func__);
const NamingScheme *n;
assert_se(n = naming_scheme_from_name(DEFAULT_NET_NAMING_SCHEME));
log_info("default → %s", n->name);
}
static void test_naming_scheme_conversions(void) {
log_info("/* %s */", __func__);
const NamingScheme *n;
assert_se(n = naming_scheme_from_name("latest"));
log_info("latest → %s", n->name);
assert_se(n = naming_scheme_from_name("v238"));
assert_se(streq(n->name, "v238"));
}
int main(int argc, char **argv) {
test_setup_logging(LOG_INFO);
test_default_net_naming_scheme();
test_naming_scheme_conversions();
}