From: Alan T. DeKok Date: Sun, 9 Mar 2025 15:54:11 +0000 (-0400) Subject: %test() takes a string argument in the tests. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd739f763c1a2f12217e543a3ec663fe3fe147a4;p=thirdparty%2Ffreeradius-server.git %test() takes a string argument in the tests. the old function argument parser didn't complain when it was passed arguments to a function which didn't take arguments. It's better to complain. --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index ef6427f8b1..8e7e3ee0a2 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -256,6 +256,11 @@ typedef struct { char const *description; } command_entry_t; +static xlat_arg_parser_t const xlat_test_args[] = { + { .required = true, .single = true, .type = FR_TYPE_STRING }, + XLAT_ARG_PARSER_TERMINATOR +}; + static xlat_action_t xlat_test(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request, UNUSED fr_value_box_list_t *in) @@ -3745,6 +3750,7 @@ int main(int argc, char *argv[]) bool do_commands = false; bool do_usage = false; bool allow_purify = false; + xlat_t *xlat; /* * Must be called first, so the handler is called last @@ -3940,10 +3946,12 @@ int main(int argc, char *argv[]) unlang_thread_instantiate(thread_ctx); - if (!xlat_func_register(NULL, "test", xlat_test, FR_TYPE_NULL)) { + xlat = xlat_func_register(NULL, "test", xlat_test, FR_TYPE_NULL); + if (!xlat) { ERROR("Failed registering xlat"); EXIT_WITH_FAILURE; } + xlat_func_args_set(xlat, xlat_test_args); /* * Disable hostname lookups, so we don't produce spurious DNS