From: Alan T. DeKok Date: Wed, 16 Nov 2022 18:44:20 +0000 (-0500) Subject: run some edits under the new regime X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f4d92e32596e39dea0b027e0f88f72ec075ac63;p=thirdparty%2Ffreeradius-server.git run some edits under the new regime The behavior which isn't yet converted is: * giving "update list { ... }" and then a *different* list for an attribute inside of the update section. The new code doesn't like this, for good reason. * assigning &request += &control[*] the new code doesn't expect to see the [*], and therefore just ignores the assignment. * creating empty attributes if the RHS of an evaluate fails. The new code does nothing. * using array indexes in LHS of assignment for sub-list, update foo { bar[1] = baz}. The new code doesn't allow it. * some compile-time errors are produced at different locations --- diff --git a/src/tests/keywords/all.mk b/src/tests/keywords/all.mk index f93fb9c9c05..d04b5f96340 100644 --- a/src/tests/keywords/all.mk +++ b/src/tests/keywords/all.mk @@ -39,19 +39,26 @@ test.keywords.${1}: $(addprefix $(OUTPUT)/,${1}) test.keywords.help: TEST_KEYWORDS_HELP += test.keywords.${1} +# +# All of the "update" tests which should also be run with "-S rewrite_update=yes" +# +KEYWORD_UPDATE_TESTS := update-attr-ref-null update-error-3 update-group-error update-filter update-list-error update-list-null-rhs update-null-value-assign update-remove-index update-exec + +KEYWORD_UPDATE_REWRITE_TESTS := update-all update-array update-delete update-remove-any update-group update-hex update-remove-value update-index update-remove-list update-prepend unknown-update update-error update-error-2 update-exec-error + # # Migration support. Some of the tests don't run under the new # conditions, so we don't run them under the new conditions. # ifneq "$(findstring ${1}, paircmp)" "" $(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=no -S use_new_conditions=no -else -ifneq "$(findstring ${1}, comments update-to-edit if-regex-multivalue smash wimax unknown unknown-update update-all update-array update-attr-ref-null update-delete update-error-2 update-error-3 update-remove-any update-exec update-exec-error update-filter update-group update-group-error update-hex update-remove-value update-remove-index update-index update-list-error update-list-null-rhs update-null-value-assign update-prepend update-remove-list vendor_specific vendor_specific.raw xlat-unknown)" "" +else ifneq "$(findstring ${1}, comments update-to-edit if-regex-multivalue smash wimax unknown $(KEYWORD_UPDATE_TESTS) vendor_specific vendor_specific.raw xlat-unknown)" "" $(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=yes -S use_new_conditions=yes +else ifneq "$(findstring ${1}, $(KEYWORD_UPDATE_REWRITE_TESTS))" "" +$(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=yes -S use_new_conditions=yes -S rewrite_update=yes else $(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=yes -S use_new_conditions=yes -S forbid_update=yes endif -endif endef $(foreach x,$(FILES),$(eval $(call KEYWORD_TEST,$x))) diff --git a/src/tests/keywords/update-to-edit b/src/tests/keywords/update-to-edit new file mode 100644 index 00000000000..851f431c9bd --- /dev/null +++ b/src/tests/keywords/update-to-edit @@ -0,0 +1,52 @@ +&Tmp-String-0 := "foo" + +update request { + &Tmp-String-0 !* ANY +} + +if (&Tmp-String-0) { + test_fail +} + +&Tmp-String-0 := "foo" +&reply.Tmp-String-0 := "bar" + +update { + &request.Tmp-String-0 !* ANY + &reply !* ANY +} + +if (&Tmp-String-0) { + test_fail +} + +if (&reply.Tmp-String-0) { + test_fail +} + +update reply { + &Tmp-Integer-0 := 12 +} + +if (!&reply.Tmp-Integer-0) { + test_fail +} + +update reply { + &Tmp-Integer-0 += 13 +} + +if (&reply.Tmp-Integer-0[0] != 12) { + test_fail +} + +if (&reply.Tmp-Integer-0[1] != 13) { + test_fail +} + +# +# Clear out reply as we don't care about the attributes in it. +# +&reply := {} + +success