Merge pull request #29558 from mrc0mmand/varlinkctl-tests

varlink: add a couple of tests + accompanying fixes
This commit is contained in:
Daan De Meyer
2023-10-16 09:49:42 +02:00
committed by GitHub
9 changed files with 267 additions and 15 deletions
+17 -9
View File
@@ -729,11 +729,7 @@ static int varlink_idl_subparse_struct_or_enum(
if (!token)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
if (streq(token, "#")) {
r = varlink_idl_subparse_comment(p, line, column);
if (r < 0)
return r;
} else if (streq(token, ")"))
if (streq(token, ")"))
state = STATE_DONE;
else {
field_name = TAKE_PTR(token);
@@ -986,6 +982,9 @@ int varlink_idl_parse(
assert(!symbol);
n_fields = 0;
if (!token)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
r = varlink_symbol_realloc(&symbol, n_fields);
if (r < 0)
return r;
@@ -1004,6 +1003,9 @@ int varlink_idl_parse(
case STATE_METHOD_ARROW:
assert(symbol);
if (!token)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
if (!streq(token, "->"))
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Unexpected token '%s'.", *line, *column, token);
@@ -1025,6 +1027,9 @@ int varlink_idl_parse(
assert(!symbol);
n_fields = 0;
if (!token)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
r = varlink_symbol_realloc(&symbol, n_fields);
if (r < 0)
return r;
@@ -1050,6 +1055,9 @@ int varlink_idl_parse(
assert(!symbol);
n_fields = 0;
if (!token)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
r = varlink_symbol_realloc(&symbol, n_fields);
if (r < 0)
return r;
@@ -1178,13 +1186,13 @@ bool varlink_idl_interface_name_is_valid(const char *name) {
return true;
}
static int varlink_idl_symbol_consistent(const VarlinkInterface *interface, const VarlinkSymbol *symbol, bool level);
static int varlink_idl_symbol_consistent(const VarlinkInterface *interface, const VarlinkSymbol *symbol, int level);
static int varlink_idl_field_consistent(
const VarlinkInterface *interface,
const VarlinkSymbol *symbol,
const VarlinkField *field,
bool level) {
int level) {
const char *symbol_name;
int r;
@@ -1276,7 +1284,7 @@ static bool varlink_symbol_is_empty(const VarlinkSymbol *symbol) {
static int varlink_idl_symbol_consistent(
const VarlinkInterface *interface,
const VarlinkSymbol *symbol,
bool level) {
int level) {
_cleanup_(set_freep) Set *input_set = NULL, *output_set = NULL;
const char *symbol_name;
@@ -1313,7 +1321,7 @@ static int varlink_idl_symbol_consistent(
return 0;
}
int varlink_idl_consistent(const VarlinkInterface *interface, bool level) {
int varlink_idl_consistent(const VarlinkInterface *interface, int level) {
_cleanup_(set_freep) Set *name_set = NULL;
int r;
+1 -1
View File
@@ -148,7 +148,7 @@ bool varlink_idl_field_name_is_valid(const char *name);
bool varlink_idl_symbol_name_is_valid(const char *name);
bool varlink_idl_interface_name_is_valid(const char *name);
int varlink_idl_consistent(const VarlinkInterface *interface, bool level);
int varlink_idl_consistent(const VarlinkInterface *interface, int level);
const VarlinkSymbol* varlink_idl_find_symbol(const VarlinkInterface *interface, VarlinkSymbolType type, const char *name);
const VarlinkField* varlink_idl_find_field(const VarlinkSymbol *symbol, const char *name);