From: Alan T. DeKok Date: Fri, 24 Jan 2025 21:03:20 +0000 (-0500) Subject: add and use -S require_enum_prefix=yes to unit_test_attribute X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67d9c5314c42e008fe05f0c7953dfe2af80738b7;p=thirdparty%2Ffreeradius-server.git add and use -S require_enum_prefix=yes to unit_test_attribute all of the protocols pass tests without '&'. The only things remaining are the condition and xlat tests --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index ab94fe563e6..5bd1c49db4f 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -3771,7 +3771,7 @@ int main(int argc, char *argv[]) default_log.fd = STDOUT_FILENO; default_log.print_level = false; - while ((c = getopt(argc, argv, "cd:D:F:fxMhpr:w:")) != -1) switch (c) { + while ((c = getopt(argc, argv, "cd:D:F:fxMhpr:S:w:")) != -1) switch (c) { case 'c': do_commands = true; break; @@ -3809,6 +3809,15 @@ int main(int argc, char *argv[]) allow_purify = true; break; + case 'S': + if (strcmp(optarg, "require_enum_prefix=yes") == 0) { + tmpl_require_enum_prefix = true; + break; + } + + fprintf(stderr, "Invalid option to -S\n"); + EXIT_WITH_FAILURE; + case 'w': write_filename = optarg; break; diff --git a/src/tests/unit/all.mk b/src/tests/unit/all.mk index 31e3bd369c9..f38d81dc6be 100644 --- a/src/tests/unit/all.mk +++ b/src/tests/unit/all.mk @@ -44,6 +44,8 @@ $(FILES.$(TEST)): export TZ = GMT # PROTOCOLS := $(subst $(DIR)/protocols/,,$(wildcard $(DIR)/protocols/*)) define UNIT_TEST_PROTOCOLS +$(addprefix $(OUTPUT)/,$(filter protocols/${1}/%.txt,$(FILES))): REQUIRE_ENUM_PREFIX=-S require_enum_prefix=yes + $(addprefix $(OUTPUT)/,$(filter protocols/${1}/%.txt,$(FILES))): $(wildcard $(top_srcdir)/share/dictionary/${1}/dictionary*) $(BUILD_DIR)/lib/local/libfreeradius-${1}.la $(BUILD_DIR)/lib/libfreeradius-${1}.la ifeq "${1}" "eap" @@ -82,14 +84,13 @@ $(BUILD_DIR)/tests/unit/xlat/purify.txt $(filter $(BUILD_DIR)/tests/unit/xlat/co # #REWRITE_FLAGS = -w $(BUILD_DIR)/tmp - # # And the actual script to run each test. # $(OUTPUT)/%: $(DIR)/% $(TEST_BIN_DIR)/unit_test_attribute $(eval DIR:=${top_srcdir}/src/tests/unit) @echo "UNIT-TEST $(lastword $(subst /, ,$(dir $@))) $(basename $(notdir $@))" - ${Q}if ! $(TEST_BIN)/unit_test_attribute $(PURIFY) $(REWRITE_FLAGS) -F ./src/tests/fuzzer-corpus -D ./share/dictionary -d $(DIR) -r "$@" $<; then \ + ${Q}if ! $(TEST_BIN)/unit_test_attribute $(PURIFY) $(REWRITE_FLAGS) -F ./src/tests/fuzzer-corpus -D ./share/dictionary -d $(DIR) -r "$@" $(REQUIRE_ENUM_PREFIX) $<; then \ echo "TZ=GMT $(TEST_BIN)/unit_test_attribute $(PURIFY) -F ./src/tests/fuzzer-corpus -D ./share/dictionary -d $(DIR) -r \"$@\" $<"; \ rm -f $(BUILD_DIR)/tests/test.unit; \ exit 1; \ diff --git a/src/tests/unit/protocols/radius/tag.txt b/src/tests/unit/protocols/radius/tag.txt index 22db3c448c6..7bfdee51652 100644 --- a/src/tests/unit/protocols/radius/tag.txt +++ b/src/tests/unit/protocols/radius/tag.txt @@ -11,7 +11,7 @@ match 1a 12 00 00 13 0a 41 0c 01 55 4e 50 4f 4c 49 43 45 44 decode-pair - match Tag-1 = { Vendor-Specific = { Unisphere = { Service-Activate = "UNPOLICED" } } } -pair Tag-2 = { &Vendor-Specific.Unisphere.Service-Activate = "PPPOE_SERVICE(3072000,2048000)" } +pair Tag-2 = { Vendor-Specific.Unisphere.Service-Activate = "PPPOE_SERVICE(3072000,2048000)" } match Tag-2 = { Vendor-Specific = { Unisphere = { Service-Activate = "PPPOE_SERVICE(3072000,2048000)" } } } encode-pair Tag-2 = { Vendor-Specific.Unisphere.Service-Activate = "UNPOLICED" }