From: Alan T. DeKok Date: Sun, 9 Mar 2025 19:54:45 +0000 (-0400) Subject: move keyword tests to new xlat argument parser X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a927a04b1656d55b91a868226bd6899a6140b85e;p=thirdparty%2Ffreeradius-server.git move keyword tests to new xlat argument parser with a bit of good fortune, not all tests had to be updated. However, there are still many tests which do unnecessary expansions, ala %foo(%{User-Name} which is no longer necessary. It may be useful to forbid that, or to at least print an error message complaining about it. --- diff --git a/src/tests/keywords/all.mk b/src/tests/keywords/all.mk index 0fdf8d618d..78b64ac988 100644 --- a/src/tests/keywords/all.mk +++ b/src/tests/keywords/all.mk @@ -86,6 +86,11 @@ $(OUTPUT)/${1}: $(BUILD_DIR)/lib/local/libfreeradius-dhcpv4.la $(BUILD_DIR)/lib/ endif endif +# +# Always use the new xlat parser +# +$(OUTPUT)/${1}: NEW_COND += -S xlat_func_bare_words=no + endef $(foreach x,$(FILES),$(eval $(call KEYWORD_TEST,$x))) @@ -152,7 +157,7 @@ KEYWORD_LIBS := $(addsuffix .la,$(addprefix rlm_,$(KEYWORD_MODULES))) rlm_csv.la # (make -k test.keywords 2>&1) | grep 'KEYWORD=' | sed 's/KEYWORD=//;s/ .*$//' # $(OUTPUT)/%: $(DIR)/% $(TEST_BIN_DIR)/unit_test_module | $(KEYWORD_RADDB) $(KEYWORD_LIBS) build.raddb rlm_test.la rlm_csv.la rlm_unpack.la - $(eval CMD:=KEYWORD=$(notdir $@) $(TEST_BIN)/unit_test_module $(NEW_COND) -S xlat_func_bare_words=yes $(UNIT_TEST_KEYWORD_ARGS.$(subst -,_,$(notdir $@))) -D share/dictionary -d src/tests/keywords/ -i "$@.attrs" -f "$@.attrs" -r "$@" -xx ) + $(eval CMD:=KEYWORD=$(notdir $@) $(TEST_BIN)/unit_test_module $(NEW_COND) $(UNIT_TEST_KEYWORD_ARGS.$(subst -,_,$(notdir $@))) -D share/dictionary -d src/tests/keywords/ -i "$@.attrs" -f "$@.attrs" -r "$@" -xx ) @echo "KEYWORD-TEST $(notdir $@)" ${Q}if ! $(CMD) > "$@.log" 2>&1 || ! test -f "$@"; then \ if ! grep ERROR $< 2>&1 > /dev/null; then \ diff --git a/src/tests/keywords/attr-index-eval b/src/tests/keywords/attr-index-eval index c2ddf4ed20..d79f7076d7 100644 --- a/src/tests/keywords/attr-index-eval +++ b/src/tests/keywords/attr-index-eval @@ -8,12 +8,12 @@ index := 1 # # Dynamically create an attribute reference # -ref = "&Filter-Id[" + (string) index + "]" +ref = "Filter-Id[" + (string) index + "]" # -# Evaluate the attribute as an unlang expression. +# Evaluate the contents of the attribute as an unlang expression. # -foo = %eval(%{ref}) +foo = %eval(ref) if (foo != "b") { test_fail @@ -21,7 +21,7 @@ if (foo != "b") { ref = "1 + 2" -foo = %eval(%{ref}) +foo = %eval(ref) if (foo != 3) { test_fail diff --git a/src/tests/keywords/base64 b/src/tests/keywords/base64 index 673ffd5bf8..8b06f89891 100644 --- a/src/tests/keywords/base64 +++ b/src/tests/keywords/base64 @@ -29,73 +29,73 @@ test_int64 = 1152921505566832445 test_ipv4prefix = 57.56.55.62/32 # String - bin 0x39383730 -test_output := %base64.encode(%{test_string}) +test_output := %base64.encode(test_string) if (!(test_output == 'OTg3MA==')) { test_fail } # Octets - bin 0x39383731 -test_output := %base64.encode(%{test_octets}) +test_output := %base64.encode(test_octets) if (!(test_output == 'OTg3MQ==')) { test_fail } # IP Address - bin 0x39383732 -test_output := %base64.encode(%{test_ipaddr}) +test_output := %base64.encode(test_ipaddr) if (!(test_output == 'OTg3Mg==')) { test_fail } # Integer - bin 0x39383734 -test_output := %base64.encode(%{test_int}) +test_output := %base64.encode(test_int) if (!(test_output == 'OTg3NA==')) { test_fail } # ifid - bin 0x0000000039383737 -test_output := %base64.encode(%{test_ifid}) +test_output := %base64.encode(test_ifid) if (!(test_output == 'AAAAADk4Nzc=')) { test_fail } # ipv6addr - bin 0x00000000000000000000000039383738 -test_output := %base64.encode(%{test_ipv6addr}) +test_output := %base64.encode(test_ipv6addr) if (!(test_output == 'AAAAAAAAAAAAAAAAOTg3OA==')) { test_fail } # ipv6addrprefix - bin 0x008000000000000000000000000039383739 -test_output := %base64.encode(%{test_ipv6prefix}) +test_output := %base64.encode(test_ipv6prefix) if (!(test_output == 'AIAAAAAAAAAAAAAAAAA5ODc5')) { test_fail } # byte - bin 0x3a -test_output := %base64.encode(%{test_byte}) +test_output := %base64.encode(test_byte) if (!(test_output == 'Og==')) { test_fail } # short - bin 0x373b -test_output := %base64.encode(%{test_short}) +test_output := %base64.encode(test_short) if (!(test_output == 'Nzs=')) { test_fail } # ethernet - bin 0x00003938373c -test_output := %base64.encode(%{test_ether}) +test_output := %base64.encode(test_ether) if (!(test_output == 'AAA5ODc8')) { test_fail } # integer64 - bin 0x100000003938373d -test_output := %base64.encode(%{test_int64}) +test_output := %base64.encode(test_int64) if (!(test_output == 'EAAAADk4Nz0=')) { test_fail } # ipv4prefix - bin 0x203938373e -test_output := %base64.encode(%{test_ipv4prefix}) +test_output := %base64.encode(test_ipv4prefix) if (!(test_output == 'IDk4Nz4=')) { test_fail } @@ -107,25 +107,25 @@ if (!(test_output == 'IDk4Nz4=')) { #} # Regression test, this used to crash... -test_octets := %base64.decode(Zm9v) +test_octets := %base64.decode('Zm9v') if (!(test_octets == "foo")) { debug_request test_fail } -test_octets := %base64.decode(AIAAAAAAAAAAAAAAAAA5ODc5) +test_octets := %base64.decode('AIAAAAAAAAAAAAAAAAA5ODc5') if (!(test_octets == 0x008000000000000000000000000039383739)) { test_fail } # Regression tests -test_octets := %base64.decode(5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK) +test_octets := %base64.decode('5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK') if (!(test_octets == 0xe5136a365f2260b6e409cec9851f1ab384ed0c3097ea8b6eb96b5c8daf2b213532c7dceb9c749ef6d4c71a628a)) { test_fail } -test_octets := %base64.decode(eHfXPKZ+2iv9cnMV1MOmE/moYYA1Uk5xTmw4aVlMYmtDYzdKaFI4YXM0VHRERENYNm90dXVXdGNqYThySVRVeXg5enJuSFNlOXRUSEdtS0s=) +test_octets := %base64.decode('eHfXPKZ+2iv9cnMV1MOmE/moYYA1Uk5xTmw4aVlMYmtDYzdKaFI4YXM0VHRERENYNm90dXVXdGNqYThySVRVeXg5enJuSFNlOXRUSEdtS0s=') if (!(test_octets == 0x7877d73ca67eda2bfd727315d4c3a613f9a8618035524e714e6c3869594c626b4363374a685238617334547444444358366f7475755774636a6138724954557978397a726e48536539745448476d4b4b)) { test_fail diff --git a/src/tests/keywords/bin b/src/tests/keywords/bin index 02cdd07511..6bce16ea3d 100644 --- a/src/tests/keywords/bin +++ b/src/tests/keywords/bin @@ -43,7 +43,7 @@ request += { NAS-Identifier = '0x030405' } -Class := %bin(%{NAS-Identifier[*]}) +Class := %bin(NAS-Identifier[*]) if (Class[#] != 2) { test_fail diff --git a/src/tests/keywords/cast-time_delta b/src/tests/keywords/cast-time_delta index e6720cf67b..8b5a22c8a9 100644 --- a/src/tests/keywords/cast-time_delta +++ b/src/tests/keywords/cast-time_delta @@ -39,7 +39,7 @@ if (diff != 60s) { # # Cast the time delta to milliseconds # -num = %cast("ms", %{diff}) +num = %cast("ms", diff) # # This results in 60, because the conversion to fr_value_box_cast() doesn't pass dst->enumv? diff --git a/src/tests/keywords/cbor b/src/tests/keywords/cbor index 1f6a81da97..2c30e31044 100644 --- a/src/tests/keywords/cbor +++ b/src/tests/keywords/cbor @@ -1,7 +1,10 @@ octets cbor string foo -cbor = %cbor.encode(User-Name) +# +# @todo - this should be a dcursor +# +cbor = %cbor.encode('User-Name') # # 9f array of indefinite length @@ -28,7 +31,7 @@ if (User-Name) { # # @todo - change this to be configurable :( # -%cbor.decode(%{cbor}) +%cbor.decode(cbor) if (User-Name != "bob") { test_fail diff --git a/src/tests/keywords/cmp-list-empty b/src/tests/keywords/cmp-list-empty index 9fd60e946f..a00d3d3903 100644 --- a/src/tests/keywords/cmp-list-empty +++ b/src/tests/keywords/cmp-list-empty @@ -3,7 +3,7 @@ # # {} == {} --> true # -if !(%test.fail() == %test.fail()) { +if (%test.fail() != %test.fail()) { test_fail } diff --git a/src/tests/keywords/date b/src/tests/keywords/date index aee33ed521..4e433cc28a 100644 --- a/src/tests/keywords/date +++ b/src/tests/keywords/date @@ -11,7 +11,7 @@ date test_date test_integer := 1506101100 # Convert to string representation -result_string1 := %date(%{test_integer}) +result_string1 := %date(test_integer) # Some systems report GMT some UTC... if (!(result_string1 == "Fri 22 Sep 17:25:00 GMT 2017")) && (!(result_string1 == "Fri 22 Sep 17:25:00 UTC 2017")) { @@ -19,7 +19,7 @@ if (!(result_string1 == "Fri 22 Sep 17:25:00 GMT 2017")) && (!(result_string1 == } # Convert string to integer -result_integer := %date(%{result_string1}) +result_integer := %date(result_string1) if (!(result_integer == test_integer)) { @@ -27,7 +27,7 @@ if (!(result_integer == test_integer)) { } # Compare two methods of reading request timestamp in local timezone -result_string1 := %localdate(request) +result_string1 := %localdate('request') result_string2 := %S if (!(result_string1 == result_string2)) { @@ -37,7 +37,7 @@ if (!(result_string1 == result_string2)) { # Convert different string format result_string1 := "2017-09-22 17:25:00" -result_integer := %sqldate(%{result_string1}) +result_integer := %sqldate(result_string1) if (!(result_integer == test_integer)) { test_fail @@ -45,7 +45,7 @@ if (!(result_integer == test_integer)) { # Use a date attribute test_date := 1659985459 -result_string1 := %sqldate(%{test_date}) +result_string1 := %sqldate(test_date) if !(result_string1 == '2022-08-08 19:04:19') { test_fail @@ -53,7 +53,7 @@ if !(result_string1 == '2022-08-08 19:04:19') { # Invalid format result_string1 := '201-32-22 17:25:00' -result_string2 := %sqldate(%{result_string1}) +result_string2 := %sqldate(result_string1) # This shouldn't exist, as the RHS above is NULL, and therefore the assignment will fail if (result_string2) { @@ -66,7 +66,7 @@ if (!(Module-Failure-Message == "Failed to parse time string \"201-32-22 17:25:0 # Invalid type NAS-IP-Address := "192.168.1.1" -result_string2 := %date(%{NAS-IP-Address}) +result_string2 := %date(NAS-IP-Address) if (result_string2) { test_fail diff --git a/src/tests/keywords/debug b/src/tests/keywords/debug index 788b99fafe..196f24ba8f 100644 --- a/src/tests/keywords/debug +++ b/src/tests/keywords/debug @@ -12,12 +12,12 @@ if (!(%debug(3) == 4)) { } # Call with NULL arg, should report current level -if (!(%debug(%{dummy_string}) == 3)) { +if (!(%debug(dummy_string) == 3)) { test_fail } # ...and again -if (!(%debug(%{dummy_string}) == 3)) { +if (!(%debug(dummy_string) == 3)) { test_fail } diff --git a/src/tests/keywords/edit-eval-rhs b/src/tests/keywords/edit-eval-rhs index afa41fad6b..3243c83340 100644 --- a/src/tests/keywords/edit-eval-rhs +++ b/src/tests/keywords/edit-eval-rhs @@ -3,7 +3,7 @@ uint32 foo Tmp-Integer-0 := 1 Tmp-Integer-1 := { 3, 6, 9 } -foo = %eval(%{'%{Tmp-Integer-1[' + "%{Tmp-Integer-0}" + ']}'}) +foo = %eval('%{Tmp-Integer-1[' + "%{Tmp-Integer-0}" + ']}') if (foo != 6) { test_fail diff --git a/src/tests/keywords/edit-multivalue b/src/tests/keywords/edit-multivalue index 56c4714cea..d38ea9efbc 100644 --- a/src/tests/keywords/edit-multivalue +++ b/src/tests/keywords/edit-multivalue @@ -7,7 +7,7 @@ baz = "a,b,c,d,e" # # Append, don't create multiple versions # -bar += %explode(%{baz}, ',') +bar += %explode(baz, ',') if !(bar == "abcde") { test_fail @@ -19,7 +19,7 @@ if !(bar == "abcde") { # We cannot have multiple copies of local variables. There's no real # reason why, but for now it's safer to be limited. # -foo := %explode(%{baz}, ',') +foo := %explode(baz, ',') if !(foo[#] == 1) { test_fail } diff --git a/src/tests/keywords/escape b/src/tests/keywords/escape index 233f532aa1..6de1c95873 100644 --- a/src/tests/keywords/escape +++ b/src/tests/keywords/escape @@ -25,39 +25,39 @@ test_string8 := 'Œ=C4=8Cÿ' # = not followed by hex and without 2 following chars test_string9 := 'a=Az=y' -if (!((string)%escape.escape("%{test_string1}") == test_string1)) { +if (!((string)%escape.escape(test_string1) == test_string1)) { test_fail } -if (!((string)%escape.escape("%{test_string2}") == test_string4)) { +if (!((string)%escape.escape(test_string2) == test_string4)) { test_fail } -if (!((string)%escape.escape("%{test_string3}") == test_string5)) { +if (!((string)%escape.escape(test_string3) == test_string5)) { test_fail } -if (!((string)%escape.unescape("%{test_string1}") == test_string1)) { +if (!((string)%escape.unescape(test_string1) == test_string1)) { test_fail } -if (!((string)%escape.unescape("%{test_string4}") == "%{test_string2}")) { +if (!((string)%escape.unescape(test_string4) == test_string2)) { test_fail } -if (!((string)%escape.unescape("%{test_string5}") == test_string3)) { +if (!((string)%escape.unescape(test_string5) == test_string3)) { test_fail } -if (!((string)%escape.escape("%{test_string7}") == test_string8)) { +if (!((string)%escape.escape(test_string7) == test_string8)) { test_fail } -if (!((string)%escape.unescape("%{test_string8}") == test_string7)) { +if (!((string)%escape.unescape(test_string8) == test_string7)) { test_fail } -if (!((string)%escape.unescape("%{test_string9}") == test_string9)) { +if (!((string)%escape.unescape(test_string9) == test_string9)) { test_fail } diff --git a/src/tests/keywords/escape-sequences b/src/tests/keywords/escape-sequences index 6790f337a9..6249c066e3 100644 --- a/src/tests/keywords/escape-sequences +++ b/src/tests/keywords/escape-sequences @@ -21,15 +21,15 @@ request += { } -if (!(%length(%{Reply-Message}) == 39)) { +if (%length(Reply-Message) != 39) { test_fail } -if (!(%length(%{Callback-Number}) == 42)) { +if (%length(Callback-Number) != 42) { test_fail } -result_string := "%{(string) %{test_octets}}" +result_string := "%{(string) test_octets}" if (!(result_string == "i have scary embedded things\000 inside me")) { test_fail } @@ -44,11 +44,11 @@ if (!(result_string == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) { test_fail } -if (!("%{Reply-Message[0]}" == "i have scary embedded things\000 inside me")) { +if ("%{Reply-Message[0]}" != "i have scary embedded things\000 inside me") { test_fail } -if (!(Reply-Message[1] == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) { +if (Reply-Message[1] != "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°") { test_fail } @@ -80,7 +80,7 @@ if (!(Callback-Id[1] == "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°")) { # Other data types # result_string := "%{(string) test_ipaddr}" -if (!(%length(%{result_string}) == 9)) { +if (!(%length(result_string) == 9)) { test_fail } diff --git a/src/tests/keywords/expr-double b/src/tests/keywords/expr-double index be3d605cdd..772acbb270 100644 --- a/src/tests/keywords/expr-double +++ b/src/tests/keywords/expr-double @@ -1,5 +1,5 @@ # # We only care if this crashes or not. # -Filter-Id := "%{1 + 1} %tolower(1)" +Filter-Id := "%{1 + 1} %tolower('1')" success diff --git a/src/tests/keywords/filter_password b/src/tests/keywords/filter_password index c089183628..2a1f66000c 100644 --- a/src/tests/keywords/filter_password +++ b/src/tests/keywords/filter_password @@ -4,27 +4,20 @@ Reply-Message := "bob\000hello" +if %length(Reply-Message) != 9 { + test_fail +} + # -# Commented out because it fails +# This assignment grabs the first element of the list, and tosses the remaining ones. # -#if %length("\000") != 1 { -# test_fail -#} - -if Reply-Message { - group tmp - octets delim +Reply-Message := %explode(Reply-Message, 0x00) - # - # Because "\000" yields "zero length delimiter is not allowed" - # - delim = 0x00 - tmp.Reply-Message := %explode(%{Reply-Message}, "%{delim}") - - Reply-Message := tmp.Reply-Message[0] +if Reply-Message != "bob" { + test_fail } -if Reply-Message != "bob" { +if %length(Reply-Message) != 3 { test_fail } diff --git a/src/tests/keywords/foreach-explode b/src/tests/keywords/foreach-explode index ce4b1be9f3..11e3147337 100644 --- a/src/tests/keywords/foreach-explode +++ b/src/tests/keywords/foreach-explode @@ -7,7 +7,7 @@ string result input = "a b c d e f" result = "" -foreach string thing (%explode(%{input}, ' ')) { +foreach string thing (%explode(input, ' ')) { result += thing result += ',' } diff --git a/src/tests/keywords/foreach-explode-key b/src/tests/keywords/foreach-explode-key index f48b7ca344..733fabf4c0 100644 --- a/src/tests/keywords/foreach-explode-key +++ b/src/tests/keywords/foreach-explode-key @@ -7,7 +7,7 @@ string result input = "a b c d e f" result = "" -foreach uint32 key,string thing (%explode(%{input}, ' ')) { +foreach uint32 key,string thing (%explode(input, ' ')) { result += thing result += ':' result += (string) key diff --git a/src/tests/keywords/foreach-key-ref b/src/tests/keywords/foreach-key-ref index 09bcee68f3..9d4318b45f 100644 --- a/src/tests/keywords/foreach-key-ref +++ b/src/tests/keywords/foreach-key-ref @@ -14,7 +14,7 @@ Tmp-String-1 := { "a", "b", "c", "d" } foreach string key, string name (Tmp-String-0[*]) { total += key total += " = '" - total += %eval(%{"&" + %{key}}) + total += %eval(key) total += "', " } diff --git a/src/tests/keywords/hex b/src/tests/keywords/hex index c879116ce0..849b6aed41 100644 --- a/src/tests/keywords/hex +++ b/src/tests/keywords/hex @@ -30,73 +30,73 @@ test_int64 := 1152921505566832445 test_ipv4prefix := 57.56.55.62/32 # String -result_string := %hex(%{test_string}) +result_string := %hex(test_string) if (!(result_string == '39383730')) { test_fail } # Octets -result_string := %hex(%{test_octets}) +result_string := %hex(test_octets) if (!(result_string == '39383731')) { test_fail } # IP Address -result_string := %hex(%{test_ipaddr}) +result_string := %hex(test_ipaddr) if (!(result_string == '39383732')) { test_fail } # Integer -result_string := %hex(%{test_integer}) +result_string := %hex(test_integer) if (!(result_string == '39383734')) { test_fail } # ifid -result_string := %hex(%{test_ifid}) +result_string := %hex(test_ifid) if (!(result_string == '0000000039383737')) { test_fail } # ipv6addr -result_string := %hex(%{test_ipv6addr}) +result_string := %hex(test_ipv6addr) if (!(result_string == '00000000000000000000000039383738')) { test_fail } # ipv6addrprefix -result_string := %hex(%{test_ipv6prefix}) +result_string := %hex(test_ipv6prefix) if (!(result_string == '008000000000000000000000000039383739')) { test_fail } # byte -result_string := %hex(%{test_byte}) +result_string := %hex(test_byte) if (!(result_string == '3a')) { test_fail } # short -result_string := %hex(%{test_short}) +result_string := %hex(test_short) if (!(result_string == '373b')) { test_fail } # ethernet -result_string := %hex(%{test_ether}) +result_string := %hex(test_ether) if (!(result_string == '00003938373c')) { test_fail } # integer64 -result_string := %hex(%{test_int64}) +result_string := %hex(test_int64) if (!(result_string == '100000003938373d')) { test_fail } # ipv4prefix -result_string := %hex(%{test_ipv4prefix}) +result_string := %hex(test_ipv4prefix) if (!(result_string == '203938373e')) { test_fail } @@ -107,7 +107,7 @@ request += { Class = 0x0405 } -NAS-Identifier := %hex(%{Class[*]}) +NAS-Identifier := %hex(Class[*]) if (NAS-Identifier[#] != 3) { test_fail diff --git a/src/tests/keywords/if-failed-xlat b/src/tests/keywords/if-failed-xlat index 568af21a1f..79b70d84c9 100644 --- a/src/tests/keywords/if-failed-xlat +++ b/src/tests/keywords/if-failed-xlat @@ -6,7 +6,7 @@ if (('${feature.regex-pcre}' == 'yes') || ('${feature.regex-pcre2}' == 'yes')) { # Check failure when no previous capture - named group # but a failed regex is equivalent to an empty string -if (%regex(foo)) { +if (%regex('foo')) { test_fail } diff --git a/src/tests/keywords/if-regex-match-named b/src/tests/keywords/if-regex-match-named index 1cbfb218ae..52f25137d1 100644 --- a/src/tests/keywords/if-regex-match-named +++ b/src/tests/keywords/if-regex-match-named @@ -21,7 +21,7 @@ if (!(Module-Failure-Message[*] == "No previous regex capture")) { request -= Module-Failure-Message[*] # Check failure when no previous capture - named group -if (%regex(foo)) { +if (%regex('foo')) { test_fail } @@ -32,7 +32,7 @@ if (!(Module-Failure-Message[*] == "No previous named regex capture group")) { request -= Module-Failure-Message[*] # Check failure when no previous capture - numbered group -if (%regex(%{Port-Limit})) { +if (%regex(Port-Limit)) { test_fail } @@ -44,7 +44,7 @@ request -= Module-Failure-Message[*] # uncompiled - ref - named capture groups if (User-Name =~ /^(?[0-9])_(?[0-9])?_(?[0-9]*)_(?[0-9]+)_(?[^_])_(?6)_(?[7-8])%{dummy_string}/) { - result_string := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}" + result_string := "%regex('seven')_%regex('six')_%regex('five')_%regex('four')_%regex('three')_%regex('two')_%regex('one')_%{0}" if (!(result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) { test_fail } @@ -55,7 +55,7 @@ else { # Checking capture groups are cleared out correctly if (User-Name =~ /^(?[0-9])_%{dummy_string}/) { - result_string := "%{0}%regex(one)%regex(two)%regex(three)%regex(four)%regex(five)%regex(six)%regex(seven)" + result_string := "%{0}%regex('one')%regex('two')%regex('three')%regex('four')%regex('five')%regex('six')%regex('seven')" if (!(result_string == '1_1')) { test_fail } @@ -66,7 +66,7 @@ else { # Checking capture groups are cleared out correctly when there are no matches if (User-Name =~ /^.%{dummy_string}/) { - result_string := "%{0}%regex(one)%regex(two)%regex(three)%regex(four)%regex(five)%regex(six)%regex(seven)" + result_string := "%{0}%regex('one')%regex('two')%regex('three')%regex('four')%regex('five')%regex('six')%regex('seven')" if (!(result_string == '1')) { test_fail } @@ -77,7 +77,7 @@ else { # compiled - ref - named capture groups if (User-Name =~ /^(?[0-9])_(?[0-9])?_(?[0-9]*)_(?[0-9]+)_(?[^_])_(?6)_(?[7-8])/) { - result_string := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}" + result_string := "%regex('seven')_%regex('six')_%regex('five')_%regex('four')_%regex('three')_%regex('two')_%regex('one')_%{0}" if (!(result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) { test_fail } @@ -88,7 +88,7 @@ else { # compiled - xlat - named capture groups if ('1_2_3_4_5_6_7' =~ /^(?[0-9])_(?[0-9])?_(?[0-9]*)_(?[0-9]+)_(?[^_])_(?6)_(?[7-8])/) { - result_string := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}" + result_string := "%regex('seven')_%regex('six')_%regex('five')_%regex('four')_%regex('three')_%regex('two')_%regex('one')_%{0}" if (!(result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) { test_fail } @@ -128,7 +128,7 @@ if (User-Name =~ /^(?[0-9])_(?[0-9])?_(?[0-9]*)_(?[0-9]+) g := 6 h := 7 - result_string := "%regex(%{h})_%regex(%{g})_%regex(%{f})_%regex(%{e})_%regex(%{d})_%regex(%{c})_%regex(%{b})_%regex(%{a})" + result_string := "%regex(h)_%regex(g)_%regex(f)_%regex(e)_%regex(d)_%regex(c)_%regex(b)_%regex(a)" if (!(result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) { test_fail } diff --git a/src/tests/keywords/if-skip b/src/tests/keywords/if-skip index 52358a9e9f..d9bee1eb56 100644 --- a/src/tests/keywords/if-skip +++ b/src/tests/keywords/if-skip @@ -30,7 +30,7 @@ else { if (true) { ok } -elsif ("%foo(bar)") { # no pass2 +elsif ("%foo('bar')") { # no pass2 no-such-module } else { diff --git a/src/tests/keywords/if-tlv b/src/tests/keywords/if-tlv index be5fb36701..3f7dfe845a 100644 --- a/src/tests/keywords/if-tlv +++ b/src/tests/keywords/if-tlv @@ -4,7 +4,7 @@ %map("TLS-Certificate.Issuer = 'foo'") -if !(TLS-Certificate.Issuer == 'foo') { +if TLS-Certificate.Issuer != 'foo' { test_fail } diff --git a/src/tests/keywords/immutable b/src/tests/keywords/immutable index eb0d795dc0..f83cb902b3 100644 --- a/src/tests/keywords/immutable +++ b/src/tests/keywords/immutable @@ -18,7 +18,7 @@ if !(NAS-Port == 1813) { # # Mark it as immutable. The value shouldn't change. # -%immutable(request.NAS-Port[*]) +%immutable('request.NAS-Port[*]') if !(NAS-Port == 1813) { test_fail } diff --git a/src/tests/keywords/join b/src/tests/keywords/join index 9d0df2bb42..6b8288b023 100644 --- a/src/tests/keywords/join +++ b/src/tests/keywords/join @@ -30,13 +30,13 @@ debug_request # # @todo - fix this... # -result_string := %concat(%join(%{control.[*]}, %{request.Framed-IP-Address}), '. ') +result_string := %concat(%join(%{control.[*]}, request.Framed-IP-Address), '. ') if (!(result_string == "bob. hello. ab c. de fg. 123. 192.168.1.254")) { test_fail } -result_string := %concat(%join(%{control.Filter-Id[*]}, %{control.NAS-Port}), ',') +result_string := %concat(%join(control.Filter-Id[*], control.NAS-Port), ',') if (!(result_string == "ab c,de fg,123")) { test_fail } diff --git a/src/tests/keywords/length b/src/tests/keywords/length index ab258c205e..77a563e0ef 100644 --- a/src/tests/keywords/length +++ b/src/tests/keywords/length @@ -20,7 +20,7 @@ abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\ abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' -if (!(%length(%{test_string}) == 260)) { +if (%length(test_string) != 260) { test_fail } @@ -38,19 +38,19 @@ test_int64 := 1152921505566832445 test_ipv4prefix := 57.56.55.62/32 # String - bin 0x39383730 -result_int := %length(%{test_string}) -if (!(result_int == 4)) { +result_int := %length(test_string) +if (result_int != 4) { test_fail } # Octets - bin 0x39383731 -result_int := %length(%{test_octets}) +result_int := %length(test_octets) if (!(result_int == 4)) { test_fail } # IP Address - bin 0x39383732 -result_int := %length(%{test_ipaddr}) +result_int := %length(test_ipaddr) if (!(result_int == 4)) { test_fail } @@ -62,55 +62,55 @@ if (!(result_int == 12)) { } # Integer - bin 0x39383734 -result_int := %length(%{test_integer}) +result_int := %length(test_integer) if (!(result_int == 4)) { test_fail } # ifid - bin 0x0000000039383737 -result_int := %length(%{test_ifid}) +result_int := %length(test_ifid) if (!(result_int == 8)) { test_fail } # ipv6addr - bin 0x00000000000000000000000039383738 -result_int := %length(%{test_ipv6addr}) +result_int := %length(test_ipv6addr) if (!(result_int == 16)) { test_fail } # ipv6addrprefix - bin 0x8000000000000000000000000039383739 -result_int := %length(%{test_ipv6prefix}) +result_int := %length(test_ipv6prefix) if (!(result_int == 17)) { test_fail } # byte - bin 0x3a -result_int := %length(%{test_byte}) +result_int := %length(test_byte) if (!(result_int == 1)) { test_fail } # short - bin 0x373b -result_int := %length(%{test_short}) +result_int := %length(test_short) if (!(result_int == 2)) { test_fail } # ethernet - bin 0x00003938373c -result_int := %length(%{test_ether}) +result_int := %length(test_ether) if (!(result_int == 6)) { test_fail } # integer64 - bin 0x100000003938373d -result_int := %length(%{test_int64}) +result_int := %length(test_int64) if (!(result_int == 8)) { test_fail } # ipv4prefix - bin 0x203938373e -result_int := %length(%{test_ipv4prefix}) +result_int := %length(test_ipv4prefix) if (!(result_int == 5)) { test_fail } diff --git a/src/tests/keywords/mschap b/src/tests/keywords/mschap index a240d702af..4a5659d064 100644 --- a/src/tests/keywords/mschap +++ b/src/tests/keywords/mschap @@ -15,41 +15,41 @@ request += { Vendor-Specific.Microsoft.CHAP-Response = 0x00010000000000000000000000000000000000000000000000008860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f } -result_octets := %mschap(Challenge) +result_octets := %mschap('Challenge') if !(result_octets == 0xe96e4fff2955c4f1) { test_fail } -result_octets := %mschap(NT-Response) +result_octets := %mschap('NT-Response') if !(result_octets == 0x8860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f) { test_fail } -result_string := %mschap(NT-Domain) +result_string := %mschap('NT-Domain') if !(result_string == 'EXAMPLE') { test_fail } -result_string := %mschap(User-Name) +result_string := %mschap('User-Name') if !(result_string == 'bob') { test_fail } request.Vendor-Specific.Microsoft.CHAP-Response := 0x00006937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db158860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f -result_octets := %mschap(LM-Response) +result_octets := %mschap('LM-Response') if !(result_octets == 0x6937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db15) { test_fail } # Hashing -result_octets := %mschap(NT-Hash, 'testing_123') +result_octets := %mschap('NT-Hash', 'testing_123') if !(result_octets == 0xfa782604f85eb3564f555648341b53e4) { test_fail } -result_octets := %mschap(LM-Hash, 'testing_123') +result_octets := %mschap('LM-Hash', 'testing_123') if !(result_octets == 0x2d5545077d7b7d2ae4343f96ab15c596) { test_fail } @@ -60,19 +60,19 @@ request -= Vendor-Specific.Microsoft.CHAP-Response[*] Vendor-Specific.Microsoft.CHAP-Challenge := 0x04408dc2a98dae1ce351dfc53f57d08e Vendor-Specific.Microsoft.CHAP2-Response := 0x00010e93cfbfcef8d5b6af42d2b2ca5b43180000000000000000bc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b200 -result_octets := %mschap(Challenge) +result_octets := %mschap('Challenge') if !(result_octets == 0xad18b6b8e1478b4c) { test_fail } -result_octets := %mschap(NT-Response) +result_octets := %mschap('NT-Response') if !(result_octets == 0xbc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b2) { test_fail } # Invalid Vendor-Specific.Microsoft.CHAP-Challenge := 0xf0eac4151d5346662ba8c5e428 -result_string := %mschap(Challenge) +result_string := %mschap('Challenge') if (result_string) { test_fail diff --git a/src/tests/keywords/nexttime b/src/tests/keywords/nexttime index a044cac822..9ab47cc385 100644 --- a/src/tests/keywords/nexttime +++ b/src/tests/keywords/nexttime @@ -8,7 +8,7 @@ uint32 result_integer # different numbers of days involved. Check hour / day / week # -result_integer := "%{%nexttime(2h) - %nexttime(1h)}" +result_integer := "%{%nexttime('2h') - %nexttime('1h')}" # We have a fudge factor of 1 second either way if ((result_integer < 3599) || (result_integer > 3601)) { @@ -18,7 +18,7 @@ if ((result_integer < 3599) || (result_integer > 3601)) { # # Day # -result_integer := "%{%nexttime(3d) - %nexttime(1d)}" +result_integer := "%{%nexttime('3d') - %nexttime('1d')}" if ((result_integer < 172799) || (result_integer > 172801)) { test_fail } @@ -26,7 +26,7 @@ if ((result_integer < 172799) || (result_integer > 172801)) { # # Week # -result_integer := "%{%nexttime(4w) - %nexttime(2w)}" +result_integer := "%{%nexttime('4w') - %nexttime('2w')}" if ((result_integer < 1209599) || (result_integer > 1209601)) { test_fail } diff --git a/src/tests/keywords/pairs b/src/tests/keywords/pairs index 9d358f0e1a..18993fb505 100644 --- a/src/tests/keywords/pairs +++ b/src/tests/keywords/pairs @@ -27,17 +27,17 @@ Tmp-Group-0 += { # #pairs := %cast('string', %{Tmp-Group-0.[*]}) -result_string := "%concat(%pairs(Tmp-Group-0.[*]), ', ')" +result_string := "%concat(%pairs('Tmp-Group-0.[*]'), ', ')" if !(result_string == 'Filter-Id = "This is a string", Filter-Id = "This is another one", Class = 0x000504030201, NAS-Port = 7331') { test_fail } -result_string := "%pairs(Tmp-Group-0.Filter-Id)" +result_string := "%pairs('Tmp-Group-0.Filter-Id')" if !(result_string == 'Filter-Id = "This is a string"') { test_fail } -result_string := "%concat(%pairs(Tmp-Group-0.Filter-Id[*]), ', ')" +result_string := "%concat(%pairs('Tmp-Group-0.Filter-Id[*]'), ', ')" if !(result_string == 'Filter-Id = "This is a string", Filter-Id = "This is another one"') { test_fail } @@ -45,17 +45,17 @@ if !(result_string == 'Filter-Id = "This is a string", Filter-Id = "This is anot # # Must be nested # -result_string := "%concat(%pairs(control.[*]), ', ')" +result_string := "%concat(%pairs('control.[*]'), ', ')" if !(result_string == 'Password = { Cleartext = "hello" }') { test_fail } -result_string := "%pairs(control.User-Name)" +result_string := "%pairs('control.User-Name')" if (!(result_string == '')) { test_fail } -result_string := "%pairs(request.Tmp-Group-0)" +result_string := "%pairs('request.Tmp-Group-0')" if !(result_string == 'Tmp-Group-0 = { Filter-Id = "This is a string", Filter-Id = "This is another one", Class = 0x000504030201, NAS-Port = 7331 }') { test_fail } diff --git a/src/tests/keywords/randstr b/src/tests/keywords/randstr index a8598d3c64..f2613c8ede 100644 --- a/src/tests/keywords/randstr +++ b/src/tests/keywords/randstr @@ -3,7 +3,7 @@ string result_string # # Empty output on empty input # -result_string := "%randstr(%{result_string})" +result_string := "%randstr(result_string)" if !(result_string == "") { test_fail } @@ -11,27 +11,27 @@ if !(result_string == "") { # # Check length of output # -result_string := "%randstr(nnn)" -if (!(%length(%{result_string}) == 3)) { +result_string := "%randstr('nnn')" +if (!(%length(result_string) == 3)) { test_fail } -result_string := "%randstr(24a)" -if (!(%length(%{result_string}) == 24)) { +result_string := %randstr('24a') +if (!(%length(result_string) == 24)) { test_fail } # # Check maximum repetition # -result_string := "%randstr(1030aa)" -if (!(%length(%{result_string}) == 1025)) { +result_string := %randstr('1030aa') +if (!(%length(result_string) == 1025)) { test_fail } # # Check invalid character class # -result_string := "%randstr(G)" +result_string := %randstr('G') if !(result_string == "") { test_fail @@ -40,8 +40,8 @@ if !(result_string == "") { # # Check repetition of binary output # -result_string := "%randstr(10b)" -if (!(%length(%{result_string}) == 10)) { +result_string := %randstr('10b') +if (!(%length(result_string) == 10)) { test_fail } diff --git a/src/tests/keywords/timeout b/src/tests/keywords/timeout index 807c2032de..c41e2b495e 100644 --- a/src/tests/keywords/timeout +++ b/src/tests/keywords/timeout @@ -10,7 +10,7 @@ bool c # redundant { timeout 0.01s { - a := %delay_10s(0.1) + a := %delay_10s(0.1s) test_fail } @@ -21,7 +21,7 @@ redundant { redundant { timeout "0.01" { - a := %delay_10s(0.1) + a := %delay_10s(0.1s) test_fail } diff --git a/src/tests/keywords/tolower b/src/tests/keywords/tolower index 7e47924da5..175f082fa6 100644 --- a/src/tests/keywords/tolower +++ b/src/tests/keywords/tolower @@ -5,13 +5,13 @@ string test_string string dummy_string test_string := "AbCdE" -test_string := %tolower(%{test_string}) +test_string := %tolower(test_string) if !(test_string == "abcde") { test_fail } -test_string := %tolower(AAbbCCdd) +test_string := %tolower('AAbbCCdd') if !(test_string == "aabbccdd") { test_fail } @@ -19,7 +19,7 @@ if !(test_string == "aabbccdd") { # # Doesn't exist # -test_string := "%tolower(%{dummy_string})" +test_string := "%tolower(dummy_string)" if !(test_string == "") { test_fail } diff --git a/src/tests/keywords/toupper b/src/tests/keywords/toupper index 9a4ba40873..dfccc039c9 100644 --- a/src/tests/keywords/toupper +++ b/src/tests/keywords/toupper @@ -5,17 +5,17 @@ string test_string string dummy_string test_string := "AbCdE" -test_string := %toupper(%{test_string}) +test_string := %toupper(test_string) if (!(test_string == "ABCDE")) { test_fail } -test_string := %toupper(AAbbCCdd) +test_string := %toupper('AAbbCCdd') if (!(test_string == "AABBCCDD")) { test_fail } -test_string := "%toupper(%{dummy_string})" +test_string := "%toupper(dummy_string)" if !(test_string == "") { test_fail } diff --git a/src/tests/keywords/xlat-arg-missing b/src/tests/keywords/xlat-arg-missing new file mode 100644 index 0000000000..f506c92f87 --- /dev/null +++ b/src/tests/keywords/xlat-arg-missing @@ -0,0 +1,3 @@ +bool foo + +foo := %file.exists() # ERROR diff --git a/src/tests/keywords/xlat-config b/src/tests/keywords/xlat-config index f6d891fad6..0998b4ca2f 100644 --- a/src/tests/keywords/xlat-config +++ b/src/tests/keywords/xlat-config @@ -4,13 +4,13 @@ string result_string uint32 result_integer -result_string := "%config(modules.static.test.boolean)" +result_string := "%config('modules.static.test.boolean')" if (!(result_string == "no")) { test_fail } result_string := "test" -result_integer := %config(modules.static.%{result_string}.integer) +result_integer := %config("modules.static.%{result_string}.integer") if (!(result_integer == 1)) { test_fail } diff --git a/src/tests/keywords/xlat-delay b/src/tests/keywords/xlat-delay index 5afad94480..2a7db434b5 100644 --- a/src/tests/keywords/xlat-delay +++ b/src/tests/keywords/xlat-delay @@ -1,21 +1,21 @@ # # PRE: update # -float32 result_float +time_delta result # This is mainly a smoke test... i.e. if it crashes there's smoke %delay_10s() # Should 'blip' the request -result_float := %delay_10s(0.1) -if (!result_float) { +result := %delay_10s(0.1s) +if (!result) { fail } # # Check the delay was ~100ms # -if (result_float < 0.1) { +if ((result < 0.1s) || (result > 0.2s)) { fail } diff --git a/src/tests/keywords/xlat-dhcpv4 b/src/tests/keywords/xlat-dhcpv4 index 31e5c12836..0996f91f95 100644 --- a/src/tests/keywords/xlat-dhcpv4 +++ b/src/tests/keywords/xlat-dhcpv4 @@ -6,7 +6,7 @@ octets test_octets test_octets := 0x520d0103abcdef0206010203040506 # the protocol decoder puts the attributes into a flat namespace -if (!(%dhcpv4.decode(%{test_octets}) == 1)) { +if (!(%dhcpv4.decode(test_octets) == 1)) { test_fail } @@ -21,7 +21,7 @@ if !(Relay-Agent-Information.Remote-Id == 0x010203040506) { # # Encode all of the Relay-Agent-Information suboptions # -test_octets := %dhcpv4.encode(request.Relay-Agent-Information.[*]) +test_octets := %dhcpv4.encode('request.Relay-Agent-Information.[*]') if !(test_octets == 0x520d0103abcdef0206010203040506) { test_fail @@ -31,7 +31,7 @@ if !(test_octets == 0x520d0103abcdef0206010203040506) { # Check decoding and encoding of VSAs # test_octets := 0x7d1900002458140101010204c0a80101050968656c6c6f2e62696e -if !(%dhcpv4.decode(%{test_octets}) == 1) { +if !(%dhcpv4.decode(test_octets) == 1) { test_fail } @@ -39,13 +39,13 @@ if (V-I-Vendor-Specific.CTS.Firmware-File-Name != 'hello.bin') { test_fail } -test_octets := %dhcpv4.encode(V-I-Vendor-Specific) +test_octets := %dhcpv4.encode('V-I-Vendor-Specific') if (test_octets != 0x7d1900002458140101010204c0a80101050968656c6c6f2e62696e) { test_fail } -test_octets := %dhcpv4.encode(V-I-Vendor-Specific.CTS.[*]) +test_octets := %dhcpv4.encode('V-I-Vendor-Specific.CTS.[*]') if (test_octets != 0x7d1900002458140101010204c0a80101050968656c6c6f2e62696e) { test_fail } diff --git a/src/tests/keywords/xlat-escape b/src/tests/keywords/xlat-escape index 8a5a81c0cf..0586034eb8 100644 --- a/src/tests/keywords/xlat-escape +++ b/src/tests/keywords/xlat-escape @@ -8,7 +8,7 @@ if !("\%{ FOO}" == '%{ FOO}') { test_fail } -if !(%tolower(\%{FOO}) == '%{foo}') { +if !(%tolower("\%{FOO}") == '%{foo}') { test_fail } diff --git a/src/tests/keywords/xlat-explode b/src/tests/keywords/xlat-explode index 1581e82910..ed710db99c 100644 --- a/src/tests/keywords/xlat-explode +++ b/src/tests/keywords/xlat-explode @@ -17,27 +17,27 @@ control += { Filter-Id = 'here. are . some. words. ' } -result_string := "%concat(%explode(%{Class}, '|'), ',')" +result_string := "%concat(%explode(Class, '|'), ',')" if (!(result_string == "1=1,my_attr=2,my_attr=hello")) { test_fail } -result_string := "%concat(%explode(%{Calling-Station-ID}, '|'), ',')" +result_string := "%concat(%explode(Calling-Station-ID, '|'), ',')" if (!(result_string == "")) { test_fail } -result_string := "%concat(%explode(%{control.User-Name[*]}, |), ',')" +result_string := "%concat(%explode(control.User-Name[*], '|'), ',')" if (!(result_string == "hello,goodbye,morning,night,1")) { test_fail } -result_string := "%concat(%explode(%{control.Reply-Message}, |), ',')" +result_string := "%concat(%explode(control.Reply-Message, '|'), ',')" if !(result_string == 'Can\'t touch this') { test_fail } -result_string := "%concat(%explode(%{control.Filter-Id}, '. '), ',')" +result_string := "%concat(%explode(control.Filter-Id, '. '), ',')" if !(result_string == 'here, are ,some, words') { test_fail } diff --git a/src/tests/keywords/xlat-interpreter b/src/tests/keywords/xlat-interpreter index 2cd1410583..1063ef5b16 100644 --- a/src/tests/keywords/xlat-interpreter +++ b/src/tests/keywords/xlat-interpreter @@ -7,19 +7,19 @@ string result_string uint32 result_integer -result_string := "%interpreter(.filename)" -result_integer := "%interpreter(.line)" +result_string := "%interpreter('.filename')" +result_integer := "%interpreter('.line')" if (!(result_string == "src/tests/keywords/xlat-interpreter")) { test_fail } -result_string := "%interpreter(.name)" +result_string := "%interpreter('.name')" if (!(result_string == "result_string")) { test_fail } -result_string := "%interpreter(.type)" +result_string := "%interpreter('.type')" if (!(result_string == "edit")) { test_fail } diff --git a/src/tests/keywords/xlat-redundant b/src/tests/keywords/xlat-redundant index 5d84ae7b91..907deaf01f 100644 --- a/src/tests/keywords/xlat-redundant +++ b/src/tests/keywords/xlat-redundant @@ -2,18 +2,18 @@ # # PRE: if # -if (!(%concat(%test1.passthrough(foo, bar),'|') == "foo|bar")) { +if (%concat(%test1.passthrough('foo', 'bar'),'|') != "foo|bar") { test_fail } -if (!(%concat(%test2.passthrough(foo, bar), '|') == "foo|bar")) { +if (%concat(%test2.passthrough('foo', 'bar'), '|') != "foo|bar") { test_fail } # # The config has a "redundant" block for test1 and test2. # -if (!(%concat(%redundant_test.passthrough(foo, bar), '|') == "foo|bar")) { +if (%concat(%redundant_test.passthrough('foo', 'bar'), '|') != "foo|bar") { test_fail } diff --git a/src/tests/keywords/xlat-subst b/src/tests/keywords/xlat-subst index 3c63d2d058..249e34e340 100644 --- a/src/tests/keywords/xlat-subst +++ b/src/tests/keywords/xlat-subst @@ -13,78 +13,78 @@ empty_string := '' # # Global substitution -if (!(%subst(%{test_string1}, 'a', 'b') == 'bbb')) { +if (!(%subst(test_string1, 'a', 'b') == 'bbb')) { test_fail } # No match -if (!(%subst(%{test_string1}, 'c', 'b') == 'aaa')) { +if (!(%subst(test_string1, 'c', 'b') == 'aaa')) { test_fail } # Line ending rewrite -if (!(%subst(%{test_string2}, "\n", "\r") == "\r\r\r")) { +if (!(%subst(test_string2, "\n", "\r") == "\r\r\r")) { test_fail } # Removal -if (!(%subst(%{test_string1}, 'a', '') == "")) { +if (!(%subst(test_string1, 'a', '') == "")) { test_fail } # Removal of last word only -if (!(%subst(%{test_string3}, 'dog', '') == "the quick brown fox jumped over the lazy ")) { +if (!(%subst(test_string3, 'dog', '') == "the quick brown fox jumped over the lazy ")) { test_fail } # Removal of first and subsequent word -if (!(%subst(%{test_string3}, 'the', '') == " quick brown fox jumped over lazy dog")) { +if (!(%subst(test_string3, 'the', '') == " quick brown fox jumped over lazy dog")) { test_fail } # Removal of middle word -if (!(%subst(%{test_string3}, 'jumped', '') == "the quick brown fox over the lazy dog")) { +if (!(%subst(test_string3, 'jumped', '') == "the quick brown fox over the lazy dog")) { test_fail } # Replacement of last word only -if (!(%subst(%{test_string3}, 'dog', 'cat') == "the quick brown fox jumped over the lazy cat")) { +if (!(%subst(test_string3, 'dog', 'cat') == "the quick brown fox jumped over the lazy cat")) { test_fail } # Replacement of first and subsequent word -if (!(%subst(%{test_string3}, 'the', 'cat') == "cat quick brown fox jumped over cat lazy dog")) { +if (!(%subst(test_string3, 'the', 'cat') == "cat quick brown fox jumped over cat lazy dog")) { test_fail } # Replacement of middle word -if (!(%subst(%{test_string3}, 'jumped', 'cat') == "the quick brown fox cat over the lazy dog")) { +if (!(%subst(test_string3, 'jumped', 'cat') == "the quick brown fox cat over the lazy dog")) { test_fail } if ("${feature.regex-pcre2}" == 'yes') { # Basic substitutions -if (!(%subst(%{test_string1}, /a/, 'b') == 'baa')) { +if (!(%subst(test_string1, '/a/', 'b') == 'baa')) { test_fail } # Global substitution -if (!(%subst(%{test_string1}, /a/g, 'b') == 'bbb')) { +if (!(%subst(test_string1, '/a/g', 'b') == 'bbb')) { test_fail } # No match -if (!(%subst(%{test_string1}, /z/, 'b') == 'aaa')) { +if (!(%subst(test_string1, '/z/', 'b') == 'aaa')) { test_fail } # Basic substitutions - Dynamic -if (!(%subst(%{test_string1}, /a%{empty_string}/, 'b') == 'baa')) { +if (!(%subst(test_string1, "/a%{empty_string}/", 'b') == 'baa')) { test_fail } # Global substitution - Dynamic -if (!(%subst(%{test_string1}, /a%{empty_string}/g, 'b') == 'bbb')) { +if (!(%subst(test_string1, "/a%{empty_string}/g", 'b') == 'bbb')) { test_fail } @@ -93,35 +93,35 @@ if (!(%subst(%{test_string1}, /a%{empty_string}/g, 'b') == 'bbb')) { # # Check that newlines really are newlines -if (!(%length(%{test_string2}) == 3)) { +if (!(%length(test_string2) == 3)) { test_fail } # Strip out just the first newline -if (!(%subst(%{test_string2}, /^./s, '') == "\n\n")) { +if (!(%subst(test_string2, '/^./s', '') == "\n\n")) { test_fail } -if (!(%subst(%{test_string2}, /\n/, '') == "\n\n")) { +if (!(%subst(test_string2, '/\n/', '') == "\n\n")) { test_fail } # Strip out all the newlines -if (!(%subst(%{test_string2}, /\n/g, '') == '')) { +if (!(%subst(test_string2, '/\n/g', '') == '')) { test_fail } # Line ending switch -if (!(%subst(%{test_string2}, /\n/g, "\r") == "\r\r\r")) { +if (!(%subst(test_string2, '/\n/g', "\r") == "\r\r\r")) { test_fail } # Capture groups -if (!(%subst(%{test_string3}, '/^the (.*) brown (.*) jumped.*/', "$1,$2") == "quick,fox")) { +if (!(%subst(test_string3, '/^the (.*) brown (.*) jumped.*/', "$1,$2") == "quick,fox")) { test_fail } -if (!(%subst(%{test_string3}, "/^%{empty_string}the (.*) brown (.*) jumped.*/", "$1,$2") == "quick,fox")) { +if (!(%subst(test_string3, "/^%{empty_string}the (.*) brown (.*) jumped.*/", "$1,$2") == "quick,fox")) { test_fail }