varlink: add enum types for configuration settings in io.systemd.Manager

Convert 8 string fields in the io.systemd.Manager varlink interface to
proper enum types:

- LogTarget: new enum (console, console_prefixed, kmsg, journal, ...)
- DefaultStandardOutput/Error: reuse ExecOutputType from common
- DefaultMemory/CPU/IOPressureWatch: reuse CGroupPressureWatch from common
- DefaultOOMPolicy: new enum (continue, stop, kill)
- CtrlAltDelBurstAction: reuse EmergencyAction from common

Output serialization updated to use JSON_BUILD_PAIR_ENUM for automatic
underscorification of dash-containing values.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ivan Kruglov
2026-04-14 02:10:52 -07:00
parent 29c00e0295
commit b5aa7635ce
5 changed files with 71 additions and 17 deletions
+3
View File
@@ -500,6 +500,9 @@ executables += [
core_test_template + {
'sources' : files('test-varlink-idl-unit.c'),
},
core_test_template + {
'sources' : files('test-varlink-idl-manager.c'),
},
test_template + {
'sources' : files('test-watchdog.c'),
'type' : 'unsafe',
+25
View File
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "cgroup.h"
#include "emergency-action.h"
#include "execute.h"
#include "log.h"
#include "tests.h"
#include "test-varlink-idl-util.h"
#include "unit.h"
#include "varlink-idl-common.h"
#include "varlink-io.systemd.Manager.h"
TEST(manager_enums_idl) {
/* ManagerContext enums */
TEST_IDL_ENUM(LogTarget, log_target, vl_type_LogTarget);
TEST_IDL_ENUM(OOMPolicy, oom_policy, vl_type_OOMPolicy);
/* ExecOutput values like "kmsg+console" contain '+' which becomes '_' via underscorify,
* but dashify won't restore it, so from_string round-trip fails. Test to_string direction only. */
TEST_IDL_ENUM_TO_STRING(ExecOutput, exec_output, vl_type_ExecOutputType);
TEST_IDL_ENUM(CGroupPressureWatch, cgroup_pressure_watch, vl_type_CGroupPressureWatch);
TEST_IDL_ENUM(EmergencyAction, emergency_action, vl_type_EmergencyAction);
}
DEFINE_TEST_MAIN(LOG_DEBUG);