varlink-idl: add infra to test our enum parsers against varlink IDL enums

In many cases we want to expose enums for which we have the usual
xyz_to_string()/xyz_from_string() via Varlink as enums. Let's add some
infra to test the tables against each other, to automatically detect
when they deviate.

In order to implement this properly, let's export/introduce clean
json_underscorefy()/json_dashify(), for dealing with the fact that our
enums usually use dash separates ames, but Varlink doesn't allow that.

(This does not add the test cases for all enum types we expose right
now, but only adds the general infra).
This commit is contained in:
Lennart Poettering
2025-11-04 11:46:17 +00:00
committed by Luca Boccassi
parent 79dd24cf14
commit 030f239a19
7 changed files with 86 additions and 8 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
#include "varlink-io.systemd.BootControl.h"
static SD_VARLINK_DEFINE_ENUM_TYPE(
SD_VARLINK_DEFINE_ENUM_TYPE(
BootEntryType,
SD_VARLINK_FIELD_COMMENT("Boot Loader Specification Type #1 entries (.conf files)"),
SD_VARLINK_DEFINE_ENUM_VALUE(type1),
@@ -13,7 +13,7 @@ static SD_VARLINK_DEFINE_ENUM_TYPE(
SD_VARLINK_FIELD_COMMENT("Automatically generated entries"),
SD_VARLINK_DEFINE_ENUM_VALUE(auto));
static SD_VARLINK_DEFINE_ENUM_TYPE(
SD_VARLINK_DEFINE_ENUM_TYPE(
BootEntrySource,
SD_VARLINK_FIELD_COMMENT("Boot entry found in EFI system partition (ESP)"),
SD_VARLINK_DEFINE_ENUM_VALUE(esp),
@@ -3,4 +3,7 @@
#include "sd-varlink-idl.h"
extern const sd_varlink_symbol vl_type_BootEntryType;
extern const sd_varlink_symbol vl_type_BootEntrySource;
extern const sd_varlink_interface vl_interface_io_systemd_BootControl;
@@ -3,7 +3,7 @@
#include "bus-polkit.h"
#include "varlink-io.systemd.MountFileSystem.h"
static SD_VARLINK_DEFINE_ENUM_TYPE(
SD_VARLINK_DEFINE_ENUM_TYPE(
PartitionDesignator,
SD_VARLINK_DEFINE_ENUM_VALUE(root),
SD_VARLINK_DEFINE_ENUM_VALUE(usr),
@@ -3,4 +3,6 @@
#include "sd-varlink-idl.h"
extern const sd_varlink_symbol vl_type_PartitionDesignator;
extern const sd_varlink_interface vl_interface_io_systemd_MountFileSystem;