Skip to content

Commit 1896217

Browse files
committed
move unit tests to run without "&"
1 parent 85d6a5a commit 1896217

File tree

18 files changed

+592
-574
lines changed

18 files changed

+592
-574
lines changed

src/bin/unit_test_attribute.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,13 @@ static size_t command_condition_normalise(command_result_t *result, command_file
15171517
talloc_free(cs);
15181518
RETURN_OK_WITH_ERROR();
15191519
}
1520-
len = xlat_print(&FR_SBUFF_OUT(data, COMMAND_OUTPUT_MAX), head, NULL);
1520+
1521+
if ((size_t) slen < inlen) {
1522+
len = snprintf(data, COMMAND_OUTPUT_MAX, "ERROR passed in %zu, returned %zd", inlen, slen);
1523+
1524+
} else {
1525+
len = xlat_print(&FR_SBUFF_OUT(data, COMMAND_OUTPUT_MAX), head, NULL);
1526+
}
15211527

15221528
talloc_free(head);
15231529
talloc_free(cs);
@@ -3383,6 +3389,7 @@ static command_file_ctx_t *command_ctx_alloc(TALLOC_CTX *ctx,
33833389

33843390
cc->tmpl_rules.attr.list_def = request_attr_request;
33853391
cc->tmpl_rules.attr.namespace = fr_dict_root(cc->config->dict);
3392+
cc->tmpl_rules.attr.allow_unresolved = false; /* tests have to use real attributes */
33863393

33873394
return cc;
33883395
}

src/lib/server/tmpl_tokenize.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,7 +3151,7 @@ static ssize_t tmpl_afrom_enum(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in,
31513151
break;
31523152

31533153
default:
3154-
fr_strerror_const("Unexpected text after enum value. Expected operator");
3154+
fr_strerror_const("Unexpected text after enum value.");
31553155
break;
31563156
}
31573157

@@ -3384,10 +3384,16 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
33843384

33853385
/*
33863386
* We can't parse it as anything, that's an error.
3387+
*
3388+
* But it may be an enumeration value for an
3389+
* attribute which is loaded later. In which
3390+
* case we allow parsing the enumeration.
33873391
*/
33883392
if (tmpl_require_enum_prefix) {
33893393
if (!fr_sbuff_is_str_literal(&our_in, "::")) {
3390-
fr_strerror_const("Failed parsing input");
3394+
/*
3395+
* Return the error string from parsing the attribute!
3396+
*/
33913397
FR_SBUFF_ERROR_RETURN(&our_in);
33923398
}
33933399
}
@@ -3419,7 +3425,7 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
34193425
break;
34203426

34213427
default:
3422-
fr_strerror_const("Unexpected text after enum value. Expected operator");
3428+
fr_strerror_const("Unexpected text after enum value.");
34233429
break;
34243430
}
34253431

src/lib/unlang/xlat_tokenize.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,22 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t
11221122
}
11231123

11241124
if (tmpl_is_data(node->vpt)) {
1125+
/*
1126+
* @todo - until such time as the value
1127+
* box functions print "::" before enum
1128+
* names.
1129+
*
1130+
* Arguably it should _always_ print the
1131+
* "::" before enum names, even if the
1132+
* input didn't have "::". But that's
1133+
* addressed when the prefix is required,
1134+
* OR when the value-box functions are
1135+
* updated.
1136+
*/
1137+
if (tmpl_require_enum_prefix && node->vpt->data.literal.enumv &&
1138+
(strncmp(node->fmt, "::", 2) == 0)) {
1139+
FR_SBUFF_IN_STRCPY_LITERAL_RETURN(out, "::");
1140+
}
11251141
FR_SBUFF_RETURN(fr_value_box_print_quoted, out, tmpl_value(node->vpt), node->vpt->quote);
11261142
goto done;
11271143
}

src/tests/unit/all.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ $(BUILD_DIR)/tests/unit/xlat/purify.txt $(filter $(BUILD_DIR)/tests/unit/xlat/co
8282
# with the "actual" output. But only for the "match" command. Everything is including comments and blank
8383
# lines is copied verbatim.
8484
#
85+
REQUIRE_ENUM_PREFIX=-S require_enum_prefix=yes
8586

8687
#REWRITE_FLAGS = -w $(BUILD_DIR)/tmp
8788
#

0 commit comments

Comments
 (0)