Skip to content

Commit

Permalink
add "fail" command
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alandekok committed Oct 11, 2019
1 parent 4ee9369 commit ec41ccd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/bin/unit_test_attribute.c
Expand Up @@ -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
*
*/
Expand Down Expand Up @@ -1541,6 +1561,11 @@ static fr_table_ptr_sorted_t commands[] = {
.usage = "exit[ <num>]",
.description = "Exit with the specified error number. If no <num> is provided, process will exit with 0"
}},
{ "fail", &(command_entry_t){
.func = command_fail,
.usage = "fail <string>",
.description = "The expected output should NOT match the string"
}},
{ "load ", &(command_entry_t){
.func = command_proto_load,
.usage = "load <protocol>",
Expand Down

0 comments on commit ec41ccd

Please sign in to comment.