From: Alan T. DeKok Date: Fri, 11 Oct 2019 14:27:40 +0000 (-0400) Subject: add "fail" command X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec41ccde6e557cdb0eba4b656f0e052071bda75f;p=thirdparty%2Ffreeradius-server.git add "fail" command for tests where we know the expected output, but which don't yet work. It's better to have known failures than results which are commented out --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 9bd18661dce..3a7f59733db 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -1281,6 +1281,26 @@ static size_t command_exit(command_result_t *result, UNUSED command_ctx_t *cc, RETURN_EXIT(atoi(in)); } +/** Compare the data buffer to an expected value + * + * Note that we fail if the string DOES match! This command is used + * as a place-holder for tests which SHOULD work in the future, but + * which do not work right no. It allows us to store the expected + * output in a test that isn't commented out. + */ +static size_t command_fail(command_result_t *result, UNUSED command_ctx_t *cc, + char *data, size_t data_used, char *in, size_t inlen) +{ + if (strcmp(in, data) == 0) RETURN_MISMATCH(in, inlen, data, data_used); + + /* + * We didn't actually write anything, but this + * keeps the contents of the data buffer around + * for the next command to operate on. + */ + RETURN_OK(data_used); +} + /** Dynamically load a protocol library * */ @@ -1541,6 +1561,11 @@ static fr_table_ptr_sorted_t commands[] = { .usage = "exit[ ]", .description = "Exit with the specified error number. If no is provided, process will exit with 0" }}, + { "fail", &(command_entry_t){ + .func = command_fail, + .usage = "fail ", + .description = "The expected output should NOT match the string" + }}, { "load ", &(command_entry_t){ .func = command_proto_load, .usage = "load ",